diff options
Diffstat (limited to 'WebCore/svg')
345 files changed, 1893 insertions, 5029 deletions
diff --git a/WebCore/svg/ElementTimeControl.h b/WebCore/svg/ElementTimeControl.h index 4c185b9..4800cb1 100644 --- a/WebCore/svg/ElementTimeControl.h +++ b/WebCore/svg/ElementTimeControl.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2008 Apple Inc. All Rights Reserved. + * Copyright (C) 2009 Cameron McCormack <cam@mcc.id.au> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -35,10 +36,10 @@ namespace WebCore { class ElementTimeControl { public: virtual ~ElementTimeControl() {} - virtual bool beginElement(ExceptionCode&) = 0; - virtual bool beginElementAt(float offset, ExceptionCode&) = 0; - virtual bool endElement(ExceptionCode&) = 0; - virtual bool endElementAt(float offset, ExceptionCode&) = 0; + virtual void beginElement() = 0; + virtual void beginElementAt(float offset) = 0; + virtual void endElement() = 0; + virtual void endElementAt(float offset) = 0; }; } diff --git a/WebCore/svg/ElementTimeControl.idl b/WebCore/svg/ElementTimeControl.idl index 569fefa..e8ca615 100644 --- a/WebCore/svg/ElementTimeControl.idl +++ b/WebCore/svg/ElementTimeControl.idl @@ -1,5 +1,6 @@ /* * Copyright (C) 2008 Apple Inc. All Rights Reserved. + * Copyright (C) 2009 Cameron McCormack <cam@mcc.id.au> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -26,14 +27,10 @@ module svg { interface [Conditional=SVG, ObjCProtocol] ElementTimeControl { - boolean beginElement() - raises(DOMException); - boolean beginElementAt(in float offset) - raises(DOMException); - boolean endElement() - raises(DOMException); - boolean endElementAt(in float offset) - raises(DOMException); + void beginElement(); + void beginElementAt(in float offset); + void endElement(); + void endElementAt(in float offset); }; } diff --git a/WebCore/svg/GradientAttributes.h b/WebCore/svg/GradientAttributes.h index 6b3408e..941e816 100644 --- a/WebCore/svg/GradientAttributes.h +++ b/WebCore/svg/GradientAttributes.h @@ -1,8 +1,6 @@ /* Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either diff --git a/WebCore/svg/LinearGradientAttributes.h b/WebCore/svg/LinearGradientAttributes.h index fc59465..b71dc22 100644 --- a/WebCore/svg/LinearGradientAttributes.h +++ b/WebCore/svg/LinearGradientAttributes.h @@ -1,8 +1,6 @@ /* Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either @@ -29,10 +27,10 @@ namespace WebCore { struct LinearGradientAttributes : GradientAttributes { LinearGradientAttributes() - : m_x1(0.0) - , m_y1(0.0) - , m_x2(1.0) - , m_y2(0.0) + : m_x1() + , m_y1() + , m_x2(LengthModeWidth, "100%") + , m_y2() , m_x1Set(false) , m_y1Set(false) , m_x2Set(false) @@ -40,15 +38,15 @@ namespace WebCore { { } - double x1() const { return m_x1; } - double y1() const { return m_y1; } - double x2() const { return m_x2; } - double y2() const { return m_y2; } + SVGLength x1() const { return m_x1; } + SVGLength y1() const { return m_y1; } + SVGLength x2() const { return m_x2; } + SVGLength y2() const { return m_y2; } - void setX1(double value) { m_x1 = value; m_x1Set = true; } - void setY1(double value) { m_y1 = value; m_y1Set = true; } - void setX2(double value) { m_x2 = value; m_x2Set = true; } - void setY2(double value) { m_y2 = value; m_y2Set = true; } + void setX1(const SVGLength& value) { m_x1 = value; m_x1Set = true; } + void setY1(const SVGLength& value) { m_y1 = value; m_y1Set = true; } + void setX2(const SVGLength& value) { m_x2 = value; m_x2Set = true; } + void setY2(const SVGLength& value) { m_y2 = value; m_y2Set = true; } bool hasX1() const { return m_x1Set; } bool hasY1() const { return m_y1Set; } @@ -57,10 +55,10 @@ namespace WebCore { private: // Properties - double m_x1; - double m_y1; - double m_x2; - double m_y2; + SVGLength m_x1; + SVGLength m_y1; + SVGLength m_x2; + SVGLength m_y2; // Property states bool m_x1Set : 1; diff --git a/WebCore/svg/PatternAttributes.h b/WebCore/svg/PatternAttributes.h index b43d87e..36d1765 100644 --- a/WebCore/svg/PatternAttributes.h +++ b/WebCore/svg/PatternAttributes.h @@ -1,8 +1,6 @@ /* Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either diff --git a/WebCore/svg/RadialGradientAttributes.h b/WebCore/svg/RadialGradientAttributes.h index 273cd29..76a78ec 100644 --- a/WebCore/svg/RadialGradientAttributes.h +++ b/WebCore/svg/RadialGradientAttributes.h @@ -1,8 +1,6 @@ /* Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either @@ -29,11 +27,11 @@ namespace WebCore { struct RadialGradientAttributes : GradientAttributes { RadialGradientAttributes() - : m_cx(0.5) - , m_cy(0.5) - , m_r(0.5) - , m_fx(0.0) - , m_fy(0.0) + : m_cx(LengthModeWidth, "50%") + , m_cy(LengthModeWidth, "50%") + , m_r(LengthModeWidth, "50%") + , m_fx() + , m_fy() , m_cxSet(false) , m_cySet(false) , m_rSet(false) @@ -42,17 +40,17 @@ namespace WebCore { { } - double cx() const { return m_cx; } - double cy() const { return m_cy; } - double r() const { return m_r; } - double fx() const { return m_fx; } - double fy() const { return m_fy; } + SVGLength cx() const { return m_cx; } + SVGLength cy() const { return m_cy; } + SVGLength r() const { return m_r; } + SVGLength fx() const { return m_fx; } + SVGLength fy() const { return m_fy; } - void setCx(double value) { m_cx = value; m_cxSet = true; } - void setCy(double value) { m_cy = value; m_cySet = true; } - void setR(double value) { m_r = value; m_rSet = true; } - void setFx(double value) { m_fx = value; m_fxSet = true; } - void setFy(double value) { m_fy = value; m_fySet = true; } + void setCx(const SVGLength& value) { m_cx = value; m_cxSet = true; } + void setCy(const SVGLength& value) { m_cy = value; m_cySet = true; } + void setR(const SVGLength& value) { m_r = value; m_rSet = true; } + void setFx(const SVGLength& value) { m_fx = value; m_fxSet = true; } + void setFy(const SVGLength& value) { m_fy = value; m_fySet = true; } bool hasCx() const { return m_cxSet; } bool hasCy() const { return m_cySet; } @@ -62,11 +60,11 @@ namespace WebCore { private: // Properties - double m_cx; - double m_cy; - double m_r; - double m_fx; - double m_fy; + SVGLength m_cx; + SVGLength m_cy; + SVGLength m_r; + SVGLength m_fx; + SVGLength m_fy; // Property states bool m_cxSet : 1; diff --git a/WebCore/svg/SVGAElement.cpp b/WebCore/svg/SVGAElement.cpp index 9919702..d0d3613 100644 --- a/WebCore/svg/SVGAElement.cpp +++ b/WebCore/svg/SVGAElement.cpp @@ -3,8 +3,6 @@ 2004, 2005, 2007 Rob Buis <buis@kde.org> 2007 Eric Seidel <eric@webkit.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either @@ -33,6 +31,7 @@ #include "EventNames.h" #include "Frame.h" #include "FrameLoader.h" +#include "FrameLoaderTypes.h" #include "KeyboardEvent.h" #include "MappedAttribute.h" #include "MouseEvent.h" @@ -53,6 +52,8 @@ SVGAElement::SVGAElement(const QualifiedName& tagName, Document *doc) , SVGLangSpace() , SVGExternalResourcesRequired() , m_target(this, SVGNames::targetAttr) + , m_href(this, XLinkNames::hrefAttr) + , m_externalResourcesRequired(this, SVGNames::externalResourcesRequiredAttr, false) { } @@ -152,7 +153,7 @@ void SVGAElement::defaultEventHandler(Event* evt) } #endif if (document()->frame()) - document()->frame()->loader()->urlSelected(document()->completeURL(url), target, evt, false, false, true); + document()->frame()->loader()->urlSelected(document()->completeURL(url), target, evt, false, false, true, SendReferrer); } evt->setDefaultHandled(); @@ -165,20 +166,15 @@ bool SVGAElement::supportsFocus() const { if (isContentEditable()) return SVGStyledTransformableElement::supportsFocus(); - return isFocusable() || (document() && !document()->haveStylesheetsLoaded()); + return true; } bool SVGAElement::isFocusable() const { - if (isContentEditable()) - return SVGStyledTransformableElement::isFocusable(); - - // FIXME: Even if we are not visible, we might have a child that is visible. - // Dave wants to fix that some day with a "has visible content" flag or the like. - if (!renderer() || !(renderer()->style()->visibility() == VISIBLE)) + if (renderer() && renderer()->absoluteClippedOverflowRect().isEmpty()) return false; - return !renderer()->absoluteClippedOverflowRect().isEmpty(); + return SVGElement::isFocusable(); } bool SVGAElement::isMouseFocusable() const diff --git a/WebCore/svg/SVGAElement.h b/WebCore/svg/SVGAElement.h index 8890ca4..a3e59c5 100644 --- a/WebCore/svg/SVGAElement.h +++ b/WebCore/svg/SVGAElement.h @@ -3,8 +3,6 @@ 2004, 2005 Rob Buis <buis@kde.org> 2007 Eric Seidel <eric@webkit.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either @@ -60,11 +58,16 @@ namespace WebCore { virtual bool childShouldCreateRenderer(Node*) const; - protected: - virtual const SVGElement* contextElement() const { return this; } - private: ANIMATED_PROPERTY_DECLARATIONS(SVGAElement, SVGNames::aTagString, SVGNames::targetAttrString, String, Target, target) + + // SVGURIReference + ANIMATED_PROPERTY_DECLARATIONS(SVGAElement, SVGURIReferenceIdentifier, XLinkNames::hrefAttrString, String, Href, href) + + // SVGExternalResourcesRequired + ANIMATED_PROPERTY_DECLARATIONS(SVGAElement, SVGExternalResourcesRequiredIdentifier, + SVGNames::externalResourcesRequiredAttrString, bool, + ExternalResourcesRequired, externalResourcesRequired) }; } // namespace WebCore diff --git a/WebCore/svg/SVGAllInOne.cpp b/WebCore/svg/SVGAllInOne.cpp index 2e34ee3..6606243 100644 --- a/WebCore/svg/SVGAllInOne.cpp +++ b/WebCore/svg/SVGAllInOne.cpp @@ -41,7 +41,6 @@ #include "SVGColor.cpp" #include "SVGComponentTransferFunctionElement.cpp" #include "SVGCursorElement.cpp" -#include "SVGDefinitionSrcElement.cpp" #include "SVGDefsElement.cpp" #include "SVGDescElement.cpp" #include "SVGDocument.cpp" @@ -68,6 +67,7 @@ #include "SVGFELightElement.cpp" #include "SVGFEMergeElement.cpp" #include "SVGFEMergeNodeElement.cpp" +#include "SVGFEMorphologyElement.cpp" #include "SVGFEOffsetElement.cpp" #include "SVGFEPointLightElement.cpp" #include "SVGFESpecularLightingElement.cpp" @@ -150,3 +150,4 @@ #include "SVGViewSpec.cpp" #include "SVGZoomAndPan.cpp" #include "SVGZoomEvent.cpp" +#include "SynchronizablePropertyController.cpp" diff --git a/WebCore/svg/SVGAltGlyphElement.cpp b/WebCore/svg/SVGAltGlyphElement.cpp index d9da3f6..f13edf5 100644 --- a/WebCore/svg/SVGAltGlyphElement.cpp +++ b/WebCore/svg/SVGAltGlyphElement.cpp @@ -35,6 +35,7 @@ namespace WebCore { SVGAltGlyphElement::SVGAltGlyphElement(const QualifiedName& tagName, Document* doc) : SVGTextPositioningElement(tagName, doc) + , m_href(this, XLinkNames::hrefAttr) { } diff --git a/WebCore/svg/SVGAltGlyphElement.h b/WebCore/svg/SVGAltGlyphElement.h index 91c99e3..b571880 100644 --- a/WebCore/svg/SVGAltGlyphElement.h +++ b/WebCore/svg/SVGAltGlyphElement.h @@ -47,8 +47,9 @@ namespace WebCore { SVGGlyphElement* glyphElement() const; - protected: - virtual const SVGElement* contextElement() const { return this; } + private: + // SVGURIReference + ANIMATED_PROPERTY_DECLARATIONS(SVGAltGlyphElement, SVGURIReferenceIdentifier, XLinkNames::hrefAttrString, String, Href, href) }; } // namespace WebCore diff --git a/WebCore/svg/SVGAngle.idl b/WebCore/svg/SVGAngle.idl index fc7c1e1..1a05646 100644 --- a/WebCore/svg/SVGAngle.idl +++ b/WebCore/svg/SVGAngle.idl @@ -4,8 +4,6 @@ Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com> Copyright (C) 2006 Apple Computer, Inc. All rights reserved. - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either diff --git a/WebCore/svg/SVGAnimateColorElement.cpp b/WebCore/svg/SVGAnimateColorElement.cpp index 1555f5e..ab48f18 100644 --- a/WebCore/svg/SVGAnimateColorElement.cpp +++ b/WebCore/svg/SVGAnimateColorElement.cpp @@ -3,8 +3,6 @@ 2004, 2005, 2006 Rob Buis <buis@kde.org> Copyright (C) 2007 Eric Seidel <eric@webkit.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either diff --git a/WebCore/svg/SVGAnimateColorElement.h b/WebCore/svg/SVGAnimateColorElement.h index 595f0a9..9071185 100644 --- a/WebCore/svg/SVGAnimateColorElement.h +++ b/WebCore/svg/SVGAnimateColorElement.h @@ -3,8 +3,6 @@ 2004, 2005, 2006 Rob Buis <buis@kde.org> Copyright (C) 2007 Eric Seidel <eric@webkit.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either diff --git a/WebCore/svg/SVGAnimateElement.cpp b/WebCore/svg/SVGAnimateElement.cpp index c2a83c0..31d681b 100644 --- a/WebCore/svg/SVGAnimateElement.cpp +++ b/WebCore/svg/SVGAnimateElement.cpp @@ -3,8 +3,6 @@ 2004, 2005, 2006 Rob Buis <buis@kde.org> Copyright (C) 2008 Apple Inc. All rights reserved. - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either @@ -64,7 +62,7 @@ static bool parseNumberValueAndUnit(const String& in, double& value, String& uni unitLength = 4; String newUnit = parse.right(unitLength); String number = parse.left(parse.length() - unitLength); - if (!unit.isEmpty() && newUnit != unit || number.isEmpty()) + if ((!unit.isEmpty() && newUnit != unit) || number.isEmpty()) return false; UChar last = number[number.length() - 1]; if (last < '0' || last > '9') diff --git a/WebCore/svg/SVGAnimateElement.h b/WebCore/svg/SVGAnimateElement.h index b90e5c8..ac5883c 100644 --- a/WebCore/svg/SVGAnimateElement.h +++ b/WebCore/svg/SVGAnimateElement.h @@ -3,8 +3,6 @@ 2004, 2005 Rob Buis <buis@kde.org> Copyright (C) 2008 Apple Inc. All rights reserved. - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either diff --git a/WebCore/svg/SVGAnimateTransformElement.h b/WebCore/svg/SVGAnimateTransformElement.h index 9b1f192..c9139c4 100644 --- a/WebCore/svg/SVGAnimateTransformElement.h +++ b/WebCore/svg/SVGAnimateTransformElement.h @@ -4,8 +4,6 @@ Copyright (C) 2007 Eric Seidel <eric@webkit.org> Copyright (C) 2008 Apple Inc. All Rights Reserved. - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either diff --git a/WebCore/svg/SVGAnimatedPathData.cpp b/WebCore/svg/SVGAnimatedPathData.cpp index be75809..0f43f2c 100644 --- a/WebCore/svg/SVGAnimatedPathData.cpp +++ b/WebCore/svg/SVGAnimatedPathData.cpp @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005, 2006 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either diff --git a/WebCore/svg/SVGAnimatedPathData.h b/WebCore/svg/SVGAnimatedPathData.h index 88b994b..79bd586 100644 --- a/WebCore/svg/SVGAnimatedPathData.h +++ b/WebCore/svg/SVGAnimatedPathData.h @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005, 2006 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either diff --git a/WebCore/svg/SVGAnimatedPoints.cpp b/WebCore/svg/SVGAnimatedPoints.cpp index 584f875..57101b3 100644 --- a/WebCore/svg/SVGAnimatedPoints.cpp +++ b/WebCore/svg/SVGAnimatedPoints.cpp @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005, 2006 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either diff --git a/WebCore/svg/SVGAnimatedPoints.h b/WebCore/svg/SVGAnimatedPoints.h index 1e61057..9f44e1f 100644 --- a/WebCore/svg/SVGAnimatedPoints.h +++ b/WebCore/svg/SVGAnimatedPoints.h @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005, 2006 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either diff --git a/WebCore/svg/SVGAnimatedProperty.h b/WebCore/svg/SVGAnimatedProperty.h index 6803055..984046f 100644 --- a/WebCore/svg/SVGAnimatedProperty.h +++ b/WebCore/svg/SVGAnimatedProperty.h @@ -1,5 +1,6 @@ /* Copyright (C) 2008 Nikolas Zimmermann <zimmermann@kde.org> + Copyright (C) Research In Motion Limited 2009. 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 @@ -62,14 +63,16 @@ namespace WebCore { struct IsDerivedFromSVGElement; // Helper template used for synchronizing SVG <-> XML properties - template<typename OwnerElement, typename DecoratedType> - void synchronizeProperty(const OwnerElement* ownerElement, const QualifiedName& attributeName, DecoratedType baseValue); + template<typename OwnerType, typename DecoratedType, bool isDerivedFromSVGElement> + struct PropertySynchronizer; // Abstract base class class SVGAnimatedPropertyBase : public Noncopyable { public: virtual ~SVGAnimatedPropertyBase() { } virtual void synchronize() const = 0; + virtual void startAnimation() const = 0; + virtual void stopAnimation() = 0; }; template<typename OwnerTypeArg, typename AnimatedTypeArg, const char* TagName, const char* PropertyName> @@ -124,6 +127,7 @@ namespace WebCore { // Tear offs only used by bindings, never in internal code PassRefPtr<TearOff> animatedTearOff() const; + void registerProperty(); virtual void synchronize() const; void startAnimation() const; @@ -140,6 +144,10 @@ namespace WebCore { const AtomicString& m_attributeIdentifier; mutable SynchronizableTypeWrapper<StorableType> m_value; + +#ifndef NDEBUG + bool m_registered; +#endif }; // SVGAnimatedPropertyTearOff implementation @@ -186,8 +194,12 @@ namespace WebCore { , m_attributeName(attributeName) , m_attributeIdentifier(attributeName.localName()) , m_value() +#ifndef NDEBUG + , m_registered(false) +#endif { ASSERT(m_ownerType); + registerProperty(); } template<typename OwnerTypeArg, typename AnimatedTypeArg, const char* TagName, const char* PropertyName> @@ -198,8 +210,12 @@ namespace WebCore { , m_attributeName(attributeName) , m_attributeIdentifier(attributeIdentifier) , m_value() +#ifndef NDEBUG + , m_registered(false) +#endif { ASSERT(m_ownerType); + registerProperty(); } template<typename OwnerTypeArg, typename AnimatedTypeArg, const char* TagName, const char* PropertyName> @@ -211,8 +227,12 @@ namespace WebCore { , m_attributeName(attributeName) , m_attributeIdentifier(attributeName.localName()) , m_value(arg1) +#ifndef NDEBUG + , m_registered(false) +#endif { ASSERT(m_ownerType); + registerProperty(); } template<typename OwnerTypeArg, typename AnimatedTypeArg, const char* TagName, const char* PropertyName> @@ -225,8 +245,12 @@ namespace WebCore { , m_attributeName(attributeName) , m_attributeIdentifier(attributeIdentifier) , m_value(arg1) +#ifndef NDEBUG + , m_registered(false) +#endif { ASSERT(m_ownerType); + registerProperty(); } template<typename OwnerTypeArg, typename AnimatedTypeArg, const char* TagName, const char* PropertyName> @@ -239,8 +263,12 @@ namespace WebCore { , m_attributeName(attributeName) , m_attributeIdentifier(attributeName.localName()) , m_value(arg1, arg2) +#ifndef NDEBUG + , m_registered(false) +#endif { ASSERT(m_ownerType); + registerProperty(); } template<typename OwnerTypeArg, typename AnimatedTypeArg, const char* TagName, const char* PropertyName> @@ -254,8 +282,12 @@ namespace WebCore { , m_attributeName(attributeName) , m_attributeIdentifier(attributeIdentifier) , m_value(arg1, arg2) +#ifndef NDEBUG + , m_registered(false) +#endif { ASSERT(m_ownerType); + registerProperty(); } template<typename OwnerTypeArg, typename AnimatedTypeArg, const char* TagName, const char* PropertyName> @@ -269,8 +301,12 @@ namespace WebCore { , m_attributeName(attributeName) , m_attributeIdentifier(attributeName.localName()) , m_value(arg1, arg2, arg3) +#ifndef NDEBUG + , m_registered(false) +#endif { ASSERT(m_ownerType); + registerProperty(); } template<typename OwnerTypeArg, typename AnimatedTypeArg, const char* TagName, const char* PropertyName> @@ -285,20 +321,26 @@ namespace WebCore { , m_attributeName(attributeName) , m_attributeIdentifier(attributeIdentifier) , m_value(arg1, arg2, arg3) +#ifndef NDEBUG + , m_registered(false) +#endif { ASSERT(m_ownerType); + registerProperty(); } template<typename OwnerTypeArg, typename AnimatedTypeArg, const char* TagName, const char* PropertyName> typename SVGAnimatedProperty<OwnerTypeArg, AnimatedTypeArg, TagName, PropertyName>::DecoratedType SVGAnimatedProperty<OwnerTypeArg, AnimatedTypeArg, TagName, PropertyName>::value() const { + ASSERT(m_registered); return m_value; } template<typename OwnerTypeArg, typename AnimatedTypeArg, const char* TagName, const char* PropertyName> void SVGAnimatedProperty<OwnerTypeArg, AnimatedTypeArg, TagName, PropertyName>::setValue(typename SVGAnimatedProperty::DecoratedType newValue) { + ASSERT(m_registered); m_value = newValue; ownerElement()->setSynchronizedSVGAttributes(false); } @@ -307,6 +349,7 @@ namespace WebCore { typename SVGAnimatedProperty<OwnerTypeArg, AnimatedTypeArg, TagName, PropertyName>::DecoratedType SVGAnimatedProperty<OwnerTypeArg, AnimatedTypeArg, TagName, PropertyName>::baseValue() const { + ASSERT(m_registered); const OwnerElement* ownerElement = this->ownerElement(); SVGDocumentExtensions* extensions = ownerElement->accessDocumentSVGExtensions(); if (extensions && extensions->hasBaseValue<DecoratedType>(ownerElement, m_attributeIdentifier)) @@ -318,6 +361,7 @@ namespace WebCore { template<typename OwnerTypeArg, typename AnimatedTypeArg, const char* TagName, const char* PropertyName> void SVGAnimatedProperty<OwnerTypeArg, AnimatedTypeArg, TagName, PropertyName>::setBaseValue(typename SVGAnimatedProperty::DecoratedType newValue) { + ASSERT(m_registered); const OwnerElement* ownerElement = this->ownerElement(); SVGDocumentExtensions* extensions = ownerElement->accessDocumentSVGExtensions(); if (extensions && extensions->hasBaseValue<DecoratedType>(ownerElement, m_attributeIdentifier)) { @@ -334,25 +378,38 @@ namespace WebCore { PassRefPtr<typename SVGAnimatedProperty<OwnerTypeArg, AnimatedTypeArg, TagName, PropertyName>::TearOff> SVGAnimatedProperty<OwnerTypeArg, AnimatedTypeArg, TagName, PropertyName>::animatedTearOff() const { + ASSERT(m_registered); return lookupOrCreateWrapper<OwnerTypeArg, AnimatedTypeArg, TagName, PropertyName, TearOff, OwnerElement>(*this, ownerElement(), m_attributeName, m_attributeIdentifier); } template<typename OwnerTypeArg, typename AnimatedTypeArg, const char* TagName, const char* PropertyName> + void SVGAnimatedProperty<OwnerTypeArg, AnimatedTypeArg, TagName, PropertyName>::registerProperty() + { + ASSERT(!m_registered); + ownerElement()->propertyController().registerProperty(m_attributeName, this); + +#ifndef NDEBUG + m_registered = true; +#endif + } + + template<typename OwnerTypeArg, typename AnimatedTypeArg, const char* TagName, const char* PropertyName> void SVGAnimatedProperty<OwnerTypeArg, AnimatedTypeArg, TagName, PropertyName>::synchronize() const { + ASSERT(m_registered); if (!m_value.needsSynchronization()) return; - synchronizeProperty<OwnerElement, DecoratedType>(ownerElement(), m_attributeName, baseValue()); + PropertySynchronizer<OwnerElement, DecoratedType, IsDerivedFromSVGElement<OwnerType>::value>::synchronize(ownerElement(), m_attributeName, baseValue()); m_value.setSynchronized(); } template<typename OwnerTypeArg, typename AnimatedTypeArg, const char* TagName, const char* PropertyName> void SVGAnimatedProperty<OwnerTypeArg, AnimatedTypeArg, TagName, PropertyName>::startAnimation() const { + ASSERT(m_registered); const OwnerElement* ownerElement = this->ownerElement(); - SVGDocumentExtensions* extensions = ownerElement->accessDocumentSVGExtensions(); - if (extensions) { + if (SVGDocumentExtensions* extensions = ownerElement->accessDocumentSVGExtensions()) { ASSERT(!extensions->hasBaseValue<DecoratedType>(ownerElement, m_attributeIdentifier)); extensions->setBaseValue<DecoratedType>(ownerElement, m_attributeIdentifier, m_value); } @@ -361,12 +418,12 @@ namespace WebCore { template<typename OwnerTypeArg, typename AnimatedTypeArg, const char* TagName, const char* PropertyName> void SVGAnimatedProperty<OwnerTypeArg, AnimatedTypeArg, TagName, PropertyName>::stopAnimation() { + ASSERT(m_registered); const OwnerElement* ownerElement = this->ownerElement(); - SVGDocumentExtensions* extensions = ownerElement->accessDocumentSVGExtensions(); - if (extensions) { + if (SVGDocumentExtensions* extensions = ownerElement->accessDocumentSVGExtensions()) { ASSERT(extensions->hasBaseValue<DecoratedType>(ownerElement, m_attributeIdentifier)); setValue(extensions->baseValue<DecoratedType>(ownerElement, m_attributeIdentifier)); - extensions->removeBaseValue<AnimatedType>(ownerElement, m_attributeIdentifier); + extensions->removeBaseValue<DecoratedType>(ownerElement, m_attributeIdentifier); } } @@ -406,39 +463,37 @@ namespace WebCore { static const bool value = true; }; - class SVGExternalResourcesRequired; - template<> - struct IsDerivedFromSVGElement<SVGExternalResourcesRequired> : Noncopyable { - static const bool value = false; - }; - - class SVGFitToViewBox; + class SVGViewSpec; template<> - struct IsDerivedFromSVGElement<SVGFitToViewBox> : Noncopyable { + struct IsDerivedFromSVGElement<SVGViewSpec> : Noncopyable { static const bool value = false; }; - class SVGURIReference; - template<> - struct IsDerivedFromSVGElement<SVGURIReference> : Noncopyable { - static const bool value = false; + // PropertySynchronizer implementation + template<typename OwnerElement, typename DecoratedType> + struct PropertySynchronizer<OwnerElement, DecoratedType, true> : Noncopyable { + static void synchronize(const OwnerElement* ownerElement, const QualifiedName& attributeName, DecoratedType baseValue) + { + AtomicString value(SVGAnimatedTypeValue<DecoratedType>::toString(baseValue)); + + NamedNodeMap* namedAttrMap = ownerElement->attributes(false); + Attribute* old = namedAttrMap->getAttributeItem(attributeName); + if (old && value.isNull()) + namedAttrMap->removeAttribute(old->name()); + else if (!old && !value.isNull()) + namedAttrMap->addAttribute(const_cast<OwnerElement*>(ownerElement)->createAttribute(attributeName, value)); + else if (old && !value.isNull()) + old->setValue(value); + } }; - // Central function handling the main SVG<->XML synchronization part. template<typename OwnerElement, typename DecoratedType> - void synchronizeProperty(const OwnerElement* ownerElement, const QualifiedName& attributeName, DecoratedType baseValue) - { - AtomicString value(SVGAnimatedTypeValue<DecoratedType>::toString(baseValue)); - - NamedNodeMap* namedAttrMap = ownerElement->attributes(false); - Attribute* old = namedAttrMap->getAttributeItem(attributeName); - if (old && value.isNull()) - namedAttrMap->removeAttribute(old->name()); - else if (!old && !value.isNull()) - namedAttrMap->addAttribute(const_cast<OwnerElement*>(ownerElement)->createAttribute(attributeName, value)); - else if (old && !value.isNull()) - old->setValue(value); - } + struct PropertySynchronizer<OwnerElement, DecoratedType, false> : Noncopyable { + static void synchronize(const OwnerElement*, const QualifiedName&, DecoratedType) + { + // no-op, for types not inheriting from Element, thus nothing to synchronize + } + }; // Helper macro used to register animated properties within SVG* classes #define ANIMATED_PROPERTY_DECLARATIONS(OwnerType, ElementTag, AttributeTag, AnimatedType, UpperProperty, LowerProperty) \ @@ -451,8 +506,7 @@ namespace WebCore { void set##UpperProperty(DecoratedTypeFor##UpperProperty type) { m_##LowerProperty.setValue(type); } \ DecoratedTypeFor##UpperProperty LowerProperty##BaseValue() const { return m_##LowerProperty.baseValue(); } \ void set##UpperProperty##BaseValue(DecoratedTypeFor##UpperProperty type) { m_##LowerProperty.setBaseValue(type); } \ - PassRefPtr<SVGAnimatedProperty##UpperProperty::TearOff> LowerProperty##Animated() const { return m_##LowerProperty.animatedTearOff(); } \ - void synchronize##UpperProperty() const { m_##LowerProperty.synchronize(); } + PassRefPtr<SVGAnimatedProperty##UpperProperty::TearOff> LowerProperty##Animated() const { return m_##LowerProperty.animatedTearOff(); } }; diff --git a/WebCore/svg/SVGAnimatedTemplate.h b/WebCore/svg/SVGAnimatedTemplate.h index 3f04c5b..d65fe0b 100644 --- a/WebCore/svg/SVGAnimatedTemplate.h +++ b/WebCore/svg/SVGAnimatedTemplate.h @@ -158,7 +158,7 @@ namespace WebCore { if (!wrapper) { wrapper = Type::create(creator, element, attrName); - element->addSVGPropertySynchronizer(attrName, creator); + element->propertyController().setPropertyNeedsSynchronization(attrName); Type::wrapperCache()->set(key, wrapper.get()); } @@ -172,7 +172,7 @@ namespace WebCore { typedef Type* DecoratedType; static Type null() { return 0; } - static AtomicString toString(Type type) { return type ? AtomicString(type->valueAsString()) : nullAtom; } + static String toString(Type type) { return type ? type->valueAsString() : String(); } }; template<> @@ -181,7 +181,7 @@ namespace WebCore { typedef bool DecoratedType; static bool null() { return false; } - static AtomicString toString(bool type) { return type ? "true" : "false"; } + static String toString(bool type) { return type ? "true" : "false"; } }; template<> @@ -190,7 +190,7 @@ namespace WebCore { typedef int DecoratedType; static int null() { return 0; } - static AtomicString toString(int type) { return String::number(type); } + static String toString(int type) { return String::number(type); } }; template<> @@ -199,7 +199,7 @@ namespace WebCore { typedef long DecoratedType; static long null() { return 0l; } - static AtomicString toString(long type) { return String::number(type); } + static String toString(long type) { return String::number(type); } }; template<> @@ -208,7 +208,7 @@ namespace WebCore { typedef SVGLength DecoratedType; static SVGLength null() { return SVGLength(); } - static AtomicString toString(const SVGLength& type) { return type.valueAsString(); } + static String toString(const SVGLength& type) { return type.valueAsString(); } }; template<> @@ -217,7 +217,7 @@ namespace WebCore { typedef float DecoratedType; static float null() { return 0.0f; } - static AtomicString toString(float type) { return String::number(type); } + static String toString(float type) { return String::number(type); } }; template<> @@ -226,7 +226,7 @@ namespace WebCore { typedef FloatRect DecoratedType; static FloatRect null() { return FloatRect(); } - static AtomicString toString(const FloatRect& type) { return String::format("%f %f %f %f", type.x(), type.y(), type.width(), type.height()); } + static String toString(const FloatRect& type) { return String::format("%f %f %f %f", type.x(), type.y(), type.width(), type.height()); } }; template<> @@ -235,7 +235,7 @@ namespace WebCore { typedef String DecoratedType; static String null() { return String(); } - static AtomicString toString(const String& type) { return type; } + static String toString(const String& type) { return type; } }; // Common type definitions, to ease IDL generation. diff --git a/WebCore/svg/SVGAnimationElement.cpp b/WebCore/svg/SVGAnimationElement.cpp index b817ad8..ce3670d 100644 --- a/WebCore/svg/SVGAnimationElement.cpp +++ b/WebCore/svg/SVGAnimationElement.cpp @@ -3,8 +3,7 @@ 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org> Copyright (C) 2007 Eric Seidel <eric@webkit.org> Copyright (C) 2008 Apple Inc. All rights reserved. - - This file is part of the KDE project + Copyright (C) 2009 Cameron McCormack <cam@mcc.id.au> This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public @@ -51,7 +50,8 @@ namespace WebCore { SVGAnimationElement::SVGAnimationElement(const QualifiedName& tagName, Document* doc) : SVGSMILElement(tagName, doc) , SVGTests() - , SVGExternalResourcesRequired() + , SVGExternalResourcesRequired() + , m_externalResourcesRequired(this, SVGNames::externalResourcesRequiredAttr, false) , m_animationValid(false) { } @@ -156,29 +156,24 @@ float SVGAnimationElement::getSimpleDuration(ExceptionCode&) const return narrowPrecisionToFloat(simpleDuration().value()); } -bool SVGAnimationElement::beginElement(ExceptionCode& ec) +void SVGAnimationElement::beginElement() { - return beginElementAt(0, ec); + beginElementAt(0); } -bool SVGAnimationElement::beginElementAt(float offset, ExceptionCode&) +void SVGAnimationElement::beginElementAt(float offset) { addBeginTime(elapsed() + offset); - return true; } -bool SVGAnimationElement::endElement(ExceptionCode& ec) +void SVGAnimationElement::endElement() { - return endElementAt(0, ec); + endElementAt(0); } -bool SVGAnimationElement::endElementAt(float offset, ExceptionCode&) +void SVGAnimationElement::endElementAt(float offset) { - if (offset < 0) - return false; - addEndTime(elapsed() + offset); - return true; } SVGAnimationElement::AnimationMode SVGAnimationElement::animationMode() const @@ -492,7 +487,7 @@ void SVGAnimationElement::startedActiveInterval() m_animationValid = m_values.size() > 1 && (calcMode == CalcModePaced || !hasAttribute(SVGNames::keyTimesAttr) || hasAttribute(SVGNames::keyPointsAttr) || (m_values.size() == m_keyTimes.size())) && (calcMode == CalcModeDiscrete || !m_keyTimes.size() || m_keyTimes.last() == 1.0) - && (calcMode != CalcModeSpline || (m_keySplines.size() && (m_keySplines.size() == m_values.size() - 1) || m_keySplines.size() == m_keyPoints.size() - 1)) + && (calcMode != CalcModeSpline || ((m_keySplines.size() && (m_keySplines.size() == m_values.size() - 1)) || m_keySplines.size() == m_keyPoints.size() - 1)) && (!hasAttribute(SVGNames::keyPointsAttr) || (m_keyTimes.size() > 1 && m_keyTimes.size() == m_keyPoints.size())); if (calcMode == CalcModePaced && m_animationValid) calculateKeyTimesForCalcModePaced(); diff --git a/WebCore/svg/SVGAnimationElement.h b/WebCore/svg/SVGAnimationElement.h index d43ed57..b0b091b 100644 --- a/WebCore/svg/SVGAnimationElement.h +++ b/WebCore/svg/SVGAnimationElement.h @@ -1,10 +1,9 @@ /* - Copyright (C) 2004, 2005 Nikolas Zimmermann <wildfox@kde.org> + Copyright (C) 2004, 2005 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005, 2006 Rob Buis <buis@kde.org> Copyright (C) 2007 Eric Seidel <eric@webkit.org> Copyright (C) 2008 Apple Inc. All rights reserved. - - This file is part of the KDE project + Copyright (C) 2008 Cameron McCormack <cam@mcc.id.au> This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public @@ -57,16 +56,14 @@ namespace WebCore { float getSimpleDuration(ExceptionCode&) const; // ElementTimeControl - virtual bool beginElement(ExceptionCode&); - virtual bool beginElementAt(float offset, ExceptionCode&); - virtual bool endElement(ExceptionCode&); - virtual bool endElementAt(float offset, ExceptionCode&); + virtual void beginElement(); + virtual void beginElementAt(float offset); + virtual void endElement(); + virtual void endElementAt(float offset); static bool attributeIsCSS(const String& attributeName); protected: - virtual const SVGElement* contextElement() const { return this; } - enum CalcMode { CalcModeDiscrete, CalcModeLinear, CalcModePaced, CalcModeSpline }; CalcMode calcMode() const; @@ -108,6 +105,11 @@ namespace WebCore { float calculatePercentForSpline(float percent, unsigned splineIndex) const; protected: + // SVGExternalResourcesRequired + ANIMATED_PROPERTY_DECLARATIONS(SVGAnimationElement, SVGExternalResourcesRequiredIdentifier, + SVGNames::externalResourcesRequiredAttrString, bool, + ExternalResourcesRequired, externalResourcesRequired) + bool m_animationValid; Vector<String> m_values; diff --git a/WebCore/svg/SVGCircleElement.cpp b/WebCore/svg/SVGCircleElement.cpp index 0c48f51..d96842a 100644 --- a/WebCore/svg/SVGCircleElement.cpp +++ b/WebCore/svg/SVGCircleElement.cpp @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005, 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either @@ -41,6 +39,7 @@ SVGCircleElement::SVGCircleElement(const QualifiedName& tagName, Document* doc) , m_cx(this, SVGNames::cxAttr, LengthModeWidth) , m_cy(this, SVGNames::cyAttr, LengthModeHeight) , m_r(this, SVGNames::rAttr, LengthModeOther) + , m_externalResourcesRequired(this, SVGNames::externalResourcesRequiredAttr, false) { } diff --git a/WebCore/svg/SVGCircleElement.h b/WebCore/svg/SVGCircleElement.h index 598e51f..69b015d 100644 --- a/WebCore/svg/SVGCircleElement.h +++ b/WebCore/svg/SVGCircleElement.h @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005, 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005, 2006 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either @@ -47,13 +45,17 @@ namespace WebCore { virtual Path toPathData() const; protected: - virtual const SVGElement* contextElement() const { return this; } virtual bool hasRelativeValues() const; private: ANIMATED_PROPERTY_DECLARATIONS(SVGCircleElement, SVGNames::circleTagString, SVGNames::cxAttrString, SVGLength, Cx, cx) ANIMATED_PROPERTY_DECLARATIONS(SVGCircleElement, SVGNames::circleTagString, SVGNames::cyAttrString, SVGLength, Cy, cy) ANIMATED_PROPERTY_DECLARATIONS(SVGCircleElement, SVGNames::circleTagString, SVGNames::rAttrString, SVGLength, R, r) + + // SVGExternalResourcesRequired + ANIMATED_PROPERTY_DECLARATIONS(SVGCircleElement, SVGExternalResourcesRequiredIdentifier, + SVGNames::externalResourcesRequiredAttrString, bool, + ExternalResourcesRequired, externalResourcesRequired) }; } // namespace WebCore diff --git a/WebCore/svg/SVGClipPathElement.cpp b/WebCore/svg/SVGClipPathElement.cpp index 691e4d5..d5df29c 100644 --- a/WebCore/svg/SVGClipPathElement.cpp +++ b/WebCore/svg/SVGClipPathElement.cpp @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005, 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005, 2006, 2007, 2008 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either @@ -40,6 +38,7 @@ SVGClipPathElement::SVGClipPathElement(const QualifiedName& tagName, Document* d , SVGLangSpace() , SVGExternalResourcesRequired() , m_clipPathUnits(this, SVGNames::clipPathUnitsAttr, SVGUnitTypes::SVG_UNIT_TYPE_USERSPACEONUSE) + , m_externalResourcesRequired(this, SVGNames::externalResourcesRequiredAttr, false) { } diff --git a/WebCore/svg/SVGClipPathElement.h b/WebCore/svg/SVGClipPathElement.h index 4043554..6079159 100644 --- a/WebCore/svg/SVGClipPathElement.h +++ b/WebCore/svg/SVGClipPathElement.h @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005, 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005, 2006 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either @@ -49,12 +47,14 @@ namespace WebCore { virtual SVGResource* canvasResource(); - protected: - virtual const SVGElement* contextElement() const { return this; } - private: ANIMATED_PROPERTY_DECLARATIONS(SVGClipPathElement, SVGNames::clipPathTagString, SVGNames::clipPathUnitsAttrString, int, ClipPathUnits, clipPathUnits) + // SVGExternalResourcesRequired + ANIMATED_PROPERTY_DECLARATIONS(SVGClipPathElement, SVGExternalResourcesRequiredIdentifier, + SVGNames::externalResourcesRequiredAttrString, bool, + ExternalResourcesRequired, externalResourcesRequired) + RefPtr<SVGResourceClipper> m_clipper; }; diff --git a/WebCore/svg/SVGColor.cpp b/WebCore/svg/SVGColor.cpp index f939ef0..ede0b0a 100644 --- a/WebCore/svg/SVGColor.cpp +++ b/WebCore/svg/SVGColor.cpp @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005 Nikolas Zimmermann <wildfox@kde.org> 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either @@ -62,9 +60,9 @@ unsigned short SVGColor::colorType() const return m_colorType; } -RGBColor* SVGColor::rgbColor() const +PassRefPtr<RGBColor> SVGColor::rgbColor() const { - return RGBColor::create(m_color.rgb()).releaseRef(); + return RGBColor::create(m_color.rgb()); } void SVGColor::setRGBColor(const String& rgbColor, ExceptionCode& ec) diff --git a/WebCore/svg/SVGColor.h b/WebCore/svg/SVGColor.h index 5dfb694..406166b 100644 --- a/WebCore/svg/SVGColor.h +++ b/WebCore/svg/SVGColor.h @@ -57,8 +57,8 @@ namespace WebCore { // 'SVGColor' functions unsigned short colorType() const; - RGBColor* rgbColor() const; - + PassRefPtr<RGBColor> rgbColor() const; + static Color colorFromRGBColorString(const String&); void setRGBColor(const String& rgbColor) { ExceptionCode ignored = 0; setRGBColor(rgbColor, ignored); } diff --git a/WebCore/svg/SVGColor.idl b/WebCore/svg/SVGColor.idl index 320a9b7..43bcb70 100644 --- a/WebCore/svg/SVGColor.idl +++ b/WebCore/svg/SVGColor.idl @@ -3,8 +3,6 @@ 2004, 2005 Rob Buis <buis@kde.org> Copyright (C) 2006 Apple Computer, Inc. All rights reserved. - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either diff --git a/WebCore/svg/SVGComponentTransferFunctionElement.cpp b/WebCore/svg/SVGComponentTransferFunctionElement.cpp index e479fae..bb08ebb 100644 --- a/WebCore/svg/SVGComponentTransferFunctionElement.cpp +++ b/WebCore/svg/SVGComponentTransferFunctionElement.cpp @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005, 2006 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either diff --git a/WebCore/svg/SVGComponentTransferFunctionElement.h b/WebCore/svg/SVGComponentTransferFunctionElement.h index 82d57b4..c955df5 100644 --- a/WebCore/svg/SVGComponentTransferFunctionElement.h +++ b/WebCore/svg/SVGComponentTransferFunctionElement.h @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005, 2006 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either @@ -25,6 +23,7 @@ #if ENABLE(SVG) && ENABLE(FILTERS) #include "SVGElement.h" +#include "SVGNames.h" #include "SVGNumberList.h" #include "FEComponentTransfer.h" diff --git a/WebCore/svg/SVGCursorElement.cpp b/WebCore/svg/SVGCursorElement.cpp index 12e9e5d..f5aa615 100644 --- a/WebCore/svg/SVGCursorElement.cpp +++ b/WebCore/svg/SVGCursorElement.cpp @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005, 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either @@ -40,6 +38,8 @@ SVGCursorElement::SVGCursorElement(const QualifiedName& tagName, Document* doc) , SVGURIReference() , m_x(this, SVGNames::xAttr, LengthModeWidth) , m_y(this, SVGNames::yAttr, LengthModeHeight) + , m_href(this, XLinkNames::hrefAttr) + , m_externalResourcesRequired(this, SVGNames::externalResourcesRequiredAttr, false) { } diff --git a/WebCore/svg/SVGCursorElement.h b/WebCore/svg/SVGCursorElement.h index ddafb76..ee919a4 100644 --- a/WebCore/svg/SVGCursorElement.h +++ b/WebCore/svg/SVGCursorElement.h @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005, 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005, 2006 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either @@ -50,13 +48,18 @@ namespace WebCore { virtual void addSubresourceAttributeURLs(ListHashSet<KURL>&) const; - protected: - virtual const SVGElement* contextElement() const { return this; } - private: ANIMATED_PROPERTY_DECLARATIONS(SVGCursorElement, SVGNames::cursorTagString, SVGNames::xAttrString, SVGLength, X, x) ANIMATED_PROPERTY_DECLARATIONS(SVGCursorElement, SVGNames::cursorTagString, SVGNames::yAttrString, SVGLength, Y, y) + // SVGURIReference + ANIMATED_PROPERTY_DECLARATIONS(SVGCursorElement, SVGURIReferenceIdentifier, XLinkNames::hrefAttrString, String, Href, href) + + // SVGExternalResourcesRequired + ANIMATED_PROPERTY_DECLARATIONS(SVGCursorElement, SVGExternalResourcesRequiredIdentifier, + SVGNames::externalResourcesRequiredAttrString, bool, + ExternalResourcesRequired, externalResourcesRequired) + HashSet<SVGElement*> m_clients; }; diff --git a/WebCore/svg/SVGDefinitionSrcElement.cpp b/WebCore/svg/SVGDefinitionSrcElement.cpp deleted file mode 100644 index 1419ec0..0000000 --- a/WebCore/svg/SVGDefinitionSrcElement.cpp +++ /dev/null @@ -1,45 +0,0 @@ -/* - Copyright (C) 2007 Eric Seidel <eric@webkit.org> - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. - */ - -#include "config.h" - -#if ENABLE(SVG_FONTS) -#include "SVGDefinitionSrcElement.h" - -#include "SVGFontFaceElement.h" -#include "SVGNames.h" - -namespace WebCore { - -SVGDefinitionSrcElement::SVGDefinitionSrcElement(const QualifiedName& tagName, Document* doc) - : SVGElement(tagName, doc) -{ -} - -void SVGDefinitionSrcElement::childrenChanged(bool changedByParser, Node* beforeChange, Node* afterChange, int childCountDelta) -{ - SVGElement::childrenChanged(changedByParser, beforeChange, afterChange, childCountDelta); - if (parentNode() && parentNode()->hasTagName(SVGNames::font_faceTag)) - static_cast<SVGFontFaceElement*>(parentNode())->rebuildFontFace(); -} - -} - -#endif // ENABLE(SVG_FONTS) - diff --git a/WebCore/svg/SVGDefinitionSrcElement.h b/WebCore/svg/SVGDefinitionSrcElement.h deleted file mode 100644 index aaefd05..0000000 --- a/WebCore/svg/SVGDefinitionSrcElement.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - Copyright (C) 2007 Eric Seidel <eric@webkit.org> - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. - */ - -#ifndef SVGDefinitionSrcElement_h -#define SVGDefinitionSrcElement_h - -#if ENABLE(SVG_FONTS) -#include "SVGElement.h" - -namespace WebCore { - class SVGDefinitionSrcElement : public SVGElement { - public: - SVGDefinitionSrcElement(const QualifiedName&, Document*); - - virtual void childrenChanged(bool changedByParser = false, Node* beforeChange = 0, Node* afterChange = 0, int childCountDelta = 0); - }; - -} // namespace WebCore - -#endif // ENABLE(SVG_FONTS) -#endif - -// vim:ts=4:noet diff --git a/WebCore/svg/SVGDefsElement.cpp b/WebCore/svg/SVGDefsElement.cpp index b084bb2..051edeb 100644 --- a/WebCore/svg/SVGDefsElement.cpp +++ b/WebCore/svg/SVGDefsElement.cpp @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005, 2006 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either @@ -34,6 +32,7 @@ SVGDefsElement::SVGDefsElement(const QualifiedName& tagName, Document* doc) , SVGTests() , SVGLangSpace() , SVGExternalResourcesRequired() + , m_externalResourcesRequired(this, SVGNames::externalResourcesRequiredAttr, false) { } diff --git a/WebCore/svg/SVGDefsElement.h b/WebCore/svg/SVGDefsElement.h index c4cac62..4bb206e 100644 --- a/WebCore/svg/SVGDefsElement.h +++ b/WebCore/svg/SVGDefsElement.h @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005, 2006 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either @@ -43,8 +41,11 @@ namespace WebCore { virtual RenderObject* createRenderer(RenderArena*, RenderStyle*); - protected: - virtual const SVGElement* contextElement() const { return this; } + private: + // SVGExternalResourcesRequired + ANIMATED_PROPERTY_DECLARATIONS(SVGDefsElement, SVGExternalResourcesRequiredIdentifier, + SVGNames::externalResourcesRequiredAttrString, bool, + ExternalResourcesRequired, externalResourcesRequired) }; } // namespace WebCore diff --git a/WebCore/svg/SVGDescElement.cpp b/WebCore/svg/SVGDescElement.cpp index 0297ad2..319dfda 100644 --- a/WebCore/svg/SVGDescElement.cpp +++ b/WebCore/svg/SVGDescElement.cpp @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005 Nikolas Zimmermann <wildfox@kde.org> 2004, 2005 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either diff --git a/WebCore/svg/SVGDescElement.h b/WebCore/svg/SVGDescElement.h index c8bc501..846a23e 100644 --- a/WebCore/svg/SVGDescElement.h +++ b/WebCore/svg/SVGDescElement.h @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either diff --git a/WebCore/svg/SVGDocument.h b/WebCore/svg/SVGDocument.h index 02e3649..c7006f9 100644 --- a/WebCore/svg/SVGDocument.h +++ b/WebCore/svg/SVGDocument.h @@ -35,13 +35,11 @@ namespace WebCore { public: static PassRefPtr<SVGDocument> create(Frame* frame) { - return new SVGDocument(frame); + return adoptRef(new SVGDocument(frame)); } virtual ~SVGDocument(); - virtual bool isSVGDocument() const { return true; } - SVGSVGElement* rootElement() const; void dispatchZoomEvent(float prevScale, float newScale); @@ -52,11 +50,13 @@ namespace WebCore { void startPan(const FloatPoint& start); void updatePan(const FloatPoint& pos) const; - virtual bool childShouldCreateRenderer(Node*) const; - private: SVGDocument(Frame*); + virtual bool isSVGDocument() const { return true; } + + virtual bool childShouldCreateRenderer(Node*) const; + FloatPoint m_translate; }; diff --git a/WebCore/svg/SVGDocument.idl b/WebCore/svg/SVGDocument.idl index 61f4e2e..26b70d1 100644 --- a/WebCore/svg/SVGDocument.idl +++ b/WebCore/svg/SVGDocument.idl @@ -3,8 +3,6 @@ 2004, 2005 Rob Buis <buis@kde.org> Copyright (C) 2006 Apple Computer, Inc. All rights reserved. - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either diff --git a/WebCore/svg/SVGDocumentExtensions.cpp b/WebCore/svg/SVGDocumentExtensions.cpp index 61645f4..b2492b4 100644 --- a/WebCore/svg/SVGDocumentExtensions.cpp +++ b/WebCore/svg/SVGDocumentExtensions.cpp @@ -34,6 +34,7 @@ #include "Frame.h" #include "FrameLoader.h" #include "Page.h" +#include "SVGSMILElement.h" #include "SVGSVGElement.h" #include "SMILTimeContainer.h" #include "XMLTokenizer.h" @@ -86,6 +87,17 @@ void SVGDocumentExtensions::unpauseAnimations() (*itr)->unpauseAnimations(); } +bool SVGDocumentExtensions::sampleAnimationAtTime(const String& elementId, SVGSMILElement* element, double time) +{ + ASSERT(element); + SMILTimeContainer* container = element->timeContainer(); + if (!container || container->isPaused()) + return false; + + container->sampleAnimationAtTime(elementId, time); + return true; +} + void SVGDocumentExtensions::reportWarning(const String& message) { if (Frame* frame = m_doc->frame()) diff --git a/WebCore/svg/SVGDocumentExtensions.h b/WebCore/svg/SVGDocumentExtensions.h index cd20a30..b66e2dc 100644 --- a/WebCore/svg/SVGDocumentExtensions.h +++ b/WebCore/svg/SVGDocumentExtensions.h @@ -41,9 +41,10 @@ class Node; class String; class SVGElementInstance; class SVGStyledElement; +class SVGSMILElement; class SVGSVGElement; -class SVGDocumentExtensions { +class SVGDocumentExtensions : public Noncopyable { public: SVGDocumentExtensions(Document*); ~SVGDocumentExtensions(); @@ -54,6 +55,7 @@ public: void startAnimations(); void pauseAnimations(); void unpauseAnimations(); + bool sampleAnimationAtTime(const String& elementId, SVGSMILElement*, double time); void reportWarning(const String&); void reportError(const String&); diff --git a/WebCore/svg/SVGElement.cpp b/WebCore/svg/SVGElement.cpp index 3a7d3d4..27e8c04 100644 --- a/WebCore/svg/SVGElement.cpp +++ b/WebCore/svg/SVGElement.cpp @@ -3,6 +3,7 @@ 2004, 2005, 2006, 2008 Rob Buis <buis@kde.org> Copyright (C) 2008 Apple Inc. All rights reserved. Copyright (C) 2008 Alp Toker <alp@atoker.com> + Copyright (C) 2009 Cameron McCormack <cam@mcc.id.au> This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public @@ -51,14 +52,19 @@ namespace WebCore { using namespace HTMLNames; -SVGElement::SVGElement(const QualifiedName& tagName, Document* doc) - : StyledElement(tagName, doc) +SVGElement::SVGElement(const QualifiedName& tagName, Document* document) + : StyledElement(tagName, document, CreateElementZeroRefCount) , m_shadowParent(0) , m_cursorElement(0) , m_cursorImageValue(0) { } +PassRefPtr<SVGElement> SVGElement::create(const QualifiedName& tagName, Document* document) +{ + return new SVGElement(tagName, document); +} + SVGElement::~SVGElement() { if (m_cursorElement) @@ -72,16 +78,6 @@ bool SVGElement::isSupported(StringImpl* feature, StringImpl* version) const return DOMImplementation::hasFeature(feature, version); } -String SVGElement::id() const -{ - return getAttribute(idAttr); -} - -void SVGElement::setId(const String& value, ExceptionCode&) -{ - setAttribute(idAttr, value); -} - String SVGElement::xmlbase() const { return getAttribute(XMLNames::baseAttr); @@ -185,18 +181,17 @@ bool SVGElement::haveLoadedRequiredResources() return true; } -static bool hasLoadListener(SVGElement* node) +static bool hasLoadListener(Node* node) { - Node* currentNode = node; - while (currentNode && currentNode->isElementNode()) { - const RegisteredEventListenerVector& listeners = static_cast<Element*>(currentNode)->eventListeners(); - size_t size = listeners.size(); - for (size_t i = 0; i < size; ++i) { - const RegisteredEventListener& r = *listeners[i]; - if (r.eventType() == eventNames().loadEvent && r.useCapture() || currentNode == node) + if (node->hasEventListeners(eventNames().loadEvent)) + return true; + + for (node = node->parentNode(); node && node->isElementNode(); node = node->parentNode()) { + const EventListenerVector& entry = node->getEventListeners(eventNames().loadEvent); + for (size_t i = 0; i < entry.size(); ++i) { + if (entry[i].useCapture) return true; } - currentNode = currentNode->parentNode(); } return false; @@ -239,7 +234,7 @@ void SVGElement::insertedIntoDocument() StyledElement::insertedIntoDocument(); SVGDocumentExtensions* extensions = document()->accessSVGExtensions(); - String resourceId = SVGURIReference::getTarget(id()); + String resourceId = SVGURIReference::getTarget(getAttribute(idAttr)); if (extensions->isPendingResource(resourceId)) { std::auto_ptr<HashSet<SVGStyledElement*> > clients(extensions->removePendingResource(resourceId)); if (clients->isEmpty()) @@ -275,10 +270,10 @@ void SVGElement::updateAnimatedSVGAttribute(const String& name) const m_synchronizingSVGAttributes = true; if (name.isEmpty()) { - invokeAllSVGPropertySynchronizers(); + m_propertyController.synchronizeAllProperties(); setSynchronizedSVGAttributes(true); } else - invokeSVGPropertySynchronizer(name); + m_propertyController.synchronizeProperty(name); m_synchronizingSVGAttributes = false; } diff --git a/WebCore/svg/SVGElement.h b/WebCore/svg/SVGElement.h index aed7e59..b247a74 100644 --- a/WebCore/svg/SVGElement.h +++ b/WebCore/svg/SVGElement.h @@ -1,8 +1,7 @@ /* Copyright (C) 2004, 2005, 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005, 2006 Rob Buis <buis@kde.org> - - This file is part of the KDE project + Copyright (C) 2009 Apple Inc. All rights reserved. This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public @@ -26,32 +25,29 @@ #if ENABLE(SVG) #include "StyledElement.h" #include "SVGAnimatedProperty.h" -#include "SVGNames.h" +#include "SynchronizablePropertyController.h" namespace WebCore { - class TransformationMatrix; class CSSCursorImageValue; class Document; class SVGCursorElement; class SVGDocumentExtensions; class SVGElementInstance; class SVGSVGElement; + class TransformationMatrix; class SVGElement : public StyledElement { public: - SVGElement(const QualifiedName&, Document*); + static PassRefPtr<SVGElement> create(const QualifiedName&, Document*); virtual ~SVGElement(); - virtual bool isSVGElement() const { return true; } - virtual bool isSupported(StringImpl* feature, StringImpl* version) const; - - String id() const; - void setId(const String&, ExceptionCode&); + String xmlbase() const; void setXmlbase(const String&, ExceptionCode&); SVGSVGElement* ownerSVGElement() const; SVGElement* viewportElement() const; + SVGDocumentExtensions* accessDocumentSVGExtensions() const; virtual void parseMappedAttribute(MappedAttribute*); @@ -64,74 +60,57 @@ namespace WebCore { virtual bool isGradientStop() const { return false; } virtual bool isTextContent() const { return false; } - virtual bool isShadowNode() const { return m_shadowParent; } - virtual Node* shadowParentNode() { return m_shadowParent; } void setShadowParentNode(ContainerNode* node) { m_shadowParent = node; } - virtual ContainerNode* eventParentNode(); // For SVGTests virtual bool isValid() const { return true; } - - virtual void finishParsingChildren(); + virtual bool rendererIsNeeded(RenderStyle*) { return false; } virtual bool childShouldCreateRenderer(Node*) const; - virtual void insertedIntoDocument(); - virtual void buildPendingResource() { } - virtual void svgAttributeChanged(const QualifiedName&) { } - virtual void attributeChanged(Attribute*, bool preserveDecls = false); void sendSVGLoadEventIfPossible(bool sendParentLoadEvents = false); virtual TransformationMatrix* supplementalTransform() { return 0; } - virtual void updateAnimatedSVGAttribute(const String&) const; virtual void setSynchronizedSVGAttributes(bool) const; HashSet<SVGElementInstance*> instancesForElement() const; - - // Inlined methods handling SVG property synchronization - void invokeSVGPropertySynchronizer(const String& name) const - { - if (m_svgPropertyMap.contains(name)) { - const SVGAnimatedPropertyBase* property = m_svgPropertyMap.get(name); - ASSERT(property); - - property->synchronize(); - } - } - - void invokeAllSVGPropertySynchronizers() const - { - HashMap<String, const SVGAnimatedPropertyBase*>::const_iterator it = m_svgPropertyMap.begin(); - const HashMap<String, const SVGAnimatedPropertyBase*>::const_iterator end = m_svgPropertyMap.end(); - for (; it != end; ++it) { - const SVGAnimatedPropertyBase* property = it->second; - ASSERT(property); - - property->synchronize(); - } - } - - void addSVGPropertySynchronizer(const QualifiedName& attrName, const SVGAnimatedPropertyBase& base) const - { - m_svgPropertyMap.set(attrName.localName(), &base); - } void setCursorElement(SVGCursorElement* cursorElement) { m_cursorElement = cursorElement; } void setCursorImageValue(CSSCursorImageValue* cursorImageValue) { m_cursorImageValue = cursorImageValue; } + SynchronizablePropertyController& propertyController() const { return m_propertyController; } + + protected: + SVGElement(const QualifiedName&, Document*); + + virtual void finishParsingChildren(); + virtual void insertedIntoDocument(); + virtual void attributeChanged(Attribute*, bool preserveDecls = false); + virtual void updateAnimatedSVGAttribute(const String&) const; + private: friend class SVGElementInstance; + virtual bool isSVGElement() const { return true; } + + virtual bool isSupported(StringImpl* feature, StringImpl* version) const; + + virtual bool isShadowNode() const { return m_shadowParent; } + virtual Node* shadowParentNode() { return m_shadowParent; } + virtual ContainerNode* eventParentNode(); + + virtual void buildPendingResource() { } + void mapInstanceToElement(SVGElementInstance*); void removeInstanceMapping(SVGElementInstance*); virtual bool haveLoadedRequiredResources(); ContainerNode* m_shadowParent; - mutable HashMap<String, const SVGAnimatedPropertyBase*> m_svgPropertyMap; + mutable SynchronizablePropertyController m_propertyController; SVGCursorElement* m_cursorElement; CSSCursorImageValue* m_cursorImageValue; diff --git a/WebCore/svg/SVGElement.idl b/WebCore/svg/SVGElement.idl index a1f331f..27fcb8d 100644 --- a/WebCore/svg/SVGElement.idl +++ b/WebCore/svg/SVGElement.idl @@ -4,8 +4,6 @@ Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com> Copyright (C) 2006 Apple Computer, Inc. All rights reserved. - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either @@ -25,7 +23,7 @@ module svg { interface [GenerateNativeConverter, Conditional=SVG] SVGElement : Element { - attribute [ConvertNullToNullString] DOMString id + attribute [ConvertNullToNullString, Reflect] DOMString id setter raises(DOMException); attribute [ConvertNullToNullString] DOMString xmlbase setter raises(DOMException); diff --git a/WebCore/svg/SVGElementInstance.cpp b/WebCore/svg/SVGElementInstance.cpp index 01555fc..46e8221 100644 --- a/WebCore/svg/SVGElementInstance.cpp +++ b/WebCore/svg/SVGElementInstance.cpp @@ -1,8 +1,6 @@ /* Copyright (C) 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either @@ -25,7 +23,6 @@ #include "SVGElementInstance.h" #include "ContainerNodeAlgorithms.h" -#include "Document.h" #include "Event.h" #include "EventException.h" #include "EventListener.h" @@ -46,7 +43,14 @@ namespace WebCore { static WTF::RefCountedLeakCounter instanceCounter("WebCoreSVGElementInstance"); #endif -SVGElementInstance::SVGElementInstance(SVGUseElement* useElement, SVGElement* originalElement) +static EventTargetData& dummyEventTargetData() +{ + DEFINE_STATIC_LOCAL(EventTargetData, dummyEventTargetData, ()); + dummyEventTargetData.eventListenerMap.clear(); + return dummyEventTargetData; +} + +SVGElementInstance::SVGElementInstance(SVGUseElement* useElement, PassRefPtr<SVGElement> originalElement) : m_needsUpdate(false) , m_useElement(useElement) , m_element(originalElement) @@ -140,438 +144,52 @@ ScriptExecutionContext* SVGElementInstance::scriptExecutionContext() const return 0; } -void SVGElementInstance::addEventListener(const AtomicString& eventType, PassRefPtr<EventListener> listener, bool useCapture) -{ - if (SVGElement* element = correspondingElement()) - element->addEventListener(eventType, listener, useCapture); -} - -void SVGElementInstance::removeEventListener(const AtomicString& eventType, EventListener* listener, bool useCapture) +bool SVGElementInstance::addEventListener(const AtomicString& eventType, PassRefPtr<EventListener> listener, bool useCapture) { - if (SVGElement* element = correspondingElement()) - element->removeEventListener(eventType, listener, useCapture); -} - -bool SVGElementInstance::dispatchEvent(PassRefPtr<Event> e, ExceptionCode& ec) -{ - RefPtr<Event> evt(e); - ASSERT(!eventDispatchForbidden()); - if (!evt || evt->type().isEmpty()) { - ec = EventException::UNSPECIFIED_EVENT_TYPE_ERR; - return false; - } - - // The event has to be dispatched to the shadowTreeElement(), not the correspondingElement()! - SVGElement* element = shadowTreeElement(); - if (!element) + if (!correspondingElement()) return false; - - evt->setTarget(this); - - RefPtr<FrameView> view = element->document()->view(); - return element->dispatchGenericEvent(evt.release()); -} - -EventListener* SVGElementInstance::onabort() const -{ - return correspondingElement()->getAttributeEventListener(eventNames().abortEvent); -} - -void SVGElementInstance::setOnabort(PassRefPtr<EventListener> eventListener) -{ - correspondingElement()->setAttributeEventListener(eventNames().abortEvent, eventListener); -} - -EventListener* SVGElementInstance::onblur() const -{ - return correspondingElement()->getAttributeEventListener(eventNames().blurEvent); -} - -void SVGElementInstance::setOnblur(PassRefPtr<EventListener> eventListener) -{ - correspondingElement()->setAttributeEventListener(eventNames().blurEvent, eventListener); -} - -EventListener* SVGElementInstance::onchange() const -{ - return correspondingElement()->getAttributeEventListener(eventNames().changeEvent); -} - -void SVGElementInstance::setOnchange(PassRefPtr<EventListener> eventListener) -{ - correspondingElement()->setAttributeEventListener(eventNames().changeEvent, eventListener); -} - -EventListener* SVGElementInstance::onclick() const -{ - return correspondingElement()->getAttributeEventListener(eventNames().clickEvent); -} - -void SVGElementInstance::setOnclick(PassRefPtr<EventListener> eventListener) -{ - correspondingElement()->setAttributeEventListener(eventNames().clickEvent, eventListener); -} - -EventListener* SVGElementInstance::oncontextmenu() const -{ - return correspondingElement()->getAttributeEventListener(eventNames().contextmenuEvent); -} - -void SVGElementInstance::setOncontextmenu(PassRefPtr<EventListener> eventListener) -{ - correspondingElement()->setAttributeEventListener(eventNames().contextmenuEvent, eventListener); -} - -EventListener* SVGElementInstance::ondblclick() const -{ - return correspondingElement()->getAttributeEventListener(eventNames().dblclickEvent); -} - -void SVGElementInstance::setOndblclick(PassRefPtr<EventListener> eventListener) -{ - correspondingElement()->setAttributeEventListener(eventNames().dblclickEvent, eventListener); -} - -EventListener* SVGElementInstance::onerror() const -{ - return correspondingElement()->getAttributeEventListener(eventNames().errorEvent); -} - -void SVGElementInstance::setOnerror(PassRefPtr<EventListener> eventListener) -{ - correspondingElement()->setAttributeEventListener(eventNames().errorEvent, eventListener); -} - -EventListener* SVGElementInstance::onfocus() const -{ - return correspondingElement()->getAttributeEventListener(eventNames().focusEvent); -} - -void SVGElementInstance::setOnfocus(PassRefPtr<EventListener> eventListener) -{ - correspondingElement()->setAttributeEventListener(eventNames().focusEvent, eventListener); -} - -EventListener* SVGElementInstance::oninput() const -{ - return correspondingElement()->getAttributeEventListener(eventNames().inputEvent); -} - -void SVGElementInstance::setOninput(PassRefPtr<EventListener> eventListener) -{ - correspondingElement()->setAttributeEventListener(eventNames().inputEvent, eventListener); -} - -EventListener* SVGElementInstance::onkeydown() const -{ - return correspondingElement()->getAttributeEventListener(eventNames().keydownEvent); -} - -void SVGElementInstance::setOnkeydown(PassRefPtr<EventListener> eventListener) -{ - correspondingElement()->setAttributeEventListener(eventNames().keydownEvent, eventListener); -} - -EventListener* SVGElementInstance::onkeypress() const -{ - return correspondingElement()->getAttributeEventListener(eventNames().keypressEvent); -} - -void SVGElementInstance::setOnkeypress(PassRefPtr<EventListener> eventListener) -{ - correspondingElement()->setAttributeEventListener(eventNames().keypressEvent, eventListener); -} - -EventListener* SVGElementInstance::onkeyup() const -{ - return correspondingElement()->getAttributeEventListener(eventNames().keyupEvent); -} - -void SVGElementInstance::setOnkeyup(PassRefPtr<EventListener> eventListener) -{ - correspondingElement()->setAttributeEventListener(eventNames().keyupEvent, eventListener); -} - -EventListener* SVGElementInstance::onload() const -{ - return correspondingElement()->getAttributeEventListener(eventNames().loadEvent); -} - -void SVGElementInstance::setOnload(PassRefPtr<EventListener> eventListener) -{ - correspondingElement()->setAttributeEventListener(eventNames().loadEvent, eventListener); -} - -EventListener* SVGElementInstance::onmousedown() const -{ - return correspondingElement()->getAttributeEventListener(eventNames().mousedownEvent); -} - -void SVGElementInstance::setOnmousedown(PassRefPtr<EventListener> eventListener) -{ - correspondingElement()->setAttributeEventListener(eventNames().mousedownEvent, eventListener); -} - -EventListener* SVGElementInstance::onmousemove() const -{ - return correspondingElement()->getAttributeEventListener(eventNames().mousemoveEvent); -} - -void SVGElementInstance::setOnmousemove(PassRefPtr<EventListener> eventListener) -{ - correspondingElement()->setAttributeEventListener(eventNames().mousemoveEvent, eventListener); -} - -EventListener* SVGElementInstance::onmouseout() const -{ - return correspondingElement()->getAttributeEventListener(eventNames().mouseoutEvent); -} - -void SVGElementInstance::setOnmouseout(PassRefPtr<EventListener> eventListener) -{ - correspondingElement()->setAttributeEventListener(eventNames().mouseoutEvent, eventListener); -} - -EventListener* SVGElementInstance::onmouseover() const -{ - return correspondingElement()->getAttributeEventListener(eventNames().mouseoverEvent); -} - -void SVGElementInstance::setOnmouseover(PassRefPtr<EventListener> eventListener) -{ - correspondingElement()->setAttributeEventListener(eventNames().mouseoverEvent, eventListener); -} - -EventListener* SVGElementInstance::onmouseup() const -{ - return correspondingElement()->getAttributeEventListener(eventNames().mouseupEvent); + return correspondingElement()->addEventListener(eventType, listener, useCapture); } -void SVGElementInstance::setOnmouseup(PassRefPtr<EventListener> eventListener) +bool SVGElementInstance::removeEventListener(const AtomicString& eventType, EventListener* listener, bool useCapture) { - correspondingElement()->setAttributeEventListener(eventNames().mouseupEvent, eventListener); -} - -EventListener* SVGElementInstance::onmousewheel() const -{ - return correspondingElement()->getAttributeEventListener(eventNames().mousewheelEvent); -} - -void SVGElementInstance::setOnmousewheel(PassRefPtr<EventListener> eventListener) -{ - correspondingElement()->setAttributeEventListener(eventNames().mousewheelEvent, eventListener); -} - -EventListener* SVGElementInstance::onbeforecut() const -{ - return correspondingElement()->getAttributeEventListener(eventNames().beforecutEvent); -} - -void SVGElementInstance::setOnbeforecut(PassRefPtr<EventListener> eventListener) -{ - correspondingElement()->setAttributeEventListener(eventNames().beforecutEvent, eventListener); -} - -EventListener* SVGElementInstance::oncut() const -{ - return correspondingElement()->getAttributeEventListener(eventNames().cutEvent); -} - -void SVGElementInstance::setOncut(PassRefPtr<EventListener> eventListener) -{ - correspondingElement()->setAttributeEventListener(eventNames().cutEvent, eventListener); -} - -EventListener* SVGElementInstance::onbeforecopy() const -{ - return correspondingElement()->getAttributeEventListener(eventNames().beforecopyEvent); -} - -void SVGElementInstance::setOnbeforecopy(PassRefPtr<EventListener> eventListener) -{ - correspondingElement()->setAttributeEventListener(eventNames().beforecopyEvent, eventListener); -} - -EventListener* SVGElementInstance::oncopy() const -{ - return correspondingElement()->getAttributeEventListener(eventNames().copyEvent); -} - -void SVGElementInstance::setOncopy(PassRefPtr<EventListener> eventListener) -{ - correspondingElement()->setAttributeEventListener(eventNames().copyEvent, eventListener); -} - -EventListener* SVGElementInstance::onbeforepaste() const -{ - return correspondingElement()->getAttributeEventListener(eventNames().beforepasteEvent); -} - -void SVGElementInstance::setOnbeforepaste(PassRefPtr<EventListener> eventListener) -{ - correspondingElement()->setAttributeEventListener(eventNames().beforepasteEvent, eventListener); -} - -EventListener* SVGElementInstance::onpaste() const -{ - return correspondingElement()->getAttributeEventListener(eventNames().pasteEvent); -} - -void SVGElementInstance::setOnpaste(PassRefPtr<EventListener> eventListener) -{ - correspondingElement()->setAttributeEventListener(eventNames().pasteEvent, eventListener); -} - -EventListener* SVGElementInstance::ondragenter() const -{ - return correspondingElement()->getAttributeEventListener(eventNames().dragenterEvent); -} - -void SVGElementInstance::setOndragenter(PassRefPtr<EventListener> eventListener) -{ - correspondingElement()->setAttributeEventListener(eventNames().dragenterEvent, eventListener); -} - -EventListener* SVGElementInstance::ondragover() const -{ - return correspondingElement()->getAttributeEventListener(eventNames().dragoverEvent); -} - -void SVGElementInstance::setOndragover(PassRefPtr<EventListener> eventListener) -{ - correspondingElement()->setAttributeEventListener(eventNames().dragoverEvent, eventListener); -} - -EventListener* SVGElementInstance::ondragleave() const -{ - return correspondingElement()->getAttributeEventListener(eventNames().dragleaveEvent); -} - -void SVGElementInstance::setOndragleave(PassRefPtr<EventListener> eventListener) -{ - correspondingElement()->setAttributeEventListener(eventNames().dragleaveEvent, eventListener); -} - -EventListener* SVGElementInstance::ondrop() const -{ - return correspondingElement()->getAttributeEventListener(eventNames().dropEvent); -} - -void SVGElementInstance::setOndrop(PassRefPtr<EventListener> eventListener) -{ - correspondingElement()->setAttributeEventListener(eventNames().dropEvent, eventListener); -} - -EventListener* SVGElementInstance::ondragstart() const -{ - return correspondingElement()->getAttributeEventListener(eventNames().dragstartEvent); -} - -void SVGElementInstance::setOndragstart(PassRefPtr<EventListener> eventListener) -{ - correspondingElement()->setAttributeEventListener(eventNames().dragstartEvent, eventListener); -} - -EventListener* SVGElementInstance::ondrag() const -{ - return correspondingElement()->getAttributeEventListener(eventNames().dragEvent); -} - -void SVGElementInstance::setOndrag(PassRefPtr<EventListener> eventListener) -{ - correspondingElement()->setAttributeEventListener(eventNames().dragEvent, eventListener); -} - -EventListener* SVGElementInstance::ondragend() const -{ - return correspondingElement()->getAttributeEventListener(eventNames().dragendEvent); -} - -void SVGElementInstance::setOndragend(PassRefPtr<EventListener> eventListener) -{ - correspondingElement()->setAttributeEventListener(eventNames().dragendEvent, eventListener); -} - -EventListener* SVGElementInstance::onreset() const -{ - return correspondingElement()->getAttributeEventListener(eventNames().resetEvent); -} - -void SVGElementInstance::setOnreset(PassRefPtr<EventListener> eventListener) -{ - correspondingElement()->setAttributeEventListener(eventNames().resetEvent, eventListener); -} - -EventListener* SVGElementInstance::onresize() const -{ - return correspondingElement()->getAttributeEventListener(eventNames().resizeEvent); -} - -void SVGElementInstance::setOnresize(PassRefPtr<EventListener> eventListener) -{ - correspondingElement()->setAttributeEventListener(eventNames().resizeEvent, eventListener); -} - -EventListener* SVGElementInstance::onscroll() const -{ - return correspondingElement()->getAttributeEventListener(eventNames().scrollEvent); -} - -void SVGElementInstance::setOnscroll(PassRefPtr<EventListener> eventListener) -{ - correspondingElement()->setAttributeEventListener(eventNames().scrollEvent, eventListener); -} - -EventListener* SVGElementInstance::onsearch() const -{ - return correspondingElement()->getAttributeEventListener(eventNames().searchEvent); -} - -void SVGElementInstance::setOnsearch(PassRefPtr<EventListener> eventListener) -{ - correspondingElement()->setAttributeEventListener(eventNames().searchEvent, eventListener); -} - -EventListener* SVGElementInstance::onselect() const -{ - return correspondingElement()->getAttributeEventListener(eventNames().selectEvent); + if (!correspondingElement()) + return false; + return correspondingElement()->removeEventListener(eventType, listener, useCapture); } -void SVGElementInstance::setOnselect(PassRefPtr<EventListener> eventListener) +void SVGElementInstance::removeAllEventListeners() { - correspondingElement()->setAttributeEventListener(eventNames().selectEvent, eventListener); + if (!correspondingElement()) + return; + correspondingElement()->removeAllEventListeners(); } -EventListener* SVGElementInstance::onselectstart() const +bool SVGElementInstance::dispatchEvent(PassRefPtr<Event> prpEvent) { - return correspondingElement()->getAttributeEventListener(eventNames().selectstartEvent); -} + RefPtr<EventTarget> protect = this; + RefPtr<Event> event = prpEvent; -void SVGElementInstance::setOnselectstart(PassRefPtr<EventListener> eventListener) -{ - correspondingElement()->setAttributeEventListener(eventNames().selectstartEvent, eventListener); -} + event->setTarget(this); -EventListener* SVGElementInstance::onsubmit() const -{ - return correspondingElement()->getAttributeEventListener(eventNames().submitEvent); -} + SVGElement* element = shadowTreeElement(); + if (!element) + return false; -void SVGElementInstance::setOnsubmit(PassRefPtr<EventListener> eventListener) -{ - correspondingElement()->setAttributeEventListener(eventNames().submitEvent, eventListener); + RefPtr<FrameView> view = element->document()->view(); + return element->dispatchGenericEvent(event.release()); } -EventListener* SVGElementInstance::onunload() const +EventTargetData* SVGElementInstance::eventTargetData() { - return correspondingElement()->getAttributeEventListener(eventNames().unloadEvent); + return correspondingElement() ? correspondingElement()->eventTargetData() : 0; } -void SVGElementInstance::setOnunload(PassRefPtr<EventListener> eventListener) +EventTargetData* SVGElementInstance::ensureEventTargetData() { - correspondingElement()->setAttributeEventListener(eventNames().unloadEvent, eventListener); + return &dummyEventTargetData(); // return something, so we don't crash } -} +} // namespace WebCore #endif // ENABLE(SVG) diff --git a/WebCore/svg/SVGElementInstance.h b/WebCore/svg/SVGElementInstance.h index c477718..3cdc761 100644 --- a/WebCore/svg/SVGElementInstance.h +++ b/WebCore/svg/SVGElementInstance.h @@ -1,8 +1,6 @@ /* Copyright (C) 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either @@ -27,9 +25,6 @@ #include "SVGElement.h" #include "TreeShared.h" -#include <wtf/RefPtr.h> -#include <wtf/PassRefPtr.h> - namespace WebCore { namespace Private { @@ -37,8 +32,6 @@ namespace WebCore { void addChildNodesToDeletionQueue(GenericNode*& head, GenericNode*& tail, GenericNodeContainer* container); }; - class EventListener; - class Frame; class SVGUseElement; class SVGElementInstanceList; @@ -46,7 +39,11 @@ namespace WebCore { class SVGElementInstance : public TreeShared<SVGElementInstance>, public EventTarget { public: - SVGElementInstance(SVGUseElement*, SVGElement* originalElement); + static PassRefPtr<SVGElementInstance> create(SVGUseElement* useElement, PassRefPtr<SVGElement> originalElement) + { + return adoptRef(new SVGElementInstance(useElement, originalElement)); + } + virtual ~SVGElementInstance(); bool needsUpdate() const { return m_needsUpdate; } @@ -54,13 +51,11 @@ namespace WebCore { virtual ScriptExecutionContext* scriptExecutionContext() const; - virtual Node* toNode() { return shadowTreeElement(); } - virtual SVGElementInstance* toSVGElementInstance() { return this; } - - virtual void addEventListener(const AtomicString& eventType, PassRefPtr<EventListener>, bool useCapture); - virtual void removeEventListener(const AtomicString& eventType, EventListener*, bool useCapture); - virtual bool dispatchEvent(PassRefPtr<Event>, ExceptionCode&); - const RegisteredEventListenerVector& eventListeners() const { return correspondingElement()->eventListeners(); } + virtual bool addEventListener(const AtomicString& eventType, PassRefPtr<EventListener>, bool useCapture); + virtual bool removeEventListener(const AtomicString& eventType, EventListener*, bool useCapture); + virtual void removeAllEventListeners(); + using EventTarget::dispatchEvent; + virtual bool dispatchEvent(PassRefPtr<Event>); SVGElement* correspondingElement() const { return m_element.get(); } SVGUseElement* correspondingUseElement() const { return m_useElement; } @@ -83,90 +78,55 @@ namespace WebCore { using TreeShared<SVGElementInstance>::deref; // EventTarget API - EventListener* onabort() const; - void setOnabort(PassRefPtr<EventListener>); - EventListener* onblur() const; - void setOnblur(PassRefPtr<EventListener>); - EventListener* onchange() const; - void setOnchange(PassRefPtr<EventListener>); - EventListener* onclick() const; - void setOnclick(PassRefPtr<EventListener>); - EventListener* oncontextmenu() const; - void setOncontextmenu(PassRefPtr<EventListener>); - EventListener* ondblclick() const; - void setOndblclick(PassRefPtr<EventListener>); - EventListener* onerror() const; - void setOnerror(PassRefPtr<EventListener>); - EventListener* onfocus() const; - void setOnfocus(PassRefPtr<EventListener>); - EventListener* oninput() const; - void setOninput(PassRefPtr<EventListener>); - EventListener* onkeydown() const; - void setOnkeydown(PassRefPtr<EventListener>); - EventListener* onkeypress() const; - void setOnkeypress(PassRefPtr<EventListener>); - EventListener* onkeyup() const; - void setOnkeyup(PassRefPtr<EventListener>); - EventListener* onload() const; - void setOnload(PassRefPtr<EventListener>); - EventListener* onmousedown() const; - void setOnmousedown(PassRefPtr<EventListener>); - EventListener* onmousemove() const; - void setOnmousemove(PassRefPtr<EventListener>); - EventListener* onmouseout() const; - void setOnmouseout(PassRefPtr<EventListener>); - EventListener* onmouseover() const; - void setOnmouseover(PassRefPtr<EventListener>); - EventListener* onmouseup() const; - void setOnmouseup(PassRefPtr<EventListener>); - EventListener* onmousewheel() const; - void setOnmousewheel(PassRefPtr<EventListener>); - EventListener* onbeforecut() const; - void setOnbeforecut(PassRefPtr<EventListener>); - EventListener* oncut() const; - void setOncut(PassRefPtr<EventListener>); - EventListener* onbeforecopy() const; - void setOnbeforecopy(PassRefPtr<EventListener>); - EventListener* oncopy() const; - void setOncopy(PassRefPtr<EventListener>); - EventListener* onbeforepaste() const; - void setOnbeforepaste(PassRefPtr<EventListener>); - EventListener* onpaste() const; - void setOnpaste(PassRefPtr<EventListener>); - EventListener* ondragenter() const; - void setOndragenter(PassRefPtr<EventListener>); - EventListener* ondragover() const; - void setOndragover(PassRefPtr<EventListener>); - EventListener* ondragleave() const; - void setOndragleave(PassRefPtr<EventListener>); - EventListener* ondrop() const; - void setOndrop(PassRefPtr<EventListener>); - EventListener* ondragstart() const; - void setOndragstart(PassRefPtr<EventListener>); - EventListener* ondrag() const; - void setOndrag(PassRefPtr<EventListener>); - EventListener* ondragend() const; - void setOndragend(PassRefPtr<EventListener>); - EventListener* onreset() const; - void setOnreset(PassRefPtr<EventListener>); - EventListener* onresize() const; - void setOnresize(PassRefPtr<EventListener>); - EventListener* onscroll() const; - void setOnscroll(PassRefPtr<EventListener>); - EventListener* onsearch() const; - void setOnsearch(PassRefPtr<EventListener>); - EventListener* onselect() const; - void setOnselect(PassRefPtr<EventListener>); - EventListener* onselectstart() const; - void setOnselectstart(PassRefPtr<EventListener>); - EventListener* onsubmit() const; - void setOnsubmit(PassRefPtr<EventListener>); - EventListener* onunload() const; - void setOnunload(PassRefPtr<EventListener>); + DEFINE_FORWARDING_ATTRIBUTE_EVENT_LISTENER(correspondingElement(), abort); + DEFINE_FORWARDING_ATTRIBUTE_EVENT_LISTENER(correspondingElement(), blur); + DEFINE_FORWARDING_ATTRIBUTE_EVENT_LISTENER(correspondingElement(), change); + DEFINE_FORWARDING_ATTRIBUTE_EVENT_LISTENER(correspondingElement(), click); + DEFINE_FORWARDING_ATTRIBUTE_EVENT_LISTENER(correspondingElement(), contextmenu); + DEFINE_FORWARDING_ATTRIBUTE_EVENT_LISTENER(correspondingElement(), dblclick); + DEFINE_FORWARDING_ATTRIBUTE_EVENT_LISTENER(correspondingElement(), error); + DEFINE_FORWARDING_ATTRIBUTE_EVENT_LISTENER(correspondingElement(), focus); + DEFINE_FORWARDING_ATTRIBUTE_EVENT_LISTENER(correspondingElement(), input); + DEFINE_FORWARDING_ATTRIBUTE_EVENT_LISTENER(correspondingElement(), keydown); + DEFINE_FORWARDING_ATTRIBUTE_EVENT_LISTENER(correspondingElement(), keypress); + DEFINE_FORWARDING_ATTRIBUTE_EVENT_LISTENER(correspondingElement(), keyup); + DEFINE_FORWARDING_ATTRIBUTE_EVENT_LISTENER(correspondingElement(), load); + DEFINE_FORWARDING_ATTRIBUTE_EVENT_LISTENER(correspondingElement(), mousedown); + DEFINE_FORWARDING_ATTRIBUTE_EVENT_LISTENER(correspondingElement(), mousemove); + DEFINE_FORWARDING_ATTRIBUTE_EVENT_LISTENER(correspondingElement(), mouseout); + DEFINE_FORWARDING_ATTRIBUTE_EVENT_LISTENER(correspondingElement(), mouseover); + DEFINE_FORWARDING_ATTRIBUTE_EVENT_LISTENER(correspondingElement(), mouseup); + DEFINE_FORWARDING_ATTRIBUTE_EVENT_LISTENER(correspondingElement(), mousewheel); + DEFINE_FORWARDING_ATTRIBUTE_EVENT_LISTENER(correspondingElement(), beforecut); + DEFINE_FORWARDING_ATTRIBUTE_EVENT_LISTENER(correspondingElement(), cut); + DEFINE_FORWARDING_ATTRIBUTE_EVENT_LISTENER(correspondingElement(), beforecopy); + DEFINE_FORWARDING_ATTRIBUTE_EVENT_LISTENER(correspondingElement(), copy); + DEFINE_FORWARDING_ATTRIBUTE_EVENT_LISTENER(correspondingElement(), beforepaste); + DEFINE_FORWARDING_ATTRIBUTE_EVENT_LISTENER(correspondingElement(), paste); + DEFINE_FORWARDING_ATTRIBUTE_EVENT_LISTENER(correspondingElement(), dragenter); + DEFINE_FORWARDING_ATTRIBUTE_EVENT_LISTENER(correspondingElement(), dragover); + DEFINE_FORWARDING_ATTRIBUTE_EVENT_LISTENER(correspondingElement(), dragleave); + DEFINE_FORWARDING_ATTRIBUTE_EVENT_LISTENER(correspondingElement(), drop); + DEFINE_FORWARDING_ATTRIBUTE_EVENT_LISTENER(correspondingElement(), dragstart); + DEFINE_FORWARDING_ATTRIBUTE_EVENT_LISTENER(correspondingElement(), drag); + DEFINE_FORWARDING_ATTRIBUTE_EVENT_LISTENER(correspondingElement(), dragend); + DEFINE_FORWARDING_ATTRIBUTE_EVENT_LISTENER(correspondingElement(), reset); + DEFINE_FORWARDING_ATTRIBUTE_EVENT_LISTENER(correspondingElement(), resize); + DEFINE_FORWARDING_ATTRIBUTE_EVENT_LISTENER(correspondingElement(), scroll); + DEFINE_FORWARDING_ATTRIBUTE_EVENT_LISTENER(correspondingElement(), search); + DEFINE_FORWARDING_ATTRIBUTE_EVENT_LISTENER(correspondingElement(), select); + DEFINE_FORWARDING_ATTRIBUTE_EVENT_LISTENER(correspondingElement(), selectstart); + DEFINE_FORWARDING_ATTRIBUTE_EVENT_LISTENER(correspondingElement(), submit); + DEFINE_FORWARDING_ATTRIBUTE_EVENT_LISTENER(correspondingElement(), unload); private: friend class SVGUseElement; + SVGElementInstance(SVGUseElement*, PassRefPtr<SVGElement> originalElement); + + virtual Node* toNode() { return shadowTreeElement(); } + virtual SVGElementInstance* toSVGElementInstance() { return this; } + void appendChild(PassRefPtr<SVGElementInstance> child); void setShadowTreeElement(SVGElement*); void forgetWrapper(); @@ -190,8 +150,9 @@ namespace WebCore { virtual void refEventTarget() { ref(); } virtual void derefEventTarget() { deref(); } + virtual EventTargetData* eventTargetData(); + virtual EventTargetData* ensureEventTargetData(); - private: bool m_needsUpdate : 1; SVGUseElement* m_useElement; diff --git a/WebCore/svg/SVGElementInstanceList.cpp b/WebCore/svg/SVGElementInstanceList.cpp index f039d44..9404734 100644 --- a/WebCore/svg/SVGElementInstanceList.cpp +++ b/WebCore/svg/SVGElementInstanceList.cpp @@ -1,8 +1,6 @@ /* Copyright (C) 2007 Nikolas Zimmermann <zimmermann@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either diff --git a/WebCore/svg/SVGElementInstanceList.h b/WebCore/svg/SVGElementInstanceList.h index ef4c73c..9da4cdc 100644 --- a/WebCore/svg/SVGElementInstanceList.h +++ b/WebCore/svg/SVGElementInstanceList.h @@ -1,8 +1,6 @@ /* Copyright (C) 2007 Nikolas Zimmermann <zimmermann@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either diff --git a/WebCore/svg/SVGEllipseElement.cpp b/WebCore/svg/SVGEllipseElement.cpp index 6d56ff8..3946fb9 100644 --- a/WebCore/svg/SVGEllipseElement.cpp +++ b/WebCore/svg/SVGEllipseElement.cpp @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005, 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either @@ -42,6 +40,7 @@ SVGEllipseElement::SVGEllipseElement(const QualifiedName& tagName, Document* doc , m_cy(this, SVGNames::cyAttr, LengthModeHeight) , m_rx(this, SVGNames::rxAttr, LengthModeWidth) , m_ry(this, SVGNames::ryAttr, LengthModeHeight) + , m_externalResourcesRequired(this, SVGNames::externalResourcesRequiredAttr, false) { } diff --git a/WebCore/svg/SVGEllipseElement.h b/WebCore/svg/SVGEllipseElement.h index 8c7d3a1..5b54fd5 100644 --- a/WebCore/svg/SVGEllipseElement.h +++ b/WebCore/svg/SVGEllipseElement.h @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005, 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005, 2006 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either @@ -47,7 +45,6 @@ namespace WebCore { virtual Path toPathData() const; protected: - virtual const SVGElement* contextElement() const { return this; } virtual bool hasRelativeValues() const; private: @@ -55,6 +52,11 @@ namespace WebCore { ANIMATED_PROPERTY_DECLARATIONS(SVGEllipseElement, SVGNames::ellipseTagString, SVGNames::cyAttrString, SVGLength, Cy, cy) ANIMATED_PROPERTY_DECLARATIONS(SVGEllipseElement, SVGNames::ellipseTagString, SVGNames::rxAttrString, SVGLength, Rx, rx) ANIMATED_PROPERTY_DECLARATIONS(SVGEllipseElement, SVGNames::ellipseTagString, SVGNames::ryAttrString, SVGLength, Ry, ry) + + // SVGExternalResourcesRequired + ANIMATED_PROPERTY_DECLARATIONS(SVGEllipseElement, SVGExternalResourcesRequiredIdentifier, + SVGNames::externalResourcesRequiredAttrString, bool, + ExternalResourcesRequired, externalResourcesRequired) }; } // namespace WebCore diff --git a/WebCore/svg/SVGExternalResourcesRequired.cpp b/WebCore/svg/SVGExternalResourcesRequired.cpp index 640f92e..b6b62d1 100644 --- a/WebCore/svg/SVGExternalResourcesRequired.cpp +++ b/WebCore/svg/SVGExternalResourcesRequired.cpp @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005, 2007 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either @@ -35,7 +33,6 @@ namespace WebCore { char SVGExternalResourcesRequiredIdentifier[] = "SVGExternalResourcesRequired"; SVGExternalResourcesRequired::SVGExternalResourcesRequired() - : m_externalResourcesRequired(this, SVGNames::externalResourcesRequiredAttr, false) { } diff --git a/WebCore/svg/SVGExternalResourcesRequired.h b/WebCore/svg/SVGExternalResourcesRequired.h index 0ab6dc9..f088c82 100644 --- a/WebCore/svg/SVGExternalResourcesRequired.h +++ b/WebCore/svg/SVGExternalResourcesRequired.h @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either @@ -25,22 +23,18 @@ #if ENABLE(SVG) #include "SVGElement.h" +#include "SVGNames.h" namespace WebCore { extern char SVGExternalResourcesRequiredIdentifier[]; class MappedAttribute; - // FIXME: This is wrong for several reasons: - // 1. externalResourcesRequired is not animateable according to SVG 1.1 section 5.9 - // 2. externalResourcesRequired should just be part of SVGElement, and default to "false" for all elements - /* - SPEC: Note that the SVG DOM - defines the attribute externalResourcesRequired as being of type SVGAnimatedBoolean, whereas the - SVG language definition says that externalResourcesRequired is not animated. Because the SVG - language definition states that externalResourcesRequired cannot be animated, the animVal will - always be the same as the baseVal. - */ + // Notes on a SVG 1.1 spec discrepancy: + // The SVG DOM defines the attribute externalResourcesRequired as being of type SVGAnimatedBoolean, whereas the + // SVG language definition says that externalResourcesRequired is not animated. Because the SVG language definition + // states that externalResourcesRequired cannot be animated, the animVal will always be the same as the baseVal. + // FIXME: When implementing animVal support, make sure that animVal==baseVal for externalResourcesRequired class SVGExternalResourcesRequired { public: SVGExternalResourcesRequired(); @@ -49,12 +43,8 @@ namespace WebCore { bool parseMappedAttribute(MappedAttribute*); bool isKnownAttribute(const QualifiedName&); - virtual const SVGElement* contextElement() const = 0; - - private: - ANIMATED_PROPERTY_DECLARATIONS(SVGExternalResourcesRequired, SVGExternalResourcesRequiredIdentifier, - SVGNames::externalResourcesRequiredAttrString, bool, - ExternalResourcesRequired, externalResourcesRequired) + protected: + virtual void setExternalResourcesRequiredBaseValue(SVGAnimatedTypeValue<bool>::DecoratedType type) = 0; }; } // namespace WebCore diff --git a/WebCore/svg/SVGFEBlendElement.cpp b/WebCore/svg/SVGFEBlendElement.cpp index 0497ea9..03c5795 100644 --- a/WebCore/svg/SVGFEBlendElement.cpp +++ b/WebCore/svg/SVGFEBlendElement.cpp @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005, 2006 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either diff --git a/WebCore/svg/SVGFEBlendElement.h b/WebCore/svg/SVGFEBlendElement.h index bed649f..c32eabd 100644 --- a/WebCore/svg/SVGFEBlendElement.h +++ b/WebCore/svg/SVGFEBlendElement.h @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005, 2006 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either diff --git a/WebCore/svg/SVGFEColorMatrixElement.cpp b/WebCore/svg/SVGFEColorMatrixElement.cpp index c2d605b..88a0d66 100644 --- a/WebCore/svg/SVGFEColorMatrixElement.cpp +++ b/WebCore/svg/SVGFEColorMatrixElement.cpp @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005, 2006 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either diff --git a/WebCore/svg/SVGFEColorMatrixElement.h b/WebCore/svg/SVGFEColorMatrixElement.h index 5b7a9ae..f3329e4 100644 --- a/WebCore/svg/SVGFEColorMatrixElement.h +++ b/WebCore/svg/SVGFEColorMatrixElement.h @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005, 2006 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either diff --git a/WebCore/svg/SVGFEComponentTransferElement.cpp b/WebCore/svg/SVGFEComponentTransferElement.cpp index 691d5cd..f1df08c 100644 --- a/WebCore/svg/SVGFEComponentTransferElement.cpp +++ b/WebCore/svg/SVGFEComponentTransferElement.cpp @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either diff --git a/WebCore/svg/SVGFEComponentTransferElement.h b/WebCore/svg/SVGFEComponentTransferElement.h index 21c95d2..46d6d9d 100644 --- a/WebCore/svg/SVGFEComponentTransferElement.h +++ b/WebCore/svg/SVGFEComponentTransferElement.h @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either diff --git a/WebCore/svg/SVGFECompositeElement.cpp b/WebCore/svg/SVGFECompositeElement.cpp index 6eec6ea..a2dd05a 100644 --- a/WebCore/svg/SVGFECompositeElement.cpp +++ b/WebCore/svg/SVGFECompositeElement.cpp @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005, 2006 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either diff --git a/WebCore/svg/SVGFECompositeElement.h b/WebCore/svg/SVGFECompositeElement.h index fc97169..1bb6b05 100644 --- a/WebCore/svg/SVGFECompositeElement.h +++ b/WebCore/svg/SVGFECompositeElement.h @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005, 2006 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either diff --git a/WebCore/svg/SVGFECompositeElement.idl b/WebCore/svg/SVGFECompositeElement.idl index 97a13fc..d317997 100644 --- a/WebCore/svg/SVGFECompositeElement.idl +++ b/WebCore/svg/SVGFECompositeElement.idl @@ -38,7 +38,7 @@ module svg { readonly attribute SVGAnimatedString in1; readonly attribute SVGAnimatedString in2; - readonly attribute SVGAnimatedEnumeration _operator; + readonly attribute SVGAnimatedEnumeration operator; readonly attribute SVGAnimatedNumber k1; readonly attribute SVGAnimatedNumber k2; readonly attribute SVGAnimatedNumber k3; diff --git a/WebCore/svg/SVGFEDiffuseLightingElement.cpp b/WebCore/svg/SVGFEDiffuseLightingElement.cpp index edbd852..ed6e353 100644 --- a/WebCore/svg/SVGFEDiffuseLightingElement.cpp +++ b/WebCore/svg/SVGFEDiffuseLightingElement.cpp @@ -88,20 +88,18 @@ bool SVGFEDiffuseLightingElement::build(SVGResourceFilter* filterResource) return true; } -LightSource* SVGFEDiffuseLightingElement::findLights() const +PassRefPtr<LightSource> SVGFEDiffuseLightingElement::findLights() const { - LightSource* light = 0; for (Node* n = firstChild(); n; n = n->nextSibling()) { if (n->hasTagName(SVGNames::feDistantLightTag) || n->hasTagName(SVGNames::fePointLightTag) || n->hasTagName(SVGNames::feSpotLightTag)) { SVGFELightElement* lightNode = static_cast<SVGFELightElement*>(n); - light = lightNode->lightSource(); - break; + return lightNode->lightSource(); } } - return light; + return 0; } } diff --git a/WebCore/svg/SVGFEDiffuseLightingElement.h b/WebCore/svg/SVGFEDiffuseLightingElement.h index fcb5eee..ed117a4 100644 --- a/WebCore/svg/SVGFEDiffuseLightingElement.h +++ b/WebCore/svg/SVGFEDiffuseLightingElement.h @@ -49,7 +49,7 @@ namespace WebCore { ANIMATED_PROPERTY_DECLARATIONS(SVGFEDiffuseLightingElement, SVGNames::feDiffuseLightingTagString, SVGKernelUnitLengthXIdentifier, float, KernelUnitLengthX, kernelUnitLengthX) ANIMATED_PROPERTY_DECLARATIONS(SVGFEDiffuseLightingElement, SVGNames::feDiffuseLightingTagString, SVGKernelUnitLengthYIdentifier, float, KernelUnitLengthY, kernelUnitLengthY) - LightSource* findLights() const; + PassRefPtr<LightSource> findLights() const; }; } // namespace WebCore diff --git a/WebCore/svg/SVGFEDistantLightElement.cpp b/WebCore/svg/SVGFEDistantLightElement.cpp index 35c487b..8322a3a 100644 --- a/WebCore/svg/SVGFEDistantLightElement.cpp +++ b/WebCore/svg/SVGFEDistantLightElement.cpp @@ -34,9 +34,9 @@ SVGFEDistantLightElement::~SVGFEDistantLightElement() { } -LightSource* SVGFEDistantLightElement::lightSource() const +PassRefPtr<LightSource> SVGFEDistantLightElement::lightSource() const { - return new DistantLightSource(azimuth(), elevation()); + return DistantLightSource::create(azimuth(), elevation()); } } diff --git a/WebCore/svg/SVGFEDistantLightElement.h b/WebCore/svg/SVGFEDistantLightElement.h index 95f45c8..3d0c039 100644 --- a/WebCore/svg/SVGFEDistantLightElement.h +++ b/WebCore/svg/SVGFEDistantLightElement.h @@ -29,7 +29,7 @@ namespace WebCore { SVGFEDistantLightElement(const QualifiedName&, Document*); virtual ~SVGFEDistantLightElement(); - virtual LightSource* lightSource() const; + virtual PassRefPtr<LightSource> lightSource() const; }; } // namespace WebCore diff --git a/WebCore/svg/SVGFEFloodElement.cpp b/WebCore/svg/SVGFEFloodElement.cpp index ae5ce94..d69c240 100644 --- a/WebCore/svg/SVGFEFloodElement.cpp +++ b/WebCore/svg/SVGFEFloodElement.cpp @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005, 2007, 2008 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either @@ -34,7 +32,6 @@ namespace WebCore { SVGFEFloodElement::SVGFEFloodElement(const QualifiedName& tagName, Document* doc) : SVGFilterPrimitiveStandardAttributes(tagName, doc) - , m_in1(this, SVGNames::inAttr) { } @@ -42,28 +39,14 @@ SVGFEFloodElement::~SVGFEFloodElement() { } -void SVGFEFloodElement::parseMappedAttribute(MappedAttribute* attr) -{ - const String& value = attr->value(); - if (attr->name() == SVGNames::inAttr) - setIn1BaseValue(value); - else - SVGFilterPrimitiveStandardAttributes::parseMappedAttribute(attr); -} - bool SVGFEFloodElement::build(SVGResourceFilter* filterResource) { - FilterEffect* input = filterResource->builder()->getEffectById(in1()); - - if (!input) - return false; - RefPtr<RenderStyle> filterStyle = styleForRenderer(); Color color = filterStyle->svgStyle()->floodColor(); float opacity = filterStyle->svgStyle()->floodOpacity(); - RefPtr<FilterEffect> effect = FEFlood::create(input, color, opacity); + RefPtr<FilterEffect> effect = FEFlood::create(color, opacity); filterResource->addFilterEffect(this, effect.release()); return true; @@ -71,6 +54,6 @@ bool SVGFEFloodElement::build(SVGResourceFilter* filterResource) } -#endif // ENABLE(SVG) +#endif // ENABLE(SVG) && ENABLE(FILTERS) // vim:ts=4:noet diff --git a/WebCore/svg/SVGFEFloodElement.h b/WebCore/svg/SVGFEFloodElement.h index ca4e18b..b8b49e7 100644 --- a/WebCore/svg/SVGFEFloodElement.h +++ b/WebCore/svg/SVGFEFloodElement.h @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005, 2008 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either @@ -33,14 +31,10 @@ namespace WebCore { SVGFEFloodElement(const QualifiedName&, Document*); virtual ~SVGFEFloodElement(); - virtual void parseMappedAttribute(MappedAttribute*); virtual bool build(SVGResourceFilter*); - - private: - ANIMATED_PROPERTY_DECLARATIONS(SVGFEFloodElement, SVGNames::feFloodTagString, SVGNames::inAttrString, String, In1, in1) }; } // namespace WebCore -#endif // ENABLE(SVG) +#endif // ENABLE(SVG) && ENABLE(FILTERS) #endif diff --git a/WebCore/svg/SVGFEFloodElement.idl b/WebCore/svg/SVGFEFloodElement.idl index 814bbdf..b3c3180 100644 --- a/WebCore/svg/SVGFEFloodElement.idl +++ b/WebCore/svg/SVGFEFloodElement.idl @@ -27,8 +27,5 @@ module svg { interface [Conditional=SVG&FILTERS, GenerateConstructor] SVGFEFloodElement : SVGElement, SVGFilterPrimitiveStandardAttributes { - - readonly attribute SVGAnimatedString in1; - }; } diff --git a/WebCore/svg/SVGFEFuncAElement.cpp b/WebCore/svg/SVGFEFuncAElement.cpp index 41118fe..a02b0e5 100644 --- a/WebCore/svg/SVGFEFuncAElement.cpp +++ b/WebCore/svg/SVGFEFuncAElement.cpp @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005, 2006 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either diff --git a/WebCore/svg/SVGFEFuncAElement.h b/WebCore/svg/SVGFEFuncAElement.h index 8ec6b1c..55a3c9d 100644 --- a/WebCore/svg/SVGFEFuncAElement.h +++ b/WebCore/svg/SVGFEFuncAElement.h @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either diff --git a/WebCore/svg/SVGFEFuncBElement.cpp b/WebCore/svg/SVGFEFuncBElement.cpp index 190b23a..2bf939b 100644 --- a/WebCore/svg/SVGFEFuncBElement.cpp +++ b/WebCore/svg/SVGFEFuncBElement.cpp @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005, 2006 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either diff --git a/WebCore/svg/SVGFEFuncBElement.h b/WebCore/svg/SVGFEFuncBElement.h index 5d86f87..177ed26 100644 --- a/WebCore/svg/SVGFEFuncBElement.h +++ b/WebCore/svg/SVGFEFuncBElement.h @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either diff --git a/WebCore/svg/SVGFEFuncGElement.cpp b/WebCore/svg/SVGFEFuncGElement.cpp index d5e5625..e0d60f4 100644 --- a/WebCore/svg/SVGFEFuncGElement.cpp +++ b/WebCore/svg/SVGFEFuncGElement.cpp @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005, 2006 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either diff --git a/WebCore/svg/SVGFEFuncGElement.h b/WebCore/svg/SVGFEFuncGElement.h index 9f5d3d7..4eeafa0 100644 --- a/WebCore/svg/SVGFEFuncGElement.h +++ b/WebCore/svg/SVGFEFuncGElement.h @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either diff --git a/WebCore/svg/SVGFEFuncRElement.cpp b/WebCore/svg/SVGFEFuncRElement.cpp index e3d7ee4..e8e6b99 100644 --- a/WebCore/svg/SVGFEFuncRElement.cpp +++ b/WebCore/svg/SVGFEFuncRElement.cpp @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005, 2006 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either diff --git a/WebCore/svg/SVGFEFuncRElement.h b/WebCore/svg/SVGFEFuncRElement.h index 0a0d115..196cfa3 100644 --- a/WebCore/svg/SVGFEFuncRElement.h +++ b/WebCore/svg/SVGFEFuncRElement.h @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either diff --git a/WebCore/svg/SVGFEGaussianBlurElement.cpp b/WebCore/svg/SVGFEGaussianBlurElement.cpp index 4cddb5a..b2970b3 100644 --- a/WebCore/svg/SVGFEGaussianBlurElement.cpp +++ b/WebCore/svg/SVGFEGaussianBlurElement.cpp @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005, 2006 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either diff --git a/WebCore/svg/SVGFEGaussianBlurElement.h b/WebCore/svg/SVGFEGaussianBlurElement.h index 187c212..9a5c058 100644 --- a/WebCore/svg/SVGFEGaussianBlurElement.h +++ b/WebCore/svg/SVGFEGaussianBlurElement.h @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005, 2006 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either @@ -24,7 +22,7 @@ #define SVGFEGaussianBlurElement_h #if ENABLE(SVG) && ENABLE(FILTERS) -#include "SVGFEGaussianBlur.h" +#include "FEGaussianBlur.h" #include "SVGFilterPrimitiveStandardAttributes.h" namespace WebCore { diff --git a/WebCore/svg/SVGFEImageElement.cpp b/WebCore/svg/SVGFEImageElement.cpp index 8122960..52531ee 100644 --- a/WebCore/svg/SVGFEImageElement.cpp +++ b/WebCore/svg/SVGFEImageElement.cpp @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either @@ -43,6 +41,8 @@ SVGFEImageElement::SVGFEImageElement(const QualifiedName& tagName, Document* doc , SVGLangSpace() , SVGExternalResourcesRequired() , m_preserveAspectRatio(this, SVGNames::preserveAspectRatioAttr, SVGPreserveAspectRatio::create()) + , m_href(this, XLinkNames::hrefAttr) + , m_externalResourcesRequired(this, SVGNames::externalResourcesRequiredAttr, false) { } diff --git a/WebCore/svg/SVGFEImageElement.h b/WebCore/svg/SVGFEImageElement.h index 67f3bd5..7c6d89b 100644 --- a/WebCore/svg/SVGFEImageElement.h +++ b/WebCore/svg/SVGFEImageElement.h @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either @@ -49,12 +47,17 @@ namespace WebCore { virtual void addSubresourceAttributeURLs(ListHashSet<KURL>&) const; virtual bool build(SVGResourceFilter*); - protected: - virtual const SVGElement* contextElement() const { return this; } - private: ANIMATED_PROPERTY_DECLARATIONS(SVGFEImageElement, SVGNames::feImageTagString, SVGNames::preserveAspectRatioAttrString, SVGPreserveAspectRatio, PreserveAspectRatio, preserveAspectRatio) + // SVGURIReference + ANIMATED_PROPERTY_DECLARATIONS(SVGFEImageElement, SVGURIReferenceIdentifier, XLinkNames::hrefAttrString, String, Href, href) + + // SVGExternalResourcesRequired + ANIMATED_PROPERTY_DECLARATIONS(SVGFEImageElement, SVGExternalResourcesRequiredIdentifier, + SVGNames::externalResourcesRequiredAttrString, bool, + ExternalResourcesRequired, externalResourcesRequired) + CachedResourceHandle<CachedImage> m_cachedImage; }; diff --git a/WebCore/svg/SVGFELightElement.h b/WebCore/svg/SVGFELightElement.h index a66ccf5..705eeaa 100644 --- a/WebCore/svg/SVGFELightElement.h +++ b/WebCore/svg/SVGFELightElement.h @@ -25,6 +25,7 @@ #if ENABLE(SVG) && ENABLE(FILTERS) #include "SVGElement.h" #include "SVGLightSource.h" +#include "SVGNames.h" namespace WebCore { @@ -35,12 +36,9 @@ namespace WebCore { SVGFELightElement(const QualifiedName&, Document*); virtual ~SVGFELightElement(); - virtual LightSource* lightSource() const = 0; + virtual PassRefPtr<LightSource> lightSource() const = 0; virtual void parseMappedAttribute(MappedAttribute*); - protected: - virtual const SVGElement* contextElement() const { return this; } - private: ANIMATED_PROPERTY_DECLARATIONS(SVGFELightElement, SVGFELightElementIdentifier, SVGNames::azimuthAttrString, float, Azimuth, azimuth) ANIMATED_PROPERTY_DECLARATIONS(SVGFELightElement, SVGFELightElementIdentifier, SVGNames::elevationAttrString, float, Elevation, elevation) diff --git a/WebCore/svg/SVGFEMergeElement.cpp b/WebCore/svg/SVGFEMergeElement.cpp index cb3a781..6c703ca 100644 --- a/WebCore/svg/SVGFEMergeElement.cpp +++ b/WebCore/svg/SVGFEMergeElement.cpp @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005, 2006 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either @@ -45,6 +43,8 @@ bool SVGFEMergeElement::build(SVGResourceFilter* filterResource) for (Node* n = firstChild(); n != 0; n = n->nextSibling()) { if (n->hasTagName(SVGNames::feMergeNodeTag)) { FilterEffect* mergeEffect = filterResource->builder()->getEffectById(static_cast<SVGFEMergeNodeElement*>(n)->in1()); + if (!mergeEffect) + return false; mergeInputs.append(mergeEffect); } } diff --git a/WebCore/svg/SVGFEMergeElement.h b/WebCore/svg/SVGFEMergeElement.h index e63ed04..f84ddce 100644 --- a/WebCore/svg/SVGFEMergeElement.h +++ b/WebCore/svg/SVGFEMergeElement.h @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005, 2006 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either diff --git a/WebCore/svg/SVGFEMergeNodeElement.cpp b/WebCore/svg/SVGFEMergeNodeElement.cpp index ae08706..4161de8 100644 --- a/WebCore/svg/SVGFEMergeNodeElement.cpp +++ b/WebCore/svg/SVGFEMergeNodeElement.cpp @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005, 2006 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either diff --git a/WebCore/svg/SVGFEMergeNodeElement.h b/WebCore/svg/SVGFEMergeNodeElement.h index e2af642..cdec8d2 100644 --- a/WebCore/svg/SVGFEMergeNodeElement.h +++ b/WebCore/svg/SVGFEMergeNodeElement.h @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005, 2006 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either @@ -25,6 +23,7 @@ #if ENABLE(SVG) && ENABLE(FILTERS) #include "SVGElement.h" +#include "SVGNames.h" namespace WebCore { @@ -35,9 +34,6 @@ namespace WebCore { virtual void parseMappedAttribute(MappedAttribute*); - protected: - virtual const SVGElement* contextElement() const { return this; } - private: ANIMATED_PROPERTY_DECLARATIONS(SVGFEMergeNodeElement, SVGNames::feMergeNodeTagString, SVGNames::inAttrString, String, In1, in1) }; diff --git a/WebCore/svg/SVGFEMorphologyElement.cpp b/WebCore/svg/SVGFEMorphologyElement.cpp new file mode 100644 index 0000000..4a06188 --- /dev/null +++ b/WebCore/svg/SVGFEMorphologyElement.cpp @@ -0,0 +1,88 @@ +/* + 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 + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include "config.h" + +#if ENABLE(SVG) && ENABLE(FILTERS) +#include "SVGFEMorphologyElement.h" + +#include "MappedAttribute.h" +#include "SVGNames.h" +#include "SVGParserUtilities.h" +#include "SVGResourceFilter.h" + +namespace WebCore { + +char SVGRadiusXAttrIdentifier[] = "SVGRadiusXAttr"; +char SVGRadiusYAttrIdentifier[] = "SVGRadiusYAttr"; + +SVGFEMorphologyElement::SVGFEMorphologyElement(const QualifiedName& tagName, Document* document) + : SVGFilterPrimitiveStandardAttributes(tagName, document) + , m_in1(this, SVGNames::inAttr) + , m__operator(this, SVGNames::operatorAttr, FEMORPHOLOGY_OPERATOR_ERODE) + , m_radiusX(this, SVGNames::radiusAttr) + , m_radiusY(this, SVGNames::radiusAttr) +{ +} + +SVGFEMorphologyElement::~SVGFEMorphologyElement() +{ +} + +void SVGFEMorphologyElement::setRadius(float, float) +{ + // FIXME: Needs an implementation. +} + +void SVGFEMorphologyElement::parseMappedAttribute(MappedAttribute* attr) +{ + const String& value = attr->value(); + if (attr->name() == SVGNames::operatorAttr) { + if (value == "erode") + set_operatorBaseValue(FEMORPHOLOGY_OPERATOR_ERODE); + else if (value == "dilate") + set_operatorBaseValue(FEMORPHOLOGY_OPERATOR_DILATE); + } else if (attr->name() == SVGNames::inAttr) + setIn1BaseValue(value); + else if (attr->name() == SVGNames::radiusAttr) { + float x, y; + if (parseNumberOptionalNumber(value, x, y)) { + setRadiusXBaseValue(x); + setRadiusYBaseValue(y); + } + } else + SVGFilterPrimitiveStandardAttributes::parseMappedAttribute(attr); +} + +bool SVGFEMorphologyElement::build(SVGResourceFilter* filterResource) +{ + FilterEffect* input1 = filterResource->builder()->getEffectById(in1()); + + if (!input1) + return false; + + RefPtr<FilterEffect> effect = FEMorphology::create(input1, static_cast<MorphologyOperatorType>(_operator()), radiusX(), radiusY()); + filterResource->addFilterEffect(this, effect.release()); + + return true; +} + +} //namespace WebCore + +#endif // ENABLE(SVG) diff --git a/WebCore/svg/SVGFEMorphologyElement.h b/WebCore/svg/SVGFEMorphologyElement.h new file mode 100644 index 0000000..6c1aec1 --- /dev/null +++ b/WebCore/svg/SVGFEMorphologyElement.h @@ -0,0 +1,52 @@ +/* + 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 + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef SVGFEMorphologyElement_h +#define SVGFEMorphologyElement_h + +#if ENABLE(SVG) && ENABLE(FILTERS) +#include "SVGFEMorphology.h" +#include "SVGFilterPrimitiveStandardAttributes.h" + +namespace WebCore { + + extern char SVGRadiusXAttrIdentifier[]; + extern char SVGRadiusYAttrIdentifier[]; + + class SVGFEMorphologyElement : public SVGFilterPrimitiveStandardAttributes { + public: + SVGFEMorphologyElement(const QualifiedName&, Document*); + virtual ~SVGFEMorphologyElement(); + + void setRadius(float radiusX, float radiusY); + + virtual void parseMappedAttribute(MappedAttribute*); + virtual bool build(SVGResourceFilter*); + + private: + ANIMATED_PROPERTY_DECLARATIONS(SVGFEMorphologyElement, SVGNames::feMorphologyTagString, SVGNames::inAttrString, String, In1, in1) + ANIMATED_PROPERTY_DECLARATIONS(SVGFEMorphologyElement, SVGNames::feMorphologyTagString, SVGNames::operatorAttrString, int, _operator, _operator) + ANIMATED_PROPERTY_DECLARATIONS(SVGFEMorphologyElement, SVGNames::feMorphologyTagString, SVGRadiusXAttrIdentifier, float, RadiusX, radiusX) + ANIMATED_PROPERTY_DECLARATIONS(SVGFEMorphologyElement, SVGNames::feMorphologyTagString, SVGRadiusYAttrIdentifier, float, RadiusY, radiusY) + }; + +} // namespace WebCore + +#endif // ENABLE(SVG) +#endif diff --git a/WebCore/svg/SVGDefinitionSrcElement.idl b/WebCore/svg/SVGFEMorphologyElement.idl index f221895..cce0e36 100644 --- a/WebCore/svg/SVGDefinitionSrcElement.idl +++ b/WebCore/svg/SVGFEMorphologyElement.idl @@ -1,5 +1,5 @@ /* - * Copyright (C) 2007 Eric Seidel <eric@webkit.org> + * Copyright (C) 2009 Dirk Schulze <krit@webkit.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -25,7 +25,19 @@ module svg { - interface [Conditional=SVG&SVG_FONTS] SVGDefinitionSrcElement : SVGElement { + interface [Conditional=SVG&FILTERS, GenerateConstructor] SVGFEMorphologyElement : SVGElement, + SVGFilterPrimitiveStandardAttributes { + // Morphology Operators + const unsigned short SVG_MORPHOLOGY_OPERATOR_UNKNOWN = 0; + const unsigned short SVG_MORPHOLOGY_OPERATOR_ERODE = 1; + const unsigned short SVG_MORPHOLOGY_OPERATOR_DILATE = 2; + + readonly attribute SVGAnimatedString in1; + readonly attribute SVGAnimatedEnumeration operator; + readonly attribute SVGAnimatedNumber radiusX; + readonly attribute SVGAnimatedNumber radiusY; + + void setRadius(in float radiusX, in float radiusY); }; } diff --git a/WebCore/svg/SVGFEOffsetElement.cpp b/WebCore/svg/SVGFEOffsetElement.cpp index 945a9da..95cbc8d 100644 --- a/WebCore/svg/SVGFEOffsetElement.cpp +++ b/WebCore/svg/SVGFEOffsetElement.cpp @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either diff --git a/WebCore/svg/SVGFEOffsetElement.h b/WebCore/svg/SVGFEOffsetElement.h index 1471abe..ae07ed8 100644 --- a/WebCore/svg/SVGFEOffsetElement.h +++ b/WebCore/svg/SVGFEOffsetElement.h @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either diff --git a/WebCore/svg/SVGFEPointLightElement.cpp b/WebCore/svg/SVGFEPointLightElement.cpp index 088f878..36ed2e9 100644 --- a/WebCore/svg/SVGFEPointLightElement.cpp +++ b/WebCore/svg/SVGFEPointLightElement.cpp @@ -34,10 +34,10 @@ SVGFEPointLightElement::~SVGFEPointLightElement() { } -LightSource* SVGFEPointLightElement::lightSource() const +PassRefPtr<LightSource> SVGFEPointLightElement::lightSource() const { FloatPoint3D pos(x(), y(), z()); - return new PointLightSource(pos); + return PointLightSource::create(pos); } } diff --git a/WebCore/svg/SVGFEPointLightElement.h b/WebCore/svg/SVGFEPointLightElement.h index b39fffa..9b1f997 100644 --- a/WebCore/svg/SVGFEPointLightElement.h +++ b/WebCore/svg/SVGFEPointLightElement.h @@ -29,7 +29,7 @@ namespace WebCore { SVGFEPointLightElement(const QualifiedName&, Document*); virtual ~SVGFEPointLightElement(); - virtual LightSource* lightSource() const; + virtual PassRefPtr<LightSource> lightSource() const; }; } // namespace WebCore diff --git a/WebCore/svg/SVGFESpecularLightingElement.cpp b/WebCore/svg/SVGFESpecularLightingElement.cpp index 7afa4cc..90e9cb3 100644 --- a/WebCore/svg/SVGFESpecularLightingElement.cpp +++ b/WebCore/svg/SVGFESpecularLightingElement.cpp @@ -70,20 +70,18 @@ void SVGFESpecularLightingElement::parseMappedAttribute(MappedAttribute* attr) SVGFilterPrimitiveStandardAttributes::parseMappedAttribute(attr); } -LightSource* SVGFESpecularLightingElement::findLights() const +PassRefPtr<LightSource> SVGFESpecularLightingElement::findLights() const { - LightSource* light = 0; for (Node* n = firstChild(); n; n = n->nextSibling()) { if (n->hasTagName(SVGNames::feDistantLightTag) || n->hasTagName(SVGNames::fePointLightTag) || n->hasTagName(SVGNames::feSpotLightTag)) { SVGFELightElement* lightNode = static_cast<SVGFELightElement*>(n); - light = lightNode->lightSource(); - break; + return lightNode->lightSource(); } } - return light; + return 0; } bool SVGFESpecularLightingElement::build(SVGResourceFilter* filterResource) diff --git a/WebCore/svg/SVGFESpecularLightingElement.h b/WebCore/svg/SVGFESpecularLightingElement.h index 8ef490a..b3771fe 100644 --- a/WebCore/svg/SVGFESpecularLightingElement.h +++ b/WebCore/svg/SVGFESpecularLightingElement.h @@ -48,8 +48,8 @@ namespace WebCore { ANIMATED_PROPERTY_DECLARATIONS(SVGFESpecularLightingElement, SVGNames::feSpecularLightingTagString, SVGNames::surfaceScaleAttrString, float, SurfaceScale, surfaceScale) ANIMATED_PROPERTY_DECLARATIONS(SVGFESpecularLightingElement, SVGNames::feSpecularLightingTagString, SVGKernelUnitLengthXIdentifier, float, KernelUnitLengthX, kernelUnitLengthX) ANIMATED_PROPERTY_DECLARATIONS(SVGFESpecularLightingElement, SVGNames::feSpecularLightingTagString, SVGKernelUnitLengthYIdentifier, float, KernelUnitLengthY, kernelUnitLengthY) - - LightSource* findLights() const; + + PassRefPtr<LightSource> findLights() const; }; } // namespace WebCore diff --git a/WebCore/svg/SVGFESpotLightElement.cpp b/WebCore/svg/SVGFESpotLightElement.cpp index 980a3bb..01fe54e 100644 --- a/WebCore/svg/SVGFESpotLightElement.cpp +++ b/WebCore/svg/SVGFESpotLightElement.cpp @@ -34,7 +34,7 @@ SVGFESpotLightElement::~SVGFESpotLightElement() { } -LightSource* SVGFESpotLightElement::lightSource() const +PassRefPtr<LightSource> SVGFESpotLightElement::lightSource() const { FloatPoint3D pos(x(), y(), z()); @@ -44,7 +44,7 @@ LightSource* SVGFESpotLightElement::lightSource() const pointsAtZ() - pos.z()); direction.normalize(); - return new SpotLightSource(pos, direction, specularExponent(), limitingConeAngle()); + return SpotLightSource::create(pos, direction, specularExponent(), limitingConeAngle()); } } diff --git a/WebCore/svg/SVGFESpotLightElement.h b/WebCore/svg/SVGFESpotLightElement.h index 440c664..d54e232 100644 --- a/WebCore/svg/SVGFESpotLightElement.h +++ b/WebCore/svg/SVGFESpotLightElement.h @@ -29,7 +29,7 @@ namespace WebCore { SVGFESpotLightElement(const QualifiedName&, Document*); virtual ~SVGFESpotLightElement(); - virtual LightSource* lightSource() const; + virtual PassRefPtr<LightSource> lightSource() const; }; } // namespace WebCore diff --git a/WebCore/svg/SVGFETileElement.cpp b/WebCore/svg/SVGFETileElement.cpp index 14af25f..8894d4b 100644 --- a/WebCore/svg/SVGFETileElement.cpp +++ b/WebCore/svg/SVGFETileElement.cpp @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either diff --git a/WebCore/svg/SVGFETileElement.h b/WebCore/svg/SVGFETileElement.h index b4fc0c5..142a797 100644 --- a/WebCore/svg/SVGFETileElement.h +++ b/WebCore/svg/SVGFETileElement.h @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either diff --git a/WebCore/svg/SVGFETurbulenceElement.cpp b/WebCore/svg/SVGFETurbulenceElement.cpp index b296e00..57114a3 100644 --- a/WebCore/svg/SVGFETurbulenceElement.cpp +++ b/WebCore/svg/SVGFETurbulenceElement.cpp @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005, 2006 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either diff --git a/WebCore/svg/SVGFETurbulenceElement.h b/WebCore/svg/SVGFETurbulenceElement.h index 3c95da8..f024f57 100644 --- a/WebCore/svg/SVGFETurbulenceElement.h +++ b/WebCore/svg/SVGFETurbulenceElement.h @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005, 2006 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either diff --git a/WebCore/svg/SVGFilterElement.cpp b/WebCore/svg/SVGFilterElement.cpp index 7703b6f..bb14448 100644 --- a/WebCore/svg/SVGFilterElement.cpp +++ b/WebCore/svg/SVGFilterElement.cpp @@ -2,8 +2,7 @@ Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org> Copyright (C) 2004, 2005, 2006 Rob Buis <buis@kde.org> Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com> - - This file is part of the KDE project + 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 @@ -27,12 +26,14 @@ #include "SVGFilterElement.h" #include "Attr.h" -#include "SVGFilterBuilder.h" +#include "FloatSize.h" #include "MappedAttribute.h" #include "PlatformString.h" +#include "SVGFilterBuilder.h" #include "SVGFilterPrimitiveStandardAttributes.h" #include "SVGLength.h" #include "SVGNames.h" +#include "SVGParserUtilities.h" #include "SVGResourceFilter.h" #include "SVGUnitTypes.h" @@ -54,6 +55,8 @@ SVGFilterElement::SVGFilterElement(const QualifiedName& tagName, Document* doc) , m_height(this, SVGNames::heightAttr, LengthModeHeight, "120%") , m_filterResX(this, SVGNames::filterResAttr) , m_filterResY(this, SVGNames::filterResAttr) + , m_href(this, XLinkNames::hrefAttr) + , m_externalResourcesRequired(this, SVGNames::externalResourcesRequiredAttr, false) { // Spec: If the x/y attribute is not specified, the effect is as if a value of "-10%" were specified. // Spec: If the width/height attribute is not specified, the effect is as if a value of "120%" were specified. @@ -88,7 +91,13 @@ void SVGFilterElement::parseMappedAttribute(MappedAttribute* attr) setWidthBaseValue(SVGLength(LengthModeWidth, value)); else if (attr->name() == SVGNames::heightAttr) setHeightBaseValue(SVGLength(LengthModeHeight, value)); - else { + else if (attr->name() == SVGNames::filterResAttr) { + float x, y; + if (parseNumberOptionalNumber(value, x, y)) { + setFilterResXBaseValue(x); + setFilterResYBaseValue(y); + } + } else { if (SVGURIReference::parseMappedAttribute(attr)) return; if (SVGLangSpace::parseMappedAttribute(attr)) @@ -100,39 +109,41 @@ void SVGFilterElement::parseMappedAttribute(MappedAttribute* attr) } } -SVGResource* SVGFilterElement::canvasResource() +void SVGFilterElement::buildFilter(const FloatRect& targetRect) const { - if (!attached()) - return 0; - - if (!m_filter) - m_filter = new SVGResourceFilter(); - bool filterBBoxMode = filterUnits() == SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX; - m_filter->setFilterBoundingBoxMode(filterBBoxMode); - - float _x, _y, _width, _height; - - if (filterBBoxMode) { - _x = x().valueAsPercentage(); - _y = y().valueAsPercentage(); - _width = width().valueAsPercentage(); - _height = height().valueAsPercentage(); - } else { - m_filter->setXBoundingBoxMode(x().unitType() == LengthTypePercentage); - m_filter->setYBoundingBoxMode(y().unitType() == LengthTypePercentage); - - _x = x().value(this); - _y = y().value(this); - _width = width().value(this); - _height = height().value(this); - } - - m_filter->setFilterRect(FloatRect(_x, _y, _width, _height)); - bool primitiveBBoxMode = primitiveUnits() == SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX; + + FloatRect filterBBox; + if (filterBBoxMode) + filterBBox = FloatRect(x().valueAsPercentage(), + y().valueAsPercentage(), + width().valueAsPercentage(), + height().valueAsPercentage()); + else + filterBBox = FloatRect(x().value(this), + y().value(this), + width().value(this), + height().value(this)); + + FloatRect filterRect = filterBBox; + if (filterBBoxMode) + filterRect = FloatRect(targetRect.x() + filterRect.x() * targetRect.width(), + targetRect.y() + filterRect.y() * targetRect.height(), + filterRect.width() * targetRect.width(), + filterRect.height() * targetRect.height()); + + m_filter->setFilterBoundingBox(filterRect); + m_filter->setFilterRect(filterBBox); m_filter->setEffectBoundingBoxMode(primitiveBBoxMode); + m_filter->setFilterBoundingBoxMode(filterBBoxMode); + + if (hasAttribute(SVGNames::filterResAttr)) { + m_filter->setHasFilterResolution(true); + m_filter->setFilterResolution(FloatSize(filterResX(), filterResY())); + } + // Add effects to the filter m_filter->builder()->clearEffects(); for (Node* n = firstChild(); n != 0; n = n->nextSibling()) { SVGElement* element = 0; @@ -147,12 +158,18 @@ SVGResource* SVGFilterElement::canvasResource() } } } +} +SVGResource* SVGFilterElement::canvasResource() +{ + if (!attached()) + return 0; + + if (!m_filter) + m_filter = SVGResourceFilter::create(this); return m_filter.get(); } } -#endif // ENABLE(SVG) - -// vim:ts=4:noet +#endif // ENABLE(SVG) && ENABLE(FILTERS) diff --git a/WebCore/svg/SVGFilterElement.h b/WebCore/svg/SVGFilterElement.h index 541ec14..836c689 100644 --- a/WebCore/svg/SVGFilterElement.h +++ b/WebCore/svg/SVGFilterElement.h @@ -3,8 +3,6 @@ Copyright (C) 2004, 2005, 2006 Rob Buis <buis@kde.org> Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either @@ -51,9 +49,6 @@ namespace WebCore { virtual void parseMappedAttribute(MappedAttribute*); virtual bool rendererIsNeeded(RenderStyle*) { return false; } - protected: - virtual const SVGElement* contextElement() const { return this; } - private: ANIMATED_PROPERTY_DECLARATIONS(SVGFilterElement, SVGNames::filterTagString, SVGNames::filterUnitsAttrString, int, FilterUnits, filterUnits) ANIMATED_PROPERTY_DECLARATIONS(SVGFilterElement, SVGNames::filterTagString, SVGNames::primitiveUnitsAttrString, int, PrimitiveUnits, primitiveUnits) @@ -64,7 +59,19 @@ namespace WebCore { ANIMATED_PROPERTY_DECLARATIONS(SVGFilterElement, SVGNames::filterTagString, SVGFilterResXIdentifier, long, FilterResX, filterResX) ANIMATED_PROPERTY_DECLARATIONS(SVGFilterElement, SVGNames::filterTagString, SVGFilterResYIdentifier, long, FilterResY, filterResY) - RefPtr<SVGResourceFilter> m_filter; + // SVGURIReference + ANIMATED_PROPERTY_DECLARATIONS(SVGFilterElement, SVGURIReferenceIdentifier, XLinkNames::hrefAttrString, String, Href, href) + + // SVGExternalResourcesRequired + ANIMATED_PROPERTY_DECLARATIONS(SVGFilterElement, SVGExternalResourcesRequiredIdentifier, + SVGNames::externalResourcesRequiredAttrString, bool, + ExternalResourcesRequired, externalResourcesRequired) + + mutable RefPtr<SVGResourceFilter> m_filter; + + private: + friend class SVGResourceFilter; + void buildFilter(const FloatRect& targetRect) const; }; } // namespace WebCore diff --git a/WebCore/svg/SVGFilterPrimitiveStandardAttributes.cpp b/WebCore/svg/SVGFilterPrimitiveStandardAttributes.cpp index 3eeb625..08559b4 100644 --- a/WebCore/svg/SVGFilterPrimitiveStandardAttributes.cpp +++ b/WebCore/svg/SVGFilterPrimitiveStandardAttributes.cpp @@ -1,8 +1,7 @@ /* Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005, 2006 Rob Buis <buis@kde.org> - - This file is part of the KDE project + 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 @@ -77,8 +76,6 @@ void SVGFilterPrimitiveStandardAttributes::setStandardAttributes(SVGResourceFilt ASSERT(resourceFilter); - float _x, _y, _width, _height; - if (this->hasAttribute(SVGNames::xAttr)) filterEffect->setHasX(true); if (this->hasAttribute(SVGNames::yAttr)) @@ -88,47 +85,19 @@ void SVGFilterPrimitiveStandardAttributes::setStandardAttributes(SVGResourceFilt if (this->hasAttribute(SVGNames::heightAttr)) filterEffect->setHasHeight(true); - if (resourceFilter->effectBoundingBoxMode()) { - _x = x().valueAsPercentage(); - _y = y().valueAsPercentage(); - _width = width().valueAsPercentage(); - _height = height().valueAsPercentage(); - } else { - // We need to resolve any percentages in filter rect space. - if (x().unitType() == LengthTypePercentage) { - filterEffect->setXBoundingBoxMode(true); - _x = x().valueAsPercentage(); - } else { - filterEffect->setXBoundingBoxMode(false); - _x = x().value(this); - } - - if (y().unitType() == LengthTypePercentage) { - filterEffect->setYBoundingBoxMode(true); - _y = y().valueAsPercentage(); - } else { - filterEffect->setYBoundingBoxMode(false); - _y = y().value(this); - } - - if (width().unitType() == LengthTypePercentage) { - filterEffect->setWidthBoundingBoxMode(true); - _width = width().valueAsPercentage(); - } else { - filterEffect->setWidthBoundingBoxMode(false); - _width = width().value(this); - } - - if (height().unitType() == LengthTypePercentage) { - filterEffect->setHeightBoundingBoxMode(true); - _height = height().valueAsPercentage(); - } else { - filterEffect->setHeightBoundingBoxMode(false); - _height = height().value(this); - } - } - - filterEffect->setSubRegion(FloatRect(_x, _y, _width, _height)); + FloatRect effectBBox; + if (resourceFilter->effectBoundingBoxMode()) + effectBBox = FloatRect(x().valueAsPercentage(), + y().valueAsPercentage(), + width().valueAsPercentage(), + height().valueAsPercentage()); + else + effectBBox = FloatRect(x().value(this), + y().value(this), + width().value(this), + height().value(this)); + + filterEffect->setEffectBoundaries(effectBBox); } } diff --git a/WebCore/svg/SVGFilterPrimitiveStandardAttributes.h b/WebCore/svg/SVGFilterPrimitiveStandardAttributes.h index fa82f6a..cb8ec1c 100644 --- a/WebCore/svg/SVGFilterPrimitiveStandardAttributes.h +++ b/WebCore/svg/SVGFilterPrimitiveStandardAttributes.h @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005, 2006 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either @@ -25,6 +23,7 @@ #if ENABLE(SVG) && ENABLE(FILTERS) #include "SVGFilterBuilder.h" +#include "SVGNames.h" #include "SVGResourceFilter.h" #include "SVGStyledElement.h" @@ -49,7 +48,6 @@ namespace WebCore { protected: friend class SVGResourceFilter; void setStandardAttributes(SVGResourceFilter*, FilterEffect*) const; - virtual const SVGElement* contextElement() const { return this; } private: ANIMATED_PROPERTY_DECLARATIONS(SVGFilterPrimitiveStandardAttributes, SVGFilterPrimitiveStandardAttributesIdentifier, SVGNames::xAttrString, SVGLength, X, x) diff --git a/WebCore/svg/SVGFitToViewBox.cpp b/WebCore/svg/SVGFitToViewBox.cpp index 847038c..c566a8f 100644 --- a/WebCore/svg/SVGFitToViewBox.cpp +++ b/WebCore/svg/SVGFitToViewBox.cpp @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either @@ -25,6 +23,7 @@ #if ENABLE(SVG) #include "SVGFitToViewBox.h" +#include "Attr.h" #include "Document.h" #include "FloatRect.h" #include "MappedAttribute.h" @@ -39,8 +38,6 @@ namespace WebCore { char SVGFitToViewBoxIdentifier[] = "SVGFitToViewBox"; SVGFitToViewBox::SVGFitToViewBox() - : m_viewBox(this, SVGNames::viewBoxAttr) - , m_preserveAspectRatio(this, SVGNames::preserveAspectRatioAttr, SVGPreserveAspectRatio::create()) { } @@ -48,9 +45,8 @@ SVGFitToViewBox::~SVGFitToViewBox() { } -bool SVGFitToViewBox::parseViewBox(const UChar*& c, const UChar* end, float& x, float& y, float& w, float& h, bool validate) +bool SVGFitToViewBox::parseViewBox(Document* doc, const UChar*& c, const UChar* end, float& x, float& y, float& w, float& h, bool validate) { - Document* doc = contextElement()->document(); String str(c, end - c); skipOptionalSpaces(c, end); @@ -81,24 +77,22 @@ bool SVGFitToViewBox::parseViewBox(const UChar*& c, const UChar* end, float& x, return true; } -TransformationMatrix SVGFitToViewBox::viewBoxToViewTransform(float viewWidth, float viewHeight) const +TransformationMatrix SVGFitToViewBox::viewBoxToViewTransform(const FloatRect& viewBoxRect, SVGPreserveAspectRatio* preserveAspectRatio, float viewWidth, float viewHeight) { - FloatRect viewBoxRect = viewBox(); + ASSERT(preserveAspectRatio); if (!viewBoxRect.width() || !viewBoxRect.height()) return TransformationMatrix(); - return preserveAspectRatio()->getCTM(viewBoxRect.x(), - viewBoxRect.y(), viewBoxRect.width(), viewBoxRect.height(), - 0, 0, viewWidth, viewHeight); + return preserveAspectRatio->getCTM(viewBoxRect.x(), viewBoxRect.y(), viewBoxRect.width(), viewBoxRect.height(), 0, 0, viewWidth, viewHeight); } -bool SVGFitToViewBox::parseMappedAttribute(MappedAttribute* attr) +bool SVGFitToViewBox::parseMappedAttribute(Document* document, MappedAttribute* attr) { if (attr->name() == SVGNames::viewBoxAttr) { float x = 0.0f, y = 0.0f, w = 0.0f, h = 0.0f; const UChar* c = attr->value().characters(); const UChar* end = c + attr->value().length(); - if (parseViewBox(c, end, x, y, w, h)) + if (parseViewBox(document, c, end, x, y, w, h)) setViewBoxBaseValue(FloatRect(x, y, w, h)); return true; } else if (attr->name() == SVGNames::preserveAspectRatioAttr) { diff --git a/WebCore/svg/SVGFitToViewBox.h b/WebCore/svg/SVGFitToViewBox.h index ac03df4..503a0ef 100644 --- a/WebCore/svg/SVGFitToViewBox.h +++ b/WebCore/svg/SVGFitToViewBox.h @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either @@ -38,17 +36,17 @@ namespace WebCore { SVGFitToViewBox(); virtual ~SVGFitToViewBox(); - bool parseViewBox(const UChar*& start, const UChar* end, float& x, float& y, float& w, float& h, bool validate = true); - virtual TransformationMatrix viewBoxToViewTransform(float viewWidth, float viewHeight) const; + bool parseViewBox(Document*, const UChar*& start, const UChar* end, float& x, float& y, float& w, float& h, bool validate = true); + static TransformationMatrix viewBoxToViewTransform(const FloatRect& viewBoxRect, SVGPreserveAspectRatio*, float viewWidth, float viewHeight); - bool parseMappedAttribute(MappedAttribute*); + bool parseMappedAttribute(Document*, MappedAttribute*); bool isKnownAttribute(const QualifiedName&); - virtual const SVGElement* contextElement() const = 0; + protected: + virtual SVGAnimatedTypeValue<FloatRect>::DecoratedType viewBoxBaseValue() const = 0; + virtual void setViewBoxBaseValue(SVGAnimatedTypeValue<FloatRect>::DecoratedType type) = 0; - private: - ANIMATED_PROPERTY_DECLARATIONS(SVGFitToViewBox, SVGFitToViewBoxIdentifier, SVGNames::viewBoxAttrString, FloatRect, ViewBox, viewBox) - ANIMATED_PROPERTY_DECLARATIONS(SVGFitToViewBox, SVGFitToViewBoxIdentifier, SVGNames::preserveAspectRatioAttrString, SVGPreserveAspectRatio, PreserveAspectRatio, preserveAspectRatio) + virtual SVGAnimatedTypeValue<SVGPreserveAspectRatio>::DecoratedType preserveAspectRatioBaseValue() const = 0; }; } // namespace WebCore diff --git a/WebCore/svg/SVGFontData.h b/WebCore/svg/SVGFontData.h index 4df3db2..3f17e3e 100644 --- a/WebCore/svg/SVGFontData.h +++ b/WebCore/svg/SVGFontData.h @@ -26,7 +26,7 @@ namespace WebCore { -class SVGFontData { +class SVGFontData : public Noncopyable { public: SVGFontData(SVGFontFaceElement*); virtual ~SVGFontData(); diff --git a/WebCore/svg/SVGFontElement.cpp b/WebCore/svg/SVGFontElement.cpp index 98321f4..7d62b8c 100644 --- a/WebCore/svg/SVGFontElement.cpp +++ b/WebCore/svg/SVGFontElement.cpp @@ -39,7 +39,8 @@ namespace WebCore { using namespace SVGNames; SVGFontElement::SVGFontElement(const QualifiedName& tagName, Document* doc) - : SVGStyledElement(tagName, doc) + : SVGStyledElement(tagName, doc) + , m_externalResourcesRequired(this, SVGNames::externalResourcesRequiredAttr, false) , m_isGlyphCacheValid(false) { } diff --git a/WebCore/svg/SVGFontElement.h b/WebCore/svg/SVGFontElement.h index 42468da..1fc5136 100644 --- a/WebCore/svg/SVGFontElement.h +++ b/WebCore/svg/SVGFontElement.h @@ -47,10 +47,12 @@ namespace WebCore { SVGMissingGlyphElement* firstMissingGlyphElement() const; - protected: - virtual const SVGElement* contextElement() const { return this; } - private: + // SVGExternalResourcesRequired + ANIMATED_PROPERTY_DECLARATIONS(SVGFontElement, SVGExternalResourcesRequiredIdentifier, + SVGNames::externalResourcesRequiredAttrString, bool, + ExternalResourcesRequired, externalResourcesRequired) + void ensureGlyphCache() const; typedef Vector<SVGHorizontalKerningPair> KerningPairVector; diff --git a/WebCore/svg/SVGFontFaceElement.cpp b/WebCore/svg/SVGFontFaceElement.cpp index 1e5a0fe..aa0b6d8 100644 --- a/WebCore/svg/SVGFontFaceElement.cpp +++ b/WebCore/svg/SVGFontFaceElement.cpp @@ -37,7 +37,6 @@ #include "Document.h" #include "Font.h" #include "MappedAttribute.h" -#include "SVGDefinitionSrcElement.h" #include "SVGFontElement.h" #include "SVGFontFaceSrcElement.h" #include "SVGGlyphElement.h" @@ -277,21 +276,12 @@ void SVGFontFaceElement::rebuildFontFace() // we currently ignore all but the first src element, alternatively we could concat them SVGFontFaceSrcElement* srcElement = 0; - SVGDefinitionSrcElement* definitionSrc = 0; - for (Node* child = firstChild(); child; child = child->nextSibling()) { - if (child->hasTagName(font_face_srcTag) && !srcElement) + for (Node* child = firstChild(); child && !srcElement; child = child->nextSibling()) { + if (child->hasTagName(font_face_srcTag)) srcElement = static_cast<SVGFontFaceSrcElement*>(child); - else if (child->hasTagName(definition_srcTag) && !definitionSrc) - definitionSrc = static_cast<SVGDefinitionSrcElement*>(child); } -#if 0 - // @font-face (CSSFontFace) does not yet support definition-src, as soon as it does this code should do the trick! - if (definitionSrc) - m_styleDeclaration->setProperty(CSSPropertyDefinitionSrc, definitionSrc->getAttribute(XLinkNames::hrefAttr), false); -#endif - bool describesParentFont = parentNode()->hasTagName(fontTag); RefPtr<CSSValueList> list; diff --git a/WebCore/svg/SVGForeignObjectElement.cpp b/WebCore/svg/SVGForeignObjectElement.cpp index 5cfca8a..1e75741 100644 --- a/WebCore/svg/SVGForeignObjectElement.cpp +++ b/WebCore/svg/SVGForeignObjectElement.cpp @@ -43,6 +43,8 @@ SVGForeignObjectElement::SVGForeignObjectElement(const QualifiedName& tagName, D , m_y(this, SVGNames::yAttr, LengthModeHeight) , m_width(this, SVGNames::widthAttr, LengthModeWidth) , m_height(this, SVGNames::heightAttr, LengthModeHeight) + , m_href(this, XLinkNames::hrefAttr) + , m_externalResourcesRequired(this, SVGNames::externalResourcesRequiredAttr, false) { } diff --git a/WebCore/svg/SVGForeignObjectElement.h b/WebCore/svg/SVGForeignObjectElement.h index 14dbe68..1848e2b 100644 --- a/WebCore/svg/SVGForeignObjectElement.h +++ b/WebCore/svg/SVGForeignObjectElement.h @@ -1,8 +1,6 @@ /* Copyright (C) 2006 Apple Computer, Inc. - This file is part of the WebKit project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either @@ -48,14 +46,19 @@ namespace WebCore { bool childShouldCreateRenderer(Node*) const; virtual RenderObject* createRenderer(RenderArena* arena, RenderStyle* style); - protected: - virtual const SVGElement* contextElement() const { return this; } - private: ANIMATED_PROPERTY_DECLARATIONS(SVGForeignObjectElement, SVGNames::foreignObjectTagString, SVGNames::xAttrString, SVGLength, X, x) ANIMATED_PROPERTY_DECLARATIONS(SVGForeignObjectElement, SVGNames::foreignObjectTagString, SVGNames::yAttrString, SVGLength, Y, y) ANIMATED_PROPERTY_DECLARATIONS(SVGForeignObjectElement, SVGNames::foreignObjectTagString, SVGNames::widthAttrString, SVGLength, Width, width) ANIMATED_PROPERTY_DECLARATIONS(SVGForeignObjectElement, SVGNames::foreignObjectTagString, SVGNames::heightAttrString, SVGLength, Height, height) + + // SVGURIReference + ANIMATED_PROPERTY_DECLARATIONS(SVGForeignObjectElement, SVGURIReferenceIdentifier, XLinkNames::hrefAttrString, String, Href, href) + + // SVGExternalResourcesRequired + ANIMATED_PROPERTY_DECLARATIONS(SVGForeignObjectElement, SVGExternalResourcesRequiredIdentifier, + SVGNames::externalResourcesRequiredAttrString, bool, + ExternalResourcesRequired, externalResourcesRequired) }; } // namespace WebCore diff --git a/WebCore/svg/SVGGElement.cpp b/WebCore/svg/SVGGElement.cpp index 2b50d74..ef46af4 100644 --- a/WebCore/svg/SVGGElement.cpp +++ b/WebCore/svg/SVGGElement.cpp @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005, 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005, 2006 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either @@ -34,6 +32,7 @@ SVGGElement::SVGGElement(const QualifiedName& tagName, Document* doc) , SVGTests() , SVGLangSpace() , SVGExternalResourcesRequired() + , m_externalResourcesRequired(this, SVGNames::externalResourcesRequiredAttr, false) { } diff --git a/WebCore/svg/SVGGElement.h b/WebCore/svg/SVGGElement.h index 8e3b368..9cfb5a3 100644 --- a/WebCore/svg/SVGGElement.h +++ b/WebCore/svg/SVGGElement.h @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005, 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005, 2006 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either @@ -47,10 +45,12 @@ namespace WebCore { virtual RenderObject* createRenderer(RenderArena*, RenderStyle*); - protected: - virtual const SVGElement* contextElement() const { return this; } - private: + // SVGExternalResourcesRequired + ANIMATED_PROPERTY_DECLARATIONS(SVGGElement, SVGExternalResourcesRequiredIdentifier, + SVGNames::externalResourcesRequiredAttrString, bool, + ExternalResourcesRequired, externalResourcesRequired) + friend class SVGUseElement; TransformationMatrix localMatrix() const; }; diff --git a/WebCore/svg/SVGGradientElement.cpp b/WebCore/svg/SVGGradientElement.cpp index 8034286..b4fe21d 100644 --- a/WebCore/svg/SVGGradientElement.cpp +++ b/WebCore/svg/SVGGradientElement.cpp @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005, 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either @@ -48,6 +46,8 @@ SVGGradientElement::SVGGradientElement(const QualifiedName& tagName, Document* d , m_spreadMethod(this, SVGNames::spreadMethodAttr) , m_gradientUnits(this, SVGNames::gradientUnitsAttr, SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX) , m_gradientTransform(this, SVGNames::gradientTransformAttr, SVGTransformList::create(SVGNames::gradientTransformAttr)) + , m_href(this, XLinkNames::hrefAttr) + , m_externalResourcesRequired(this, SVGNames::externalResourcesRequiredAttr, false) { } diff --git a/WebCore/svg/SVGGradientElement.h b/WebCore/svg/SVGGradientElement.h index 2027258..8413597 100644 --- a/WebCore/svg/SVGGradientElement.h +++ b/WebCore/svg/SVGGradientElement.h @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005, 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005, 2006 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either @@ -60,12 +58,18 @@ namespace WebCore { Vector<SVGGradientStop> buildStops() const; mutable RefPtr<SVGPaintServerGradient> m_resource; - virtual const SVGElement* contextElement() const { return this; } - protected: ANIMATED_PROPERTY_DECLARATIONS(SVGGradientElement, SVGGradientElementIdentifier, SVGNames::spreadMethodAttrString, int, SpreadMethod, spreadMethod) ANIMATED_PROPERTY_DECLARATIONS(SVGGradientElement, SVGGradientElementIdentifier, SVGNames::gradientUnitsAttrString, int, GradientUnits, gradientUnits) ANIMATED_PROPERTY_DECLARATIONS(SVGGradientElement, SVGGradientElementIdentifier, SVGNames::gradientTransformAttrString, SVGTransformList, GradientTransform, gradientTransform) + + // SVGURIReference + ANIMATED_PROPERTY_DECLARATIONS(SVGGradientElement, SVGURIReferenceIdentifier, XLinkNames::hrefAttrString, String, Href, href) + + // SVGExternalResourcesRequired + ANIMATED_PROPERTY_DECLARATIONS(SVGGradientElement, SVGExternalResourcesRequiredIdentifier, + SVGNames::externalResourcesRequiredAttrString, bool, + ExternalResourcesRequired, externalResourcesRequired) }; } // namespace WebCore diff --git a/WebCore/svg/SVGHKernElement.idl b/WebCore/svg/SVGHKernElement.idl index 1971aef..7706578 100644 --- a/WebCore/svg/SVGHKernElement.idl +++ b/WebCore/svg/SVGHKernElement.idl @@ -1,8 +1,6 @@ /* Copyright (C) 2008 Apple Computer, Inc. All rights reserved. - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either diff --git a/WebCore/svg/SVGImageElement.cpp b/WebCore/svg/SVGImageElement.cpp index 299828f..e29846c 100644 --- a/WebCore/svg/SVGImageElement.cpp +++ b/WebCore/svg/SVGImageElement.cpp @@ -45,7 +45,9 @@ SVGImageElement::SVGImageElement(const QualifiedName& tagName, Document* doc) , m_y(this, SVGNames::yAttr, LengthModeHeight) , m_width(this, SVGNames::widthAttr, LengthModeWidth) , m_height(this, SVGNames::heightAttr, LengthModeHeight) - , m_preserveAspectRatio(this, SVGNames::preserveAspectRatioAttr, SVGPreserveAspectRatio::create()) + , m_preserveAspectRatio(this, SVGNames::preserveAspectRatioAttr, SVGPreserveAspectRatio::create()) + , m_href(this, XLinkNames::hrefAttr) + , m_externalResourcesRequired(this, SVGNames::externalResourcesRequiredAttr, false) , m_imageLoader(this) { } diff --git a/WebCore/svg/SVGImageElement.h b/WebCore/svg/SVGImageElement.h index 1d242b5..1bdcdba 100644 --- a/WebCore/svg/SVGImageElement.h +++ b/WebCore/svg/SVGImageElement.h @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005, 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005, 2006 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either @@ -61,7 +59,6 @@ namespace WebCore { protected: virtual bool haveLoadedRequiredResources(); virtual bool hasRelativeValues() const; - virtual const SVGElement* contextElement() const { return this; } private: ANIMATED_PROPERTY_DECLARATIONS(SVGImageElement, SVGNames::imageTagString, SVGNames::xAttrString, SVGLength, X, x) @@ -70,6 +67,14 @@ namespace WebCore { ANIMATED_PROPERTY_DECLARATIONS(SVGImageElement, SVGNames::imageTagString, SVGNames::heightAttrString, SVGLength, Height, height) ANIMATED_PROPERTY_DECLARATIONS(SVGImageElement, SVGNames::imageTagString, SVGNames::preserveAspectRatioAttrString, SVGPreserveAspectRatio, PreserveAspectRatio, preserveAspectRatio) + // SVGURIReference + ANIMATED_PROPERTY_DECLARATIONS(SVGImageElement, SVGURIReferenceIdentifier, XLinkNames::hrefAttrString, String, Href, href) + + // SVGExternalResourcesRequired + ANIMATED_PROPERTY_DECLARATIONS(SVGImageElement, SVGExternalResourcesRequiredIdentifier, + SVGNames::externalResourcesRequiredAttrString, bool, + ExternalResourcesRequired, externalResourcesRequired) + SVGImageLoader m_imageLoader; }; diff --git a/WebCore/svg/SVGImageLoader.cpp b/WebCore/svg/SVGImageLoader.cpp index f8380f5..5d5d3bc 100644 --- a/WebCore/svg/SVGImageLoader.cpp +++ b/WebCore/svg/SVGImageLoader.cpp @@ -25,6 +25,7 @@ #if ENABLE(SVG) #include "SVGImageLoader.h" +#include "Event.h" #include "EventNames.h" #include "SVGImageElement.h" #include "RenderImage.h" @@ -43,7 +44,7 @@ SVGImageLoader::~SVGImageLoader() void SVGImageLoader::dispatchLoadEvent() { if (image()->errorOccurred()) - element()->dispatchEvent(eventNames().errorEvent, false, false); + element()->dispatchEvent(Event::create(eventNames().errorEvent, false, false)); else { SVGImageElement* imageElement = static_cast<SVGImageElement*>(element()); if (imageElement->externalResourcesRequiredBaseValue()) diff --git a/WebCore/svg/SVGLangSpace.cpp b/WebCore/svg/SVGLangSpace.cpp index d49e09a..f0d6997 100644 --- a/WebCore/svg/SVGLangSpace.cpp +++ b/WebCore/svg/SVGLangSpace.cpp @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005, 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005, 2006 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either diff --git a/WebCore/svg/SVGLangSpace.h b/WebCore/svg/SVGLangSpace.h index df8606e..1613998 100644 --- a/WebCore/svg/SVGLangSpace.h +++ b/WebCore/svg/SVGLangSpace.h @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005, 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005, 2006 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either diff --git a/WebCore/svg/SVGLength.cpp b/WebCore/svg/SVGLength.cpp index ca3bac3..2884507 100644 --- a/WebCore/svg/SVGLength.cpp +++ b/WebCore/svg/SVGLength.cpp @@ -3,8 +3,6 @@ 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org> 2007 Apple Inc. All rights reserved. - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either diff --git a/WebCore/svg/SVGLength.h b/WebCore/svg/SVGLength.h index 7846b4a..a14bc68 100644 --- a/WebCore/svg/SVGLength.h +++ b/WebCore/svg/SVGLength.h @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005, 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005, 2006 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either diff --git a/WebCore/svg/SVGLength.idl b/WebCore/svg/SVGLength.idl index 20748b1..3938a2c 100644 --- a/WebCore/svg/SVGLength.idl +++ b/WebCore/svg/SVGLength.idl @@ -4,8 +4,6 @@ Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com> Copyright (C) 2006 Apple Computer, Inc. All rights reserved. - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either diff --git a/WebCore/svg/SVGLengthList.cpp b/WebCore/svg/SVGLengthList.cpp index 20b61d6..367befb 100644 --- a/WebCore/svg/SVGLengthList.cpp +++ b/WebCore/svg/SVGLengthList.cpp @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005, 2006 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either diff --git a/WebCore/svg/SVGLengthList.h b/WebCore/svg/SVGLengthList.h index e83fee8..00fc3f8 100644 --- a/WebCore/svg/SVGLengthList.h +++ b/WebCore/svg/SVGLengthList.h @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005, 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005, 2006 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either diff --git a/WebCore/svg/SVGLineElement.cpp b/WebCore/svg/SVGLineElement.cpp index cb31178..a359698 100644 --- a/WebCore/svg/SVGLineElement.cpp +++ b/WebCore/svg/SVGLineElement.cpp @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005, 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either @@ -42,6 +40,7 @@ SVGLineElement::SVGLineElement(const QualifiedName& tagName, Document* doc) , m_y1(this, SVGNames::y1Attr, LengthModeHeight) , m_x2(this, SVGNames::x2Attr, LengthModeWidth) , m_y2(this, SVGNames::y2Attr, LengthModeHeight) + , m_externalResourcesRequired(this, SVGNames::externalResourcesRequiredAttr, false) { } diff --git a/WebCore/svg/SVGLineElement.h b/WebCore/svg/SVGLineElement.h index 2d89f5c..a24e009 100644 --- a/WebCore/svg/SVGLineElement.h +++ b/WebCore/svg/SVGLineElement.h @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005, 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005, 2006 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either @@ -51,7 +49,6 @@ namespace WebCore { virtual bool supportsMarkers() const { return true; } protected: - virtual const SVGElement* contextElement() const { return this; } virtual bool hasRelativeValues() const; private: @@ -59,6 +56,11 @@ namespace WebCore { ANIMATED_PROPERTY_DECLARATIONS(SVGLineElement, SVGNames::lineTagString, SVGNames::y1AttrString, SVGLength, Y1, y1) ANIMATED_PROPERTY_DECLARATIONS(SVGLineElement, SVGNames::lineTagString, SVGNames::x2AttrString, SVGLength, X2, x2) ANIMATED_PROPERTY_DECLARATIONS(SVGLineElement, SVGNames::lineTagString, SVGNames::y2AttrString, SVGLength, Y2, y2) + + // SVGExternalResourcesRequired + ANIMATED_PROPERTY_DECLARATIONS(SVGLineElement, SVGExternalResourcesRequiredIdentifier, + SVGNames::externalResourcesRequiredAttrString, bool, + ExternalResourcesRequired, externalResourcesRequired) }; } // namespace WebCore diff --git a/WebCore/svg/SVGLinearGradientElement.cpp b/WebCore/svg/SVGLinearGradientElement.cpp index 9927a50..f5c8cee 100644 --- a/WebCore/svg/SVGLinearGradientElement.cpp +++ b/WebCore/svg/SVGLinearGradientElement.cpp @@ -84,8 +84,15 @@ void SVGLinearGradientElement::buildGradient() const RefPtr<SVGPaintServerLinearGradient> linearGradient = WTF::static_pointer_cast<SVGPaintServerLinearGradient>(m_resource); - FloatPoint startPoint = FloatPoint::narrowPrecision(attributes.x1(), attributes.y1()); - FloatPoint endPoint = FloatPoint::narrowPrecision(attributes.x2(), attributes.y2()); + 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()); @@ -142,16 +149,16 @@ LinearGradientAttributes SVGLinearGradientElement::collectGradientProperties() c const SVGLinearGradientElement* linear = static_cast<const SVGLinearGradientElement*>(current); if (!attributes.hasX1() && current->hasAttribute(SVGNames::x1Attr)) - attributes.setX1(linear->x1().valueAsPercentage()); + attributes.setX1(linear->x1()); if (!attributes.hasY1() && current->hasAttribute(SVGNames::y1Attr)) - attributes.setY1(linear->y1().valueAsPercentage()); + attributes.setY1(linear->y1()); if (!attributes.hasX2() && current->hasAttribute(SVGNames::x2Attr)) - attributes.setX2(linear->x2().valueAsPercentage()); + attributes.setX2(linear->x2()); if (!attributes.hasY2() && current->hasAttribute(SVGNames::y2Attr)) - attributes.setY2(linear->y2().valueAsPercentage()); + attributes.setY2(linear->y2()); } processedGradients.add(current); diff --git a/WebCore/svg/SVGLinearGradientElement.h b/WebCore/svg/SVGLinearGradientElement.h index 0e1efd4..492c366 100644 --- a/WebCore/svg/SVGLinearGradientElement.h +++ b/WebCore/svg/SVGLinearGradientElement.h @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005, 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005, 2006 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either diff --git a/WebCore/svg/SVGList.h b/WebCore/svg/SVGList.h index c04c200..8fb3bc1 100644 --- a/WebCore/svg/SVGList.h +++ b/WebCore/svg/SVGList.h @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005, 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either @@ -41,6 +39,10 @@ namespace WebCore { { return SVGListTraits<UsesDefaultInitializer<Item>::value, Item>::nullItem(); } + static bool isNull(const Item& it) + { + return SVGListTraits<UsesDefaultInitializer<Item>::value, Item>::isNull(it); + } }; template<typename Item> @@ -58,6 +60,10 @@ namespace WebCore { Item initialize(Item newItem, ExceptionCode& ec) { + if (TypeOperations::isNull(newItem)) { + ec = TYPE_MISMATCH_ERR; + return TypeOperations::nullItem(); + } clear(ec); return appendItem(newItem, ec); } @@ -94,8 +100,13 @@ namespace WebCore { return m_vector[index]; } - Item insertItemBefore(Item newItem, unsigned int index, ExceptionCode&) + Item insertItemBefore(Item newItem, unsigned int index, ExceptionCode& ec) { + if (TypeOperations::isNull(newItem)) { + ec = TYPE_MISMATCH_ERR; + return TypeOperations::nullItem(); + } + if (index < m_vector.size()) { m_vector.insert(index, newItem); } else { @@ -110,6 +121,11 @@ namespace WebCore { ec = INDEX_SIZE_ERR; return TypeOperations::nullItem(); } + + if (TypeOperations::isNull(newItem)) { + ec = TYPE_MISMATCH_ERR; + return TypeOperations::nullItem(); + } m_vector[index] = newItem; return newItem; @@ -127,8 +143,13 @@ namespace WebCore { return item; } - Item appendItem(Item newItem, ExceptionCode&) + Item appendItem(Item newItem, ExceptionCode& ec) { + if (TypeOperations::isNull(newItem)) { + ec = TYPE_MISMATCH_ERR; + return TypeOperations::nullItem(); + } + m_vector.append(newItem); return newItem; } diff --git a/WebCore/svg/SVGListTraits.h b/WebCore/svg/SVGListTraits.h index d96bc67..f58b9b9 100644 --- a/WebCore/svg/SVGListTraits.h +++ b/WebCore/svg/SVGListTraits.h @@ -2,8 +2,6 @@ Copyright (C) 2006 Nikolas Zimmermann <wildfox@kde.org> 2006 Apple Computer Inc. - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either @@ -25,24 +23,48 @@ #if ENABLE(SVG) +#include <wtf/RefPtr.h> + namespace WebCore { template<typename Item> struct UsesDefaultInitializer { static const bool value = true; }; template<> struct UsesDefaultInitializer<double> { static const bool value = false; }; + template<> struct UsesDefaultInitializer<float> { static const bool value = false; }; template<bool usesDefaultInitializer, typename Item> struct SVGListTraits { }; + template<typename ItemPtr> + struct SVGListTraits<true, ItemPtr*> { + static ItemPtr* nullItem() { return 0; } + static bool isNull(ItemPtr* it) { return !it; } + }; + + template<typename ItemPtr> + struct SVGListTraits<true, RefPtr<ItemPtr> > { + static RefPtr<ItemPtr> nullItem() { return 0; } + static bool isNull(const RefPtr<ItemPtr>& it) { return !it; } + }; + template<typename Item> struct SVGListTraits<true, Item> { - static Item nullItem() { return Item(); } + static Item nullItem() { return Item(); } + static bool isNull(Item it) { return !it; } }; template<> struct SVGListTraits<false, double> { static double nullItem() { return 0.0; } + static bool isNull(double) { return false; } }; + template<> + struct SVGListTraits<false, float> { + static float nullItem() { return 0; } + static bool isNull(float) { return false; } + }; + + } // namespace WebCore #endif // SVG_SUPPORT diff --git a/WebCore/svg/SVGLocatable.h b/WebCore/svg/SVGLocatable.h index ccb9072..180dae5 100644 --- a/WebCore/svg/SVGLocatable.h +++ b/WebCore/svg/SVGLocatable.h @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005 Nikolas Zimmermann <wildfox@kde.org> 2004, 2005, 2007 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either diff --git a/WebCore/svg/SVGMPathElement.cpp b/WebCore/svg/SVGMPathElement.cpp index b3214ed..b8c862a 100644 --- a/WebCore/svg/SVGMPathElement.cpp +++ b/WebCore/svg/SVGMPathElement.cpp @@ -31,6 +31,8 @@ namespace WebCore { SVGMPathElement::SVGMPathElement(const QualifiedName& qname, Document* doc) : SVGElement(qname, doc) + , m_href(this, XLinkNames::hrefAttr) + , m_externalResourcesRequired(this, SVGNames::externalResourcesRequiredAttr, false) { } @@ -47,7 +49,7 @@ void SVGMPathElement::parseMappedAttribute(MappedAttribute* attr) SVGPathElement* SVGMPathElement::pathElement() { - Element* target = document()->getElementById(getTarget(SVGURIReference::href())); + Element* target = document()->getElementById(getTarget(href())); if (target && target->hasTagName(SVGNames::pathTag)) return static_cast<SVGPathElement*>(target); return 0; diff --git a/WebCore/svg/SVGMPathElement.h b/WebCore/svg/SVGMPathElement.h index 988cead..ded6cdf 100644 --- a/WebCore/svg/SVGMPathElement.h +++ b/WebCore/svg/SVGMPathElement.h @@ -1,28 +1,26 @@ /* - Copyright (C) 2007 Eric Seidel <eric@webkit.org> - - This file is part of the WebKit project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. - */ + Copyright (C) 2007 Eric Seidel <eric@webkit.org> + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ #ifndef SVGMPathElement_h #define SVGMPathElement_h -#if ENABLE(SVG) +#if ENABLE(SVG) #include "SVGURIReference.h" #include "SVGExternalResourcesRequired.h" @@ -31,8 +29,8 @@ namespace WebCore { class SVGPathElement; class SVGMPathElement : public SVGElement, - SVGURIReference, - SVGExternalResourcesRequired { + public SVGURIReference, + public SVGExternalResourcesRequired { public: SVGMPathElement(const QualifiedName&, Document*); virtual ~SVGMPathElement(); @@ -41,13 +39,17 @@ namespace WebCore { SVGPathElement* pathElement(); - protected: - virtual const SVGElement* contextElement() const { return this; } + private: + // SVGURIReference + ANIMATED_PROPERTY_DECLARATIONS(SVGMPathElement, SVGURIReferenceIdentifier, XLinkNames::hrefAttrString, String, Href, href) + + // SVGExternalResourcesRequired + ANIMATED_PROPERTY_DECLARATIONS(SVGMPathElement, SVGExternalResourcesRequiredIdentifier, + SVGNames::externalResourcesRequiredAttrString, bool, + ExternalResourcesRequired, externalResourcesRequired) }; } // namespace WebCore #endif // ENABLE(SVG) #endif // SVGMPathElement_h - -// vim:ts=4:noet diff --git a/WebCore/svg/SVGMarkerElement.cpp b/WebCore/svg/SVGMarkerElement.cpp index b09e718..2e96926 100644 --- a/WebCore/svg/SVGMarkerElement.cpp +++ b/WebCore/svg/SVGMarkerElement.cpp @@ -50,6 +50,9 @@ SVGMarkerElement::SVGMarkerElement(const QualifiedName& tagName, Document* doc) , m_markerUnits(this, SVGNames::markerUnitsAttr, SVG_MARKERUNITS_STROKEWIDTH) , m_orientType(this, SVGNames::orientAttr, SVG_MARKER_ORIENT_ANGLE) , m_orientAngle(this, SVGNames::orientAttr, SVGAngle::create()) + , m_externalResourcesRequired(this, SVGNames::externalResourcesRequiredAttr, false) + , m_viewBox(this, SVGNames::viewBoxAttr) + , m_preserveAspectRatio(this, SVGNames::preserveAspectRatioAttr, SVGPreserveAspectRatio::create()) { // Spec: If the markerWidth/markerHeight attribute is not specified, the effect is as if a value of "3" were specified. } @@ -63,6 +66,11 @@ SVGMarkerElement::~SVGMarkerElement() detach(); } +TransformationMatrix SVGMarkerElement::viewBoxToViewTransform(float viewWidth, float viewHeight) const +{ + return SVGFitToViewBox::viewBoxToViewTransform(viewBox(), preserveAspectRatio(), viewWidth, viewHeight); +} + void SVGMarkerElement::parseMappedAttribute(MappedAttribute* attr) { if (attr->name() == SVGNames::markerUnitsAttr) { @@ -94,7 +102,7 @@ void SVGMarkerElement::parseMappedAttribute(MappedAttribute* attr) return; if (SVGExternalResourcesRequired::parseMappedAttribute(attr)) return; - if (SVGFitToViewBox::parseMappedAttribute(attr)) + if (SVGFitToViewBox::parseMappedAttribute(document(), attr)) return; SVGStyledElement::parseMappedAttribute(attr); diff --git a/WebCore/svg/SVGMarkerElement.h b/WebCore/svg/SVGMarkerElement.h index e2e3493..7e08a96 100644 --- a/WebCore/svg/SVGMarkerElement.h +++ b/WebCore/svg/SVGMarkerElement.h @@ -58,6 +58,8 @@ namespace WebCore { SVGMarkerElement(const QualifiedName&, Document*); virtual ~SVGMarkerElement(); + TransformationMatrix viewBoxToViewTransform(float viewWidth, float viewHeight) const; + void setOrientToAuto(); void setOrientToAngle(PassRefPtr<SVGAngle>); @@ -68,9 +70,6 @@ namespace WebCore { virtual RenderObject* createRenderer(RenderArena*, RenderStyle*); virtual SVGResource* canvasResource(); - protected: - virtual const SVGElement* contextElement() const { return this; } - private: ANIMATED_PROPERTY_DECLARATIONS(SVGMarkerElement, SVGNames::markerTagString, SVGNames::refXAttrString, SVGLength, RefX, refX) ANIMATED_PROPERTY_DECLARATIONS(SVGMarkerElement, SVGNames::markerTagString, SVGNames::refYAttrString, SVGLength, RefY, refY) @@ -80,6 +79,15 @@ namespace WebCore { ANIMATED_PROPERTY_DECLARATIONS(SVGMarkerElement, SVGNames::markerTagString, SVGOrientTypeAttrIdentifier, int, OrientType, orientType) ANIMATED_PROPERTY_DECLARATIONS(SVGMarkerElement, SVGNames::markerTagString, SVGOrientAngleAttrIdentifier, SVGAngle, OrientAngle, orientAngle) + // SVGExternalResourcesRequired + ANIMATED_PROPERTY_DECLARATIONS(SVGMarkerElement, SVGExternalResourcesRequiredIdentifier, + SVGNames::externalResourcesRequiredAttrString, bool, + ExternalResourcesRequired, externalResourcesRequired) + + // SVGFitToViewBox + ANIMATED_PROPERTY_DECLARATIONS(SVGMarkerElement, SVGFitToViewBoxIdentifier, SVGNames::viewBoxAttrString, FloatRect, ViewBox, viewBox) + ANIMATED_PROPERTY_DECLARATIONS(SVGMarkerElement, SVGFitToViewBoxIdentifier, SVGNames::preserveAspectRatioAttrString, SVGPreserveAspectRatio, PreserveAspectRatio, preserveAspectRatio) + RefPtr<SVGResourceMarker> m_marker; }; diff --git a/WebCore/svg/SVGMaskElement.cpp b/WebCore/svg/SVGMaskElement.cpp index 6b75527..e131d34 100644 --- a/WebCore/svg/SVGMaskElement.cpp +++ b/WebCore/svg/SVGMaskElement.cpp @@ -2,8 +2,7 @@ Copyright (C) 2004, 2005, 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org> 2005 Alexander Kellett <lypanov@kde.org> - - This file is part of the KDE project + 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 @@ -55,6 +54,8 @@ SVGMaskElement::SVGMaskElement(const QualifiedName& tagName, Document* doc) , m_y(this, SVGNames::yAttr, LengthModeHeight, "-10%") , m_width(this, SVGNames::widthAttr, LengthModeWidth, "120%") , m_height(this, SVGNames::heightAttr, LengthModeHeight, "120%") + , m_href(this, XLinkNames::hrefAttr) + , m_externalResourcesRequired(this, SVGNames::externalResourcesRequiredAttr, false) { // Spec: If the x/y attribute is not specified, the effect is as if a value of "-10%" were specified. // Spec: If the width/height attribute is not specified, the effect is as if a value of "120%" were specified. @@ -128,45 +129,48 @@ void SVGMaskElement::childrenChanged(bool changedByParser, Node* beforeChange, N PassOwnPtr<ImageBuffer> SVGMaskElement::drawMaskerContent(const FloatRect& targetRect, FloatRect& maskDestRect) const { // Determine specified mask size - float xValue; - float yValue; - float widthValue; - float heightValue; - - if (maskUnits() == SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX) { - xValue = x().valueAsPercentage() * targetRect.width(); - yValue = y().valueAsPercentage() * targetRect.height(); - widthValue = width().valueAsPercentage() * targetRect.width(); - heightValue = height().valueAsPercentage() * targetRect.height(); - } else { - xValue = x().value(this); - yValue = y().value(this); - widthValue = width().value(this); - heightValue = height().value(this); - } - - IntSize imageSize(lroundf(widthValue), lroundf(heightValue)); + if (maskUnits() == SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX) + maskDestRect = FloatRect(x().valueAsPercentage() * targetRect.width(), + y().valueAsPercentage() * targetRect.height(), + width().valueAsPercentage() * targetRect.width(), + height().valueAsPercentage() * targetRect.height()); + else + maskDestRect = FloatRect(x().value(this), + y().value(this), + width().value(this), + height().value(this)); + + IntSize imageSize(lroundf(maskDestRect.width()), lroundf(maskDestRect.height())); clampImageBufferSizeToViewport(document()->view(), imageSize); - if (imageSize.width() < static_cast<int>(widthValue)) - widthValue = imageSize.width(); + if (imageSize.width() < static_cast<int>(maskDestRect.width())) + maskDestRect.setWidth(imageSize.width()); - if (imageSize.height() < static_cast<int>(heightValue)) - heightValue = imageSize.height(); + if (imageSize.height() < static_cast<int>(maskDestRect.height())) + maskDestRect.setHeight(imageSize.height()); - OwnPtr<ImageBuffer> maskImage = ImageBuffer::create(imageSize); + // FIXME: This changes color space to linearRGB, the default color space + // for masking operations in SVG. We need a switch for the other color-space + // attribute values sRGB, inherit and auto. + OwnPtr<ImageBuffer> maskImage = ImageBuffer::create(imageSize, LinearRGB); if (!maskImage) return 0; - maskDestRect = FloatRect(xValue, yValue, widthValue, heightValue); - if (maskUnits() == SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX) + FloatPoint maskContextLocation = maskDestRect.location(); + if (maskUnits() == SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX) { maskDestRect.move(targetRect.x(), targetRect.y()); + if (maskContentUnits() == SVGUnitTypes::SVG_UNIT_TYPE_USERSPACEONUSE) + maskContextLocation.move(targetRect.x(), targetRect.y()); + } else { + if (maskContentUnits() == SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX) + maskContextLocation.move(-targetRect.x(), -targetRect.y()); + } GraphicsContext* maskImageContext = maskImage->context(); ASSERT(maskImageContext); maskImageContext->save(); - maskImageContext->translate(-xValue, -yValue); + maskImageContext->translate(-maskContextLocation.x(), -maskContextLocation.y()); if (maskContentUnits() == SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX) { maskImageContext->save(); diff --git a/WebCore/svg/SVGMaskElement.h b/WebCore/svg/SVGMaskElement.h index f2b7ae5..362c730 100644 --- a/WebCore/svg/SVGMaskElement.h +++ b/WebCore/svg/SVGMaskElement.h @@ -1,8 +1,6 @@ /* Copyright (C) 2005 Alexander Kellett <lypanov@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either @@ -54,9 +52,6 @@ namespace WebCore { PassOwnPtr<ImageBuffer> drawMaskerContent(const FloatRect& targetRect, FloatRect& maskRect) const; - protected: - virtual const SVGElement* contextElement() const { return this; } - private: ANIMATED_PROPERTY_DECLARATIONS(SVGMaskElement, SVGNames::maskTagString, SVGNames::maskUnitsAttrString, int, MaskUnits, maskUnits) ANIMATED_PROPERTY_DECLARATIONS(SVGMaskElement, SVGNames::maskTagString, SVGNames::maskContentUnitsAttrString, int, MaskContentUnits, maskContentUnits) @@ -65,6 +60,14 @@ namespace WebCore { ANIMATED_PROPERTY_DECLARATIONS(SVGMaskElement, SVGNames::maskTagString, SVGNames::widthAttrString, SVGLength, Width, width) ANIMATED_PROPERTY_DECLARATIONS(SVGMaskElement, SVGNames::maskTagString, SVGNames::heightAttrString, SVGLength, Height, height) + // SVGURIReference + ANIMATED_PROPERTY_DECLARATIONS(SVGMaskElement, SVGURIReferenceIdentifier, XLinkNames::hrefAttrString, String, Href, href) + + // SVGExternalResourcesRequired + ANIMATED_PROPERTY_DECLARATIONS(SVGMaskElement, SVGExternalResourcesRequiredIdentifier, + SVGNames::externalResourcesRequiredAttrString, bool, + ExternalResourcesRequired, externalResourcesRequired) + RefPtr<SVGResourceMasker> m_masker; }; diff --git a/WebCore/svg/SVGMatrix.idl b/WebCore/svg/SVGMatrix.idl index cb8c08b..d064aa9 100644 --- a/WebCore/svg/SVGMatrix.idl +++ b/WebCore/svg/SVGMatrix.idl @@ -4,8 +4,6 @@ Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com> Copyright (C) 2006 Apple Computer, Inc. All rights reserved. - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either @@ -34,7 +32,7 @@ module svg { attribute double e; attribute double f; - [Immutable] SVGMatrix multiply(in SVGMatrix secondMatrix); + [Custom] SVGMatrix multiply(in SVGMatrix secondMatrix); [Custom] SVGMatrix inverse() raises(SVGException); [Immutable] SVGMatrix translate(in float x, in float y); diff --git a/WebCore/svg/SVGMetadataElement.cpp b/WebCore/svg/SVGMetadataElement.cpp index a18f73a..2cefc7d 100644 --- a/WebCore/svg/SVGMetadataElement.cpp +++ b/WebCore/svg/SVGMetadataElement.cpp @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005 Nikolas Zimmermann <wildfox@kde.org> 2004, 2005 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either diff --git a/WebCore/svg/SVGMetadataElement.h b/WebCore/svg/SVGMetadataElement.h index 63d0aae..afa6a8e 100644 --- a/WebCore/svg/SVGMetadataElement.h +++ b/WebCore/svg/SVGMetadataElement.h @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005 Nikolas Zimmermann <wildfox@kde.org> 2004, 2005 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either diff --git a/WebCore/svg/SVGMetadataElement.idl b/WebCore/svg/SVGMetadataElement.idl index ce65b5e..9434f4d 100644 --- a/WebCore/svg/SVGMetadataElement.idl +++ b/WebCore/svg/SVGMetadataElement.idl @@ -3,8 +3,6 @@ 2004, 2005 Rob Buis <buis@kde.org> Copyright (C) 2006 Apple Computer, Inc. All rights reserved. - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either diff --git a/WebCore/svg/SVGNumber.idl b/WebCore/svg/SVGNumber.idl index 7e4c8bd..7e1a117 100644 --- a/WebCore/svg/SVGNumber.idl +++ b/WebCore/svg/SVGNumber.idl @@ -4,8 +4,6 @@ Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com> Copyright (C) 2006 Apple Computer, Inc. All rights reserved. - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either diff --git a/WebCore/svg/SVGNumberList.cpp b/WebCore/svg/SVGNumberList.cpp index be1e895..c73e397 100644 --- a/WebCore/svg/SVGNumberList.cpp +++ b/WebCore/svg/SVGNumberList.cpp @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005, 2006 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either @@ -41,6 +39,7 @@ SVGNumberList::~SVGNumberList() void SVGNumberList::parse(const String& value) { ExceptionCode ec = 0; + clear(ec); float number = 0.0f; diff --git a/WebCore/svg/SVGNumberList.h b/WebCore/svg/SVGNumberList.h index 6cd43ff..29de27e 100644 --- a/WebCore/svg/SVGNumberList.h +++ b/WebCore/svg/SVGNumberList.h @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005, 2006 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either diff --git a/WebCore/svg/SVGPaint.cpp b/WebCore/svg/SVGPaint.cpp index 45abe69..3b39b91 100644 --- a/WebCore/svg/SVGPaint.cpp +++ b/WebCore/svg/SVGPaint.cpp @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005 Nikolas Zimmermann <wildfox@kde.org> 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either diff --git a/WebCore/svg/SVGParserUtilities.cpp b/WebCore/svg/SVGParserUtilities.cpp index 6f696e6..c05e0f8 100644 --- a/WebCore/svg/SVGParserUtilities.cpp +++ b/WebCore/svg/SVGParserUtilities.cpp @@ -509,8 +509,8 @@ bool SVGPathParser::parseSVG(const String& s, bool process) return true; // Check for remaining coordinates in the current command. - if ((*ptr == '+' || *ptr == '-' || (*ptr >= '0' && *ptr <= '9')) && - (command != 'z' && command != 'Z')) { + if ((*ptr == '+' || *ptr == '-' || *ptr == '.' || (*ptr >= '0' && *ptr <= '9')) + && (command != 'z' && command != 'Z')) { if (command == 'M') command = 'L'; else if (command == 'm') diff --git a/WebCore/svg/SVGPathElement.cpp b/WebCore/svg/SVGPathElement.cpp index 172cac1..d53fbb2 100644 --- a/WebCore/svg/SVGPathElement.cpp +++ b/WebCore/svg/SVGPathElement.cpp @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005, 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either @@ -50,6 +48,7 @@ SVGPathElement::SVGPathElement(const QualifiedName& tagName, Document* doc) , SVGLangSpace() , SVGExternalResourcesRequired() , m_pathLength(this, SVGNames::pathLengthAttr, 0.0f) + , m_externalResourcesRequired(this, SVGNames::externalResourcesRequiredAttr, false) { } @@ -70,9 +69,9 @@ FloatPoint SVGPathElement::getPointAtLength(float length) return toPathData().pointAtLength(length, ok); } -unsigned long SVGPathElement::getPathSegAtLength(float length) +unsigned long SVGPathElement::getPathSegAtLength(float length, ExceptionCode& ec) { - return pathSegList()->getPathSegAtLength(length); + return pathSegList()->getPathSegAtLength(length, ec); } PassRefPtr<SVGPathSegClosePath> SVGPathElement::createSVGPathSegClosePath() diff --git a/WebCore/svg/SVGPathElement.h b/WebCore/svg/SVGPathElement.h index 362a85b..266bfdd 100644 --- a/WebCore/svg/SVGPathElement.h +++ b/WebCore/svg/SVGPathElement.h @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005, 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either @@ -64,7 +62,7 @@ namespace WebCore { virtual bool isValid() const { return SVGTests::isValid(); } float getTotalLength(); FloatPoint getPointAtLength(float distance); - unsigned long getPathSegAtLength(float distance); + unsigned long getPathSegAtLength(float distance, ExceptionCode&); static PassRefPtr<SVGPathSegClosePath> createSVGPathSegClosePath(); static PassRefPtr<SVGPathSegMovetoAbs> createSVGPathSegMovetoAbs(float x, float y); @@ -99,13 +97,15 @@ namespace WebCore { virtual bool supportsMarkers() const { return true; } - protected: - virtual const SVGElement* contextElement() const { return this; } - private: mutable RefPtr<SVGPathSegList> m_pathSegList; ANIMATED_PROPERTY_DECLARATIONS(SVGPathElement, SVGNames::pathTagString, SVGNames::pathLengthAttrString, float, PathLength, pathLength) + + // SVGExternalResourcesRequired + ANIMATED_PROPERTY_DECLARATIONS(SVGPathElement, SVGExternalResourcesRequiredIdentifier, + SVGNames::externalResourcesRequiredAttrString, bool, + ExternalResourcesRequired, externalResourcesRequired) }; } // namespace WebCore diff --git a/WebCore/svg/SVGPathElement.idl b/WebCore/svg/SVGPathElement.idl index d66df1d..9a389c8 100644 --- a/WebCore/svg/SVGPathElement.idl +++ b/WebCore/svg/SVGPathElement.idl @@ -37,7 +37,8 @@ module svg { float getTotalLength(); SVGPoint getPointAtLength(in float distance); - unsigned long getPathSegAtLength(in float distance); + unsigned long getPathSegAtLength(in float distance) + raises(DOMException, SVGException); SVGPathSegClosePath createSVGPathSegClosePath(); diff --git a/WebCore/svg/SVGPathSeg.h b/WebCore/svg/SVGPathSeg.h index 84de92f..b88806c 100644 --- a/WebCore/svg/SVGPathSeg.h +++ b/WebCore/svg/SVGPathSeg.h @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005, 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005, 2006, 2008 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either diff --git a/WebCore/svg/SVGPathSegArc.cpp b/WebCore/svg/SVGPathSegArc.cpp index a54f057..5fb0243 100644 --- a/WebCore/svg/SVGPathSegArc.cpp +++ b/WebCore/svg/SVGPathSegArc.cpp @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005, 2006, 2008 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either diff --git a/WebCore/svg/SVGPathSegArc.h b/WebCore/svg/SVGPathSegArc.h index 8611e8a..e1cbeb1 100644 --- a/WebCore/svg/SVGPathSegArc.h +++ b/WebCore/svg/SVGPathSegArc.h @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005, 2006, 2008 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either diff --git a/WebCore/svg/SVGPathSegClosePath.cpp b/WebCore/svg/SVGPathSegClosePath.cpp index 04b711c..1f58096 100644 --- a/WebCore/svg/SVGPathSegClosePath.cpp +++ b/WebCore/svg/SVGPathSegClosePath.cpp @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005, 2006 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either diff --git a/WebCore/svg/SVGPathSegClosePath.h b/WebCore/svg/SVGPathSegClosePath.h index 190af9e..0e29bb3 100644 --- a/WebCore/svg/SVGPathSegClosePath.h +++ b/WebCore/svg/SVGPathSegClosePath.h @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005, 2006 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either diff --git a/WebCore/svg/SVGPathSegCurvetoCubic.cpp b/WebCore/svg/SVGPathSegCurvetoCubic.cpp index 14359de..6b87f55 100644 --- a/WebCore/svg/SVGPathSegCurvetoCubic.cpp +++ b/WebCore/svg/SVGPathSegCurvetoCubic.cpp @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005, 2006, 2008 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either diff --git a/WebCore/svg/SVGPathSegCurvetoCubic.h b/WebCore/svg/SVGPathSegCurvetoCubic.h index 68e3311..125b3a3 100644 --- a/WebCore/svg/SVGPathSegCurvetoCubic.h +++ b/WebCore/svg/SVGPathSegCurvetoCubic.h @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005, 2006, 2008 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either diff --git a/WebCore/svg/SVGPathSegCurvetoCubicSmooth.cpp b/WebCore/svg/SVGPathSegCurvetoCubicSmooth.cpp index 26babdb..97b256b 100644 --- a/WebCore/svg/SVGPathSegCurvetoCubicSmooth.cpp +++ b/WebCore/svg/SVGPathSegCurvetoCubicSmooth.cpp @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005, 2006, 2008 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either diff --git a/WebCore/svg/SVGPathSegCurvetoCubicSmooth.h b/WebCore/svg/SVGPathSegCurvetoCubicSmooth.h index 816ba0f..db71dac 100644 --- a/WebCore/svg/SVGPathSegCurvetoCubicSmooth.h +++ b/WebCore/svg/SVGPathSegCurvetoCubicSmooth.h @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005, 2006, 2008 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either diff --git a/WebCore/svg/SVGPathSegCurvetoQuadratic.cpp b/WebCore/svg/SVGPathSegCurvetoQuadratic.cpp index 8594fde..f3de513 100644 --- a/WebCore/svg/SVGPathSegCurvetoQuadratic.cpp +++ b/WebCore/svg/SVGPathSegCurvetoQuadratic.cpp @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005, 2006, 2008 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either diff --git a/WebCore/svg/SVGPathSegCurvetoQuadratic.h b/WebCore/svg/SVGPathSegCurvetoQuadratic.h index 1625f13..eb8b0d5 100644 --- a/WebCore/svg/SVGPathSegCurvetoQuadratic.h +++ b/WebCore/svg/SVGPathSegCurvetoQuadratic.h @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005, 2006, 2008 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either diff --git a/WebCore/svg/SVGPathSegCurvetoQuadraticSmooth.cpp b/WebCore/svg/SVGPathSegCurvetoQuadraticSmooth.cpp index 3377709..a64cbb6 100644 --- a/WebCore/svg/SVGPathSegCurvetoQuadraticSmooth.cpp +++ b/WebCore/svg/SVGPathSegCurvetoQuadraticSmooth.cpp @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005, 2006, 2008 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either diff --git a/WebCore/svg/SVGPathSegCurvetoQuadraticSmooth.h b/WebCore/svg/SVGPathSegCurvetoQuadraticSmooth.h index 3017689..00eeec7 100644 --- a/WebCore/svg/SVGPathSegCurvetoQuadraticSmooth.h +++ b/WebCore/svg/SVGPathSegCurvetoQuadraticSmooth.h @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005, 2006, 2008 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either diff --git a/WebCore/svg/SVGPathSegLineto.cpp b/WebCore/svg/SVGPathSegLineto.cpp index ac3a8bd..9ad300e 100644 --- a/WebCore/svg/SVGPathSegLineto.cpp +++ b/WebCore/svg/SVGPathSegLineto.cpp @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005, 2008 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either diff --git a/WebCore/svg/SVGPathSegLineto.h b/WebCore/svg/SVGPathSegLineto.h index 1818ad2..500d5e4 100644 --- a/WebCore/svg/SVGPathSegLineto.h +++ b/WebCore/svg/SVGPathSegLineto.h @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005, 2006, 2008 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either diff --git a/WebCore/svg/SVGPathSegLinetoHorizontal.cpp b/WebCore/svg/SVGPathSegLinetoHorizontal.cpp index 3de2cc7..f217919 100644 --- a/WebCore/svg/SVGPathSegLinetoHorizontal.cpp +++ b/WebCore/svg/SVGPathSegLinetoHorizontal.cpp @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005, 2008 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either diff --git a/WebCore/svg/SVGPathSegLinetoHorizontal.h b/WebCore/svg/SVGPathSegLinetoHorizontal.h index 84965a5..87d6475 100644 --- a/WebCore/svg/SVGPathSegLinetoHorizontal.h +++ b/WebCore/svg/SVGPathSegLinetoHorizontal.h @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005, 2006, 2008 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either diff --git a/WebCore/svg/SVGPathSegLinetoVertical.cpp b/WebCore/svg/SVGPathSegLinetoVertical.cpp index 4f667ee..341ab02 100644 --- a/WebCore/svg/SVGPathSegLinetoVertical.cpp +++ b/WebCore/svg/SVGPathSegLinetoVertical.cpp @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005, 2006, 2008 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either diff --git a/WebCore/svg/SVGPathSegLinetoVertical.h b/WebCore/svg/SVGPathSegLinetoVertical.h index 8d4ba29..844f2f2 100644 --- a/WebCore/svg/SVGPathSegLinetoVertical.h +++ b/WebCore/svg/SVGPathSegLinetoVertical.h @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005, 2006, 2008 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either diff --git a/WebCore/svg/SVGPathSegList.cpp b/WebCore/svg/SVGPathSegList.cpp index 8d6fdef..11cad14 100644 --- a/WebCore/svg/SVGPathSegList.cpp +++ b/WebCore/svg/SVGPathSegList.cpp @@ -51,15 +51,16 @@ SVGPathSegList::~SVGPathSegList() { } -unsigned SVGPathSegList::getPathSegAtLength(double) +unsigned SVGPathSegList::getPathSegAtLength(double, ExceptionCode& ec) { // FIXME : to be useful this will need to support non-normalized SVGPathSegLists - ExceptionCode ec = 0; int len = numberOfItems(); // FIXME: Eventually this will likely move to a "path applier"-like model, until then PathTraversalState is less useful as we could just use locals PathTraversalState traversalState(PathTraversalState::TraversalSegmentAtLength); for (int i = 0; i < len; ++i) { SVGPathSeg* segment = getItem(i, ec).get(); + if (ec) + return 0; float segmentLength = 0; switch (segment->pathSegType()) { case SVGPathSeg::PATHSEG_MOVETO_ABS: @@ -104,10 +105,12 @@ Path SVGPathSegList::toPathData() { // FIXME : This should also support non-normalized PathSegLists Path pathData; - ExceptionCode ec = 0; int len = numberOfItems(); + ExceptionCode ec = 0; for (int i = 0; i < len; ++i) { SVGPathSeg* segment = getItem(i, ec).get(); + if (ec) + return Path(); switch (segment->pathSegType()) { case SVGPathSeg::PATHSEG_MOVETO_ABS: { @@ -182,10 +185,14 @@ PassRefPtr<SVGPathSegList> SVGPathSegList::createAnimated(const SVGPathSegList* if (!itemCount || itemCount != toList->numberOfItems()) return 0; RefPtr<SVGPathSegList> result = create(fromList->associatedAttributeName()); - ExceptionCode ec; + ExceptionCode ec = 0; for (unsigned n = 0; n < itemCount; ++n) { SVGPathSeg* from = fromList->getItem(n, ec).get(); + if (ec) + return 0; SVGPathSeg* to = toList->getItem(n, ec).get(); + if (ec) + return 0; if (from->pathSegType() == SVGPathSeg::PATHSEG_UNKNOWN || from->pathSegType() != to->pathSegType()) return 0; RefPtr<SVGPathSeg> segment = 0; @@ -251,6 +258,8 @@ PassRefPtr<SVGPathSegList> SVGPathSegList::createAnimated(const SVGPathSegList* ASSERT_NOT_REACHED(); } result->appendItem(segment, ec); + if (ec) + return 0; } return result.release(); } diff --git a/WebCore/svg/SVGPathSegList.h b/WebCore/svg/SVGPathSegList.h index d9325ce..d2999f0 100644 --- a/WebCore/svg/SVGPathSegList.h +++ b/WebCore/svg/SVGPathSegList.h @@ -36,7 +36,7 @@ namespace WebCore { static PassRefPtr<SVGPathSegList> create(const QualifiedName& attributeName) { return adoptRef(new SVGPathSegList(attributeName)); } virtual ~SVGPathSegList(); - unsigned getPathSegAtLength(double); + unsigned getPathSegAtLength(double, ExceptionCode&); Path toPathData(); static PassRefPtr<SVGPathSegList> createAnimated(const SVGPathSegList* fromList, const SVGPathSegList* toList, float progress); diff --git a/WebCore/svg/SVGPathSegMoveto.cpp b/WebCore/svg/SVGPathSegMoveto.cpp index fc67b29..1144779 100644 --- a/WebCore/svg/SVGPathSegMoveto.cpp +++ b/WebCore/svg/SVGPathSegMoveto.cpp @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005, 2006, 2008 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either diff --git a/WebCore/svg/SVGPathSegMoveto.h b/WebCore/svg/SVGPathSegMoveto.h index 726b819..5d30633 100644 --- a/WebCore/svg/SVGPathSegMoveto.h +++ b/WebCore/svg/SVGPathSegMoveto.h @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005, 2006, 2008 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either diff --git a/WebCore/svg/SVGPatternElement.cpp b/WebCore/svg/SVGPatternElement.cpp index befca85..a10c2c2 100644 --- a/WebCore/svg/SVGPatternElement.cpp +++ b/WebCore/svg/SVGPatternElement.cpp @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005, 2006, 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either @@ -64,6 +62,10 @@ SVGPatternElement::SVGPatternElement(const QualifiedName& tagName, Document* doc , m_patternUnits(this, SVGNames::patternUnitsAttr, SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX) , m_patternContentUnits(this, SVGNames::patternContentUnitsAttr, SVGUnitTypes::SVG_UNIT_TYPE_USERSPACEONUSE) , m_patternTransform(this, SVGNames::patternTransformAttr, SVGTransformList::create(SVGNames::patternTransformAttr)) + , m_href(this, XLinkNames::hrefAttr) + , m_externalResourcesRequired(this, SVGNames::externalResourcesRequiredAttr, false) + , m_viewBox(this, SVGNames::viewBoxAttr) + , m_preserveAspectRatio(this, SVGNames::preserveAspectRatioAttr, SVGPreserveAspectRatio::create()) { } @@ -110,7 +112,7 @@ void SVGPatternElement::parseMappedAttribute(MappedAttribute* attr) return; if (SVGExternalResourcesRequired::parseMappedAttribute(attr)) return; - if (SVGFitToViewBox::parseMappedAttribute(attr)) + if (SVGFitToViewBox::parseMappedAttribute(document(), attr)) return; SVGStyledElement::parseMappedAttribute(attr); @@ -195,7 +197,7 @@ void SVGPatternElement::buildPattern(const FloatRect& targetRect) const } } - TransformationMatrix viewBoxCTM = viewBoxToViewTransform(patternBoundaries.width(), patternBoundaries.height()); + TransformationMatrix viewBoxCTM = viewBoxToViewTransform(viewBox(), preserveAspectRatio(), patternBoundaries.width(), patternBoundaries.height()); FloatRect patternBoundariesIncludingOverflow = patternBoundaries; // Apply objectBoundingBoxMode fixup for patternContentUnits, if viewBox is not set. diff --git a/WebCore/svg/SVGPatternElement.h b/WebCore/svg/SVGPatternElement.h index 2e6399c..6a679af 100644 --- a/WebCore/svg/SVGPatternElement.h +++ b/WebCore/svg/SVGPatternElement.h @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005, 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either @@ -58,9 +56,6 @@ namespace WebCore { virtual RenderObject* createRenderer(RenderArena*, RenderStyle*); virtual SVGResource* canvasResource(); - protected: - virtual const SVGElement* contextElement() const { return this; } - private: ANIMATED_PROPERTY_DECLARATIONS(SVGPatternElement, SVGNames::patternTagString, SVGNames::xAttrString, SVGLength, X, x) ANIMATED_PROPERTY_DECLARATIONS(SVGPatternElement, SVGNames::patternTagString, SVGNames::yAttrString, SVGLength, Y, y) @@ -70,6 +65,18 @@ namespace WebCore { ANIMATED_PROPERTY_DECLARATIONS(SVGPatternElement, SVGNames::patternTagString, SVGNames::patternContentUnitsAttrString, int, PatternContentUnits, patternContentUnits) ANIMATED_PROPERTY_DECLARATIONS(SVGPatternElement, SVGNames::patternTagString, SVGNames::patternTransformAttrString, SVGTransformList, PatternTransform, patternTransform) + // SVGURIReference + ANIMATED_PROPERTY_DECLARATIONS(SVGPatternElement, SVGURIReferenceIdentifier, XLinkNames::hrefAttrString, String, Href, href) + + // SVGExternalResourcesRequired + ANIMATED_PROPERTY_DECLARATIONS(SVGPatternElement, SVGExternalResourcesRequiredIdentifier, + SVGNames::externalResourcesRequiredAttrString, bool, + ExternalResourcesRequired, externalResourcesRequired) + + // SVGPatternElement + ANIMATED_PROPERTY_DECLARATIONS(SVGPatternElement, SVGFitToViewBoxIdentifier, SVGNames::viewBoxAttrString, FloatRect, ViewBox, viewBox) + ANIMATED_PROPERTY_DECLARATIONS(SVGPatternElement, SVGFitToViewBoxIdentifier, SVGNames::preserveAspectRatioAttrString, SVGPreserveAspectRatio, PreserveAspectRatio, preserveAspectRatio) + mutable RefPtr<SVGPaintServerPattern> m_resource; private: diff --git a/WebCore/svg/SVGPoint.idl b/WebCore/svg/SVGPoint.idl index 1a0d227..1bf96f8 100644 --- a/WebCore/svg/SVGPoint.idl +++ b/WebCore/svg/SVGPoint.idl @@ -4,8 +4,6 @@ Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com> Copyright (C) 2006 Apple Computer, Inc. All rights reserved. - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either diff --git a/WebCore/svg/SVGPointList.cpp b/WebCore/svg/SVGPointList.cpp index c5a6dd2..02a67ed 100644 --- a/WebCore/svg/SVGPointList.cpp +++ b/WebCore/svg/SVGPointList.cpp @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005, 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either diff --git a/WebCore/svg/SVGPointList.h b/WebCore/svg/SVGPointList.h index d443e2d..cc12366 100644 --- a/WebCore/svg/SVGPointList.h +++ b/WebCore/svg/SVGPointList.h @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005, 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either diff --git a/WebCore/svg/SVGPolyElement.cpp b/WebCore/svg/SVGPolyElement.cpp index db39c52..61725b5 100644 --- a/WebCore/svg/SVGPolyElement.cpp +++ b/WebCore/svg/SVGPolyElement.cpp @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005, 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either @@ -42,6 +40,7 @@ SVGPolyElement::SVGPolyElement(const QualifiedName& tagName, Document* doc) , SVGLangSpace() , SVGExternalResourcesRequired() , SVGAnimatedPoints() + , m_externalResourcesRequired(this, SVGNames::externalResourcesRequiredAttr, false) { } @@ -117,7 +116,7 @@ void SVGPolyElement::updateAnimatedSVGAttribute(const String& name) const if (name == SVGNames::pointsAttr.localName()) { m_synchronizingSVGAttributes = true; - synchronizeProperty<SVGPolyElement, SVGPointList*>(this, SVGNames::pointsAttr, m_points.get()); + PropertySynchronizer<SVGPolyElement, SVGPointList*, true>::synchronize(this, SVGNames::pointsAttr, m_points.get()); setSynchronizedSVGAttributes(true); m_synchronizingSVGAttributes = false; return; diff --git a/WebCore/svg/SVGPolyElement.h b/WebCore/svg/SVGPolyElement.h index 8dd16cd..2ffd150 100644 --- a/WebCore/svg/SVGPolyElement.h +++ b/WebCore/svg/SVGPolyElement.h @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005, 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either @@ -54,10 +52,12 @@ namespace WebCore { virtual void updateAnimatedSVGAttribute(const String&) const; - protected: - virtual const SVGElement* contextElement() const { return this; } - private: + // SVGExternalResourcesRequired + ANIMATED_PROPERTY_DECLARATIONS(SVGPolyElement, SVGExternalResourcesRequiredIdentifier, + SVGNames::externalResourcesRequiredAttrString, bool, + ExternalResourcesRequired, externalResourcesRequired) + mutable RefPtr<SVGPointList> m_points; }; diff --git a/WebCore/svg/SVGPolygonElement.cpp b/WebCore/svg/SVGPolygonElement.cpp index 95513e4..a4a62af 100644 --- a/WebCore/svg/SVGPolygonElement.cpp +++ b/WebCore/svg/SVGPolygonElement.cpp @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005, 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005, 2006 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either diff --git a/WebCore/svg/SVGPolygonElement.h b/WebCore/svg/SVGPolygonElement.h index 7afb553..fa6eef6 100644 --- a/WebCore/svg/SVGPolygonElement.h +++ b/WebCore/svg/SVGPolygonElement.h @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005, 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005, 2006 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either diff --git a/WebCore/svg/SVGPolylineElement.cpp b/WebCore/svg/SVGPolylineElement.cpp index 9ea136e..899c072 100644 --- a/WebCore/svg/SVGPolylineElement.cpp +++ b/WebCore/svg/SVGPolylineElement.cpp @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005, 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005, 2006 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either diff --git a/WebCore/svg/SVGPolylineElement.h b/WebCore/svg/SVGPolylineElement.h index d43dbbe..e070c9f 100644 --- a/WebCore/svg/SVGPolylineElement.h +++ b/WebCore/svg/SVGPolylineElement.h @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005, 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005, 2006 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either diff --git a/WebCore/svg/SVGPreserveAspectRatio.cpp b/WebCore/svg/SVGPreserveAspectRatio.cpp index 5793976..e6452c3 100644 --- a/WebCore/svg/SVGPreserveAspectRatio.cpp +++ b/WebCore/svg/SVGPreserveAspectRatio.cpp @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either @@ -180,7 +178,7 @@ TransformationMatrix SVGPreserveAspectRatio::getCTM(double logicX, double logicY if (align() == SVG_PRESERVEASPECTRATIO_NONE) { temp.scaleNonUniform(physWidth / logicWidth, physHeight / logicHeight); temp.translate(-logicX, -logicY); - } else if (vpar < svgar && (meetOrSlice() == SVG_MEETORSLICE_MEET) || vpar >= svgar && (meetOrSlice() == SVG_MEETORSLICE_SLICE)) { + } else if ((vpar < svgar && (meetOrSlice() == SVG_MEETORSLICE_MEET)) || (vpar >= svgar && (meetOrSlice() == SVG_MEETORSLICE_SLICE))) { temp.scaleNonUniform(physHeight / logicHeight, physHeight / logicHeight); if (align() == SVG_PRESERVEASPECTRATIO_XMINYMIN || align() == SVG_PRESERVEASPECTRATIO_XMINYMID || align() == SVG_PRESERVEASPECTRATIO_XMINYMAX) diff --git a/WebCore/svg/SVGPreserveAspectRatio.h b/WebCore/svg/SVGPreserveAspectRatio.h index a0100ff..18a89dd 100644 --- a/WebCore/svg/SVGPreserveAspectRatio.h +++ b/WebCore/svg/SVGPreserveAspectRatio.h @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either diff --git a/WebCore/svg/SVGRadialGradientElement.cpp b/WebCore/svg/SVGRadialGradientElement.cpp index 23a8579..270de6f 100644 --- a/WebCore/svg/SVGRadialGradientElement.cpp +++ b/WebCore/svg/SVGRadialGradientElement.cpp @@ -92,29 +92,53 @@ void SVGRadialGradientElement::buildGradient() const RefPtr<SVGPaintServerRadialGradient> radialGradient = WTF::static_pointer_cast<SVGPaintServerRadialGradient>(m_resource); - double adjustedFocusX = attributes.fx(); - double adjustedFocusY = attributes.fy(); + 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); + } - double fdx = attributes.fx() - attributes.cx(); - double fdy = attributes.fy() - attributes.cy(); + FloatPoint adjustedFocalPoint = focalPoint; + float dfx = focalPoint.x() - centerPoint.x(); + float dfy = focalPoint.y() - centerPoint.y(); // Spec: If (fx, fy) lies outside the circle defined by (cx, cy) and // r, set (fx, fy) to the point of intersection of the line through // (fx, fy) and the circle. - if (sqrt(fdx * fdx + fdy * fdy) > attributes.r()) { - double angle = atan2(attributes.fy() * 100.0, attributes.fx() * 100.0); - adjustedFocusX = cos(angle) * attributes.r(); - adjustedFocusY = sin(angle) * attributes.r(); + if (sqrt(dfx * dfx + dfy * dfy) >= radius) { + float angle = atan2f(dfx, dfy); + + // The maximum deviation of 0.2% is needed on Cairo, since Cairo + // is working with fixed point numbers. +#if PLATFORM(CAIRO) + if (focalPoint.x() < centerPoint.x()) + dfx = cosf(angle) * radius + 0.002f; + else + dfx = cosf(angle) * radius - 0.002f; + if (focalPoint.y() < centerPoint.y()) + dfy = sinf(angle) * radius + 0.002f; + else + dfy = sinf(angle) * radius - 0.002f; +#else + dfx = cosf(angle) * radius; + dfy = sinf(angle) * radius; +#endif + + adjustedFocalPoint = FloatPoint(dfx + centerPoint.x(), dfy + centerPoint.y()); } - FloatPoint focalPoint = FloatPoint::narrowPrecision(attributes.fx(), attributes.fy()); - FloatPoint centerPoint = FloatPoint::narrowPrecision(attributes.cx(), attributes.cy()); - RefPtr<Gradient> gradient = Gradient::create( - FloatPoint::narrowPrecision(adjustedFocusX, adjustedFocusY), + adjustedFocalPoint, 0.f, // SVG does not support a "focus radius" centerPoint, - narrowPrecisionToFloat(attributes.r())); + radius); gradient->setSpreadMethod(attributes.spreadMethod()); Vector<SVGGradientStop> stops = attributes.stops(); @@ -134,7 +158,7 @@ void SVGRadialGradientElement::buildGradient() const radialGradient->setGradientTransform(attributes.gradientTransform()); radialGradient->setGradientCenter(centerPoint); radialGradient->setGradientFocal(focalPoint); - radialGradient->setGradientRadius(narrowPrecisionToFloat(attributes.r())); + radialGradient->setGradientRadius(radius); radialGradient->setGradientStops(attributes.stops()); } @@ -166,19 +190,19 @@ RadialGradientAttributes SVGRadialGradientElement::collectGradientProperties() c const SVGRadialGradientElement* radial = static_cast<const SVGRadialGradientElement*>(current); if (!attributes.hasCx() && current->hasAttribute(SVGNames::cxAttr)) - attributes.setCx(radial->cx().valueAsPercentage()); + attributes.setCx(radial->cx()); if (!attributes.hasCy() && current->hasAttribute(SVGNames::cyAttr)) - attributes.setCy(radial->cy().valueAsPercentage()); + attributes.setCy(radial->cy()); if (!attributes.hasR() && current->hasAttribute(SVGNames::rAttr)) - attributes.setR(radial->r().valueAsPercentage()); + attributes.setR(radial->r()); if (!attributes.hasFx() && current->hasAttribute(SVGNames::fxAttr)) - attributes.setFx(radial->fx().valueAsPercentage()); + attributes.setFx(radial->fx()); if (!attributes.hasFy() && current->hasAttribute(SVGNames::fyAttr)) - attributes.setFy(radial->fy().valueAsPercentage()); + attributes.setFy(radial->fy()); } processedGradients.add(current); diff --git a/WebCore/svg/SVGRadialGradientElement.h b/WebCore/svg/SVGRadialGradientElement.h index 6813e65..61f56f5 100644 --- a/WebCore/svg/SVGRadialGradientElement.h +++ b/WebCore/svg/SVGRadialGradientElement.h @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005, 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005, 2006 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either diff --git a/WebCore/svg/SVGRect.idl b/WebCore/svg/SVGRect.idl index 7fdce65..0278030 100644 --- a/WebCore/svg/SVGRect.idl +++ b/WebCore/svg/SVGRect.idl @@ -4,8 +4,6 @@ Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com> Copyright (C) 2006 Apple Computer, Inc. All rights reserved. - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either diff --git a/WebCore/svg/SVGRectElement.cpp b/WebCore/svg/SVGRectElement.cpp index bfb6205..f9b04c8 100644 --- a/WebCore/svg/SVGRectElement.cpp +++ b/WebCore/svg/SVGRectElement.cpp @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005, 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either @@ -43,6 +41,7 @@ SVGRectElement::SVGRectElement(const QualifiedName& tagName, Document *doc) , m_height(this, SVGNames::heightAttr, LengthModeHeight) , m_rx(this, SVGNames::rxAttr, LengthModeWidth) , m_ry(this, SVGNames::ryAttr, LengthModeHeight) + , m_externalResourcesRequired(this, SVGNames::externalResourcesRequiredAttr, false) { } diff --git a/WebCore/svg/SVGRectElement.h b/WebCore/svg/SVGRectElement.h index 2937c23..a4d859e 100644 --- a/WebCore/svg/SVGRectElement.h +++ b/WebCore/svg/SVGRectElement.h @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005, 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005, 2006 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either @@ -47,7 +45,6 @@ namespace WebCore { virtual Path toPathData() const; protected: - virtual const SVGElement* contextElement() const { return this; } virtual bool hasRelativeValues() const; private: @@ -57,6 +54,11 @@ namespace WebCore { ANIMATED_PROPERTY_DECLARATIONS(SVGRectElement, SVGNames::rectTagString, SVGNames::heightAttrString, SVGLength, Height, height) ANIMATED_PROPERTY_DECLARATIONS(SVGRectElement, SVGNames::rectTagString, SVGNames::rxAttrString, SVGLength, Rx, rx) ANIMATED_PROPERTY_DECLARATIONS(SVGRectElement, SVGNames::rectTagString, SVGNames::ryAttrString, SVGLength, Ry, ry) + + // SVGExternalResourcesRequired + ANIMATED_PROPERTY_DECLARATIONS(SVGRectElement, SVGExternalResourcesRequiredIdentifier, + SVGNames::externalResourcesRequiredAttrString, bool, + ExternalResourcesRequired, externalResourcesRequired) }; } // namespace WebCore diff --git a/WebCore/svg/SVGRenderingIntent.h b/WebCore/svg/SVGRenderingIntent.h index 699f228..f4bfa6a 100644 --- a/WebCore/svg/SVGRenderingIntent.h +++ b/WebCore/svg/SVGRenderingIntent.h @@ -1,8 +1,6 @@ /* Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either diff --git a/WebCore/svg/SVGSVGElement.cpp b/WebCore/svg/SVGSVGElement.cpp index fcecd8c..2d5008b 100644 --- a/WebCore/svg/SVGSVGElement.cpp +++ b/WebCore/svg/SVGSVGElement.cpp @@ -66,7 +66,10 @@ SVGSVGElement::SVGSVGElement(const QualifiedName& tagName, Document* doc) , m_x(this, SVGNames::xAttr, LengthModeWidth) , m_y(this, SVGNames::yAttr, LengthModeHeight) , m_width(this, SVGNames::widthAttr, LengthModeWidth, "100%") - , m_height(this, SVGNames::heightAttr, LengthModeHeight, "100%") + , m_height(this, SVGNames::heightAttr, LengthModeHeight, "100%") + , m_externalResourcesRequired(this, SVGNames::externalResourcesRequiredAttr, false) + , m_viewBox(this, SVGNames::viewBoxAttr) + , m_preserveAspectRatio(this, SVGNames::preserveAspectRatioAttr, SVGPreserveAspectRatio::create()) , m_useCurrentView(false) , m_timeContainer(SMILTimeContainer::create(this)) , m_viewSpec(0) @@ -261,7 +264,7 @@ void SVGSVGElement::parseMappedAttribute(MappedAttribute* attr) return; if (SVGExternalResourcesRequired::parseMappedAttribute(attr)) return; - if (SVGFitToViewBox::parseMappedAttribute(attr)) + if (SVGFitToViewBox::parseMappedAttribute(document(), attr)) return; if (SVGZoomAndPan::parseMappedAttribute(attr)) return; @@ -307,15 +310,14 @@ void SVGSVGElement::svgAttributeChanged(const QualifiedName& attrName) renderer()->setNeedsLayout(true); } -unsigned long SVGSVGElement::suspendRedraw(unsigned long /* max_wait_milliseconds */) +unsigned SVGSVGElement::suspendRedraw(unsigned /* maxWaitMilliseconds */) { // FIXME: Implement me (see bug 11275) return 0; } -void SVGSVGElement::unsuspendRedraw(unsigned long /* suspend_handle_id */, ExceptionCode&) +void SVGSVGElement::unsuspendRedraw(unsigned /* suspendHandleId */) { - // if suspend_handle_id is not found, throw exception // FIXME: Implement me (see bug 11275) } @@ -514,13 +516,8 @@ TransformationMatrix SVGSVGElement::viewBoxToViewTransform(float viewWidth, floa viewBoxRect = currentView()->viewBox(); } else viewBoxRect = viewBox(); - if (!viewBoxRect.width() || !viewBoxRect.height()) - return TransformationMatrix(); - - TransformationMatrix ctm = preserveAspectRatio()->getCTM(viewBoxRect.x(), - viewBoxRect.y(), viewBoxRect.width(), viewBoxRect.height(), - 0, 0, viewWidth, viewHeight); + TransformationMatrix ctm = SVGFitToViewBox::viewBoxToViewTransform(viewBoxRect, preserveAspectRatio(), viewWidth, viewHeight); if (useCurrentView() && currentView()) return currentView()->transform()->concatenate().matrix() * ctm; diff --git a/WebCore/svg/SVGSVGElement.h b/WebCore/svg/SVGSVGElement.h index f92ed72..f30e8f6 100644 --- a/WebCore/svg/SVGSVGElement.h +++ b/WebCore/svg/SVGSVGElement.h @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either @@ -94,8 +92,8 @@ namespace WebCore { float getCurrentTime() const; void setCurrentTime(float seconds); - unsigned long suspendRedraw(unsigned long max_wait_milliseconds); - void unsuspendRedraw(unsigned long suspend_handle_id, ExceptionCode&); + unsigned suspendRedraw(unsigned maxWaitMilliseconds); + void unsuspendRedraw(unsigned suspendHandleId); void unsuspendRedrawAll(); void forceRedraw(); @@ -128,13 +126,11 @@ namespace WebCore { virtual void svgAttributeChanged(const QualifiedName&); - virtual TransformationMatrix viewBoxToViewTransform(float viewWidth, float viewHeight) const; + TransformationMatrix viewBoxToViewTransform(float viewWidth, float viewHeight) const; void inheritViewAttributes(SVGViewElement*); protected: - virtual const SVGElement* contextElement() const { return this; } - friend class RenderSVGRoot; friend class RenderSVGViewportContainer; @@ -148,6 +144,15 @@ namespace WebCore { ANIMATED_PROPERTY_DECLARATIONS(SVGSVGElement, SVGNames::svgTagString, SVGNames::widthAttrString, SVGLength, Width, width) ANIMATED_PROPERTY_DECLARATIONS(SVGSVGElement, SVGNames::svgTagString, SVGNames::heightAttrString, SVGLength, Height, height) + // SVGExternalResourcesRequired + ANIMATED_PROPERTY_DECLARATIONS(SVGSVGElement, SVGExternalResourcesRequiredIdentifier, + SVGNames::externalResourcesRequiredAttrString, bool, + ExternalResourcesRequired, externalResourcesRequired) + + // SVGFitToViewBox + ANIMATED_PROPERTY_DECLARATIONS(SVGSVGElement, SVGFitToViewBoxIdentifier, SVGNames::viewBoxAttrString, FloatRect, ViewBox, viewBox) + ANIMATED_PROPERTY_DECLARATIONS(SVGSVGElement, SVGFitToViewBoxIdentifier, SVGNames::preserveAspectRatioAttrString, SVGPreserveAspectRatio, PreserveAspectRatio, preserveAspectRatio) + virtual void documentWillBecomeInactive(); virtual void documentDidBecomeActive(); diff --git a/WebCore/svg/SVGSVGElement.idl b/WebCore/svg/SVGSVGElement.idl index 32b4e3c..46a17b0 100644 --- a/WebCore/svg/SVGSVGElement.idl +++ b/WebCore/svg/SVGSVGElement.idl @@ -4,8 +4,6 @@ Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com> Copyright (C) 2006 Apple Computer, Inc. All rights reserved. - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either @@ -56,8 +54,7 @@ module svg { readonly attribute SVGPoint currentTranslate; unsigned long suspendRedraw(in unsigned long maxWaitMilliseconds); - void unsuspendRedraw(in unsigned long suspendHandleId) - setter raises(DOMException); + void unsuspendRedraw(in unsigned long suspendHandleId); void unsuspendRedrawAll(); void forceRedraw(); void pauseAnimations(); diff --git a/WebCore/svg/SVGScriptElement.cpp b/WebCore/svg/SVGScriptElement.cpp index 2ecf912..7be72dc 100644 --- a/WebCore/svg/SVGScriptElement.cpp +++ b/WebCore/svg/SVGScriptElement.cpp @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005, 2007 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either @@ -26,6 +24,7 @@ #include "SVGScriptElement.h" #include "Document.h" +#include "Event.h" #include "EventNames.h" #include "MappedAttribute.h" #include "SVGNames.h" @@ -36,6 +35,8 @@ SVGScriptElement::SVGScriptElement(const QualifiedName& tagName, Document* doc, : SVGElement(tagName, doc) , SVGURIReference() , SVGExternalResourcesRequired() + , m_href(this, XLinkNames::hrefAttr) + , m_externalResourcesRequired(this, SVGNames::externalResourcesRequiredAttr, false) , m_data(this, this) { m_data.setCreatedByParser(createdByParser); @@ -209,7 +210,7 @@ void SVGScriptElement::dispatchLoadEvent() void SVGScriptElement::dispatchErrorEvent() { - dispatchEvent(eventNames().errorEvent, true, false); + dispatchEvent(Event::create(eventNames().errorEvent, true, false)); } } diff --git a/WebCore/svg/SVGScriptElement.h b/WebCore/svg/SVGScriptElement.h index f2efc8e..699c535 100644 --- a/WebCore/svg/SVGScriptElement.h +++ b/WebCore/svg/SVGScriptElement.h @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005, 2007 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either @@ -60,7 +58,6 @@ namespace WebCore { virtual bool shouldExecuteAsJavaScript() const { return false; } protected: - virtual const SVGElement* contextElement() const { return this; } virtual bool haveLoadedRequiredResources(); virtual String sourceAttributeValue() const; @@ -73,6 +70,15 @@ namespace WebCore { virtual void dispatchErrorEvent(); private: + // SVGURIReference + ANIMATED_PROPERTY_DECLARATIONS(SVGScriptElement, SVGURIReferenceIdentifier, XLinkNames::hrefAttrString, String, Href, href) + + // SVGExternalResourcesRequired + ANIMATED_PROPERTY_DECLARATIONS(SVGScriptElement, SVGExternalResourcesRequiredIdentifier, + SVGNames::externalResourcesRequiredAttrString, bool, + ExternalResourcesRequired, externalResourcesRequired) + + private: ScriptElementData m_data; String m_type; }; diff --git a/WebCore/svg/SVGSetElement.cpp b/WebCore/svg/SVGSetElement.cpp index 5800580..a6e81b3 100644 --- a/WebCore/svg/SVGSetElement.cpp +++ b/WebCore/svg/SVGSetElement.cpp @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005 Nikolas Zimmermann <wildfox@kde.org> 2004, 2005 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either diff --git a/WebCore/svg/SVGSetElement.h b/WebCore/svg/SVGSetElement.h index fda6919..7d0eced 100644 --- a/WebCore/svg/SVGSetElement.h +++ b/WebCore/svg/SVGSetElement.h @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005 Nikolas Zimmermann <wildfox@kde.org> 2004, 2005 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either diff --git a/WebCore/svg/SVGStopElement.cpp b/WebCore/svg/SVGStopElement.cpp index 51582d7..0549031 100644 --- a/WebCore/svg/SVGStopElement.cpp +++ b/WebCore/svg/SVGStopElement.cpp @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005, 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either diff --git a/WebCore/svg/SVGStopElement.h b/WebCore/svg/SVGStopElement.h index bbfd770..5d14a40 100644 --- a/WebCore/svg/SVGStopElement.h +++ b/WebCore/svg/SVGStopElement.h @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005, 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005, 2006 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either @@ -24,6 +22,7 @@ #define SVGStopElement_h #if ENABLE(SVG) +#include "SVGNames.h" #include "SVGStyledElement.h" namespace WebCore { @@ -33,13 +32,13 @@ namespace WebCore { SVGStopElement(const QualifiedName&, Document*); virtual ~SVGStopElement(); + private: virtual bool isGradientStop() const { return true; } virtual void parseMappedAttribute(MappedAttribute*); virtual RenderObject* createRenderer(RenderArena*, RenderStyle*); - private: ANIMATED_PROPERTY_DECLARATIONS(SVGStopElement, SVGNames::stopTagString, SVGNames::offsetAttrString, float, Offset, offset) }; diff --git a/WebCore/svg/SVGStringList.cpp b/WebCore/svg/SVGStringList.cpp index 9a23a4a..70bfad8 100644 --- a/WebCore/svg/SVGStringList.cpp +++ b/WebCore/svg/SVGStringList.cpp @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005, 2006 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either diff --git a/WebCore/svg/SVGStringList.h b/WebCore/svg/SVGStringList.h index 1cbe9d2..2fca6bc 100644 --- a/WebCore/svg/SVGStringList.h +++ b/WebCore/svg/SVGStringList.h @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005, 2006 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either diff --git a/WebCore/svg/SVGStylable.cpp b/WebCore/svg/SVGStylable.cpp index 5d063c3..c72843a 100644 --- a/WebCore/svg/SVGStylable.cpp +++ b/WebCore/svg/SVGStylable.cpp @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005, 2006 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either diff --git a/WebCore/svg/SVGStylable.h b/WebCore/svg/SVGStylable.h index ade5c2f..7e13d35 100644 --- a/WebCore/svg/SVGStylable.h +++ b/WebCore/svg/SVGStylable.h @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either diff --git a/WebCore/svg/SVGStyleElement.cpp b/WebCore/svg/SVGStyleElement.cpp index 72f70e6..0a2195a 100644 --- a/WebCore/svg/SVGStyleElement.cpp +++ b/WebCore/svg/SVGStyleElement.cpp @@ -2,8 +2,7 @@ Copyright (C) 2004, 2005 Nikolas Zimmermann <wildfox@kde.org> 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org> Copyright (C) 2006 Apple Computer, Inc. - - This file is part of the KDE project + Copyright (C) 2009 Cameron McCormack <cam@mcc.id.au> This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public @@ -29,31 +28,21 @@ #include "CSSStyleSheet.h" #include "Document.h" #include "ExceptionCode.h" -#include "HTMLNames.h" #include "MappedAttribute.h" -#include "XMLNames.h" +#include "SVGNames.h" #include <wtf/StdLibExtras.h> namespace WebCore { -using namespace HTMLNames; +using namespace SVGNames; SVGStyleElement::SVGStyleElement(const QualifiedName& tagName, Document* doc, bool createdByParser) : SVGElement(tagName, doc) + , SVGLangSpace() , m_createdByParser(createdByParser) { } -const AtomicString& SVGStyleElement::xmlspace() const -{ - return getAttribute(XMLNames::spaceAttr); -} - -void SVGStyleElement::setXmlspace(const AtomicString&, ExceptionCode& ec) -{ - ec = NO_MODIFICATION_ALLOWED_ERR; -} - const AtomicString& SVGStyleElement::type() const { DEFINE_STATIC_LOCAL(const AtomicString, defaultValue, ("text/css")); @@ -61,9 +50,9 @@ const AtomicString& SVGStyleElement::type() const return n.isNull() ? defaultValue : n; } -void SVGStyleElement::setType(const AtomicString&, ExceptionCode& ec) +void SVGStyleElement::setType(const AtomicString& type, ExceptionCode& ec) { - ec = NO_MODIFICATION_ALLOWED_ERR; + setAttribute(typeAttr, type, ec); } const AtomicString& SVGStyleElement::media() const @@ -73,9 +62,9 @@ const AtomicString& SVGStyleElement::media() const return n.isNull() ? defaultValue : n; } -void SVGStyleElement::setMedia(const AtomicString&, ExceptionCode& ec) +void SVGStyleElement::setMedia(const AtomicString& media, ExceptionCode& ec) { - ec = NO_MODIFICATION_ALLOWED_ERR; + setAttribute(mediaAttr, media, ec); } String SVGStyleElement::title() const @@ -83,17 +72,20 @@ String SVGStyleElement::title() const return getAttribute(titleAttr); } -void SVGStyleElement::setTitle(const AtomicString&, ExceptionCode& ec) +void SVGStyleElement::setTitle(const AtomicString& title, ExceptionCode& ec) { - ec = NO_MODIFICATION_ALLOWED_ERR; + setAttribute(titleAttr, title, ec); } void SVGStyleElement::parseMappedAttribute(MappedAttribute* attr) { if (attr->name() == titleAttr && m_sheet) m_sheet->setTitle(attr->value()); - else + else { + if (SVGLangSpace::parseMappedAttribute(attr)) + return; SVGElement::parseMappedAttribute(attr); + } } void SVGStyleElement::finishParsingChildren() diff --git a/WebCore/svg/SVGStyleElement.h b/WebCore/svg/SVGStyleElement.h index 48afdb1..de37f5d 100644 --- a/WebCore/svg/SVGStyleElement.h +++ b/WebCore/svg/SVGStyleElement.h @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005 Nikolas Zimmermann <wildfox@kde.org> 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either @@ -25,11 +23,14 @@ #if ENABLE(SVG) #include <SVGElement.h> +#include "SVGLangSpace.h" #include "StyleElement.h" namespace WebCore { - class SVGStyleElement : public SVGElement, public StyleElement { + class SVGStyleElement : public SVGElement, + public SVGLangSpace, + public StyleElement { public: SVGStyleElement(const QualifiedName&, Document*, bool createdByParser); @@ -41,10 +42,6 @@ namespace WebCore { virtual void finishParsingChildren(); - // 'SVGStyleElement' functions - const AtomicString& xmlspace() const; - void setXmlspace(const AtomicString&, ExceptionCode&); - virtual bool sheetLoaded(); virtual const AtomicString& type() const; diff --git a/WebCore/svg/SVGStyleElement.idl b/WebCore/svg/SVGStyleElement.idl index e87b79f..e47ed1d 100644 --- a/WebCore/svg/SVGStyleElement.idl +++ b/WebCore/svg/SVGStyleElement.idl @@ -26,9 +26,8 @@ module svg { - interface [Conditional=SVG] SVGStyleElement : SVGElement { - attribute core::DOMString xmlspace - setter raises(DOMException); + interface [Conditional=SVG] SVGStyleElement : SVGElement, + SVGLangSpace { attribute core::DOMString type setter raises(DOMException); attribute core::DOMString media diff --git a/WebCore/svg/SVGStyledElement.cpp b/WebCore/svg/SVGStyledElement.cpp index 98b6459..6960519 100644 --- a/WebCore/svg/SVGStyledElement.cpp +++ b/WebCore/svg/SVGStyledElement.cpp @@ -245,20 +245,23 @@ PassRefPtr<CSSValue> SVGStyledElement::getPresentationAttribute(const String& na if (!mappedAttributes()) return 0; - Attribute* attr = mappedAttributes()->getAttributeItem(QualifiedName(nullAtom, name, nullAtom)); + QualifiedName attributeName(nullAtom, name, nullAtom); + Attribute* attr = mappedAttributes()->getAttributeItem(attributeName); if (!attr || !attr->isMappedAttribute() || !attr->style()) return 0; MappedAttribute* cssSVGAttr = static_cast<MappedAttribute*>(attr); - - // FIXME: Is it possible that the style will not be shared at the time this - // is called, but a later addition to the DOM will make it shared? - if (!cssSVGAttr->style()->hasOneRef()) { + // This function returns a pointer to a CSSValue which can be mutated from JavaScript. + // If the associated MappedAttribute uses the same CSSMappedAttributeDeclaration + // as StyledElement's mappedAttributeDecls cache, create a new CSSMappedAttributeDeclaration + // before returning so that any modifications to the CSSValue will not affect other attributes. + MappedAttributeEntry entry; + mapToEntry(attributeName, entry); + if (getMappedAttributeDecl(entry, cssSVGAttr) == cssSVGAttr->decl()) { cssSVGAttr->setDecl(0); int propId = SVGStyledElement::cssPropertyIdForSVGAttributeName(cssSVGAttr->name()); addCSSProperty(cssSVGAttr, propId, cssSVGAttr->value()); } - return cssSVGAttr->style()->getPropertyCSSValue(name); } diff --git a/WebCore/svg/SVGStyledElement.h b/WebCore/svg/SVGStyledElement.h index e21db97..9cc21c5 100644 --- a/WebCore/svg/SVGStyledElement.h +++ b/WebCore/svg/SVGStyledElement.h @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005, 2006, 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005, 2007 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either diff --git a/WebCore/svg/SVGStyledLocatableElement.cpp b/WebCore/svg/SVGStyledLocatableElement.cpp index 39ecb7d..a48082c 100644 --- a/WebCore/svg/SVGStyledLocatableElement.cpp +++ b/WebCore/svg/SVGStyledLocatableElement.cpp @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005, 2006 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either diff --git a/WebCore/svg/SVGStyledLocatableElement.h b/WebCore/svg/SVGStyledLocatableElement.h index 41a034d..3902c73 100644 --- a/WebCore/svg/SVGStyledLocatableElement.h +++ b/WebCore/svg/SVGStyledLocatableElement.h @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005, 2006 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either diff --git a/WebCore/svg/SVGStyledTransformableElement.cpp b/WebCore/svg/SVGStyledTransformableElement.cpp index b7cf979..4e97c83 100644 --- a/WebCore/svg/SVGStyledTransformableElement.cpp +++ b/WebCore/svg/SVGStyledTransformableElement.cpp @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005, 2006 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either diff --git a/WebCore/svg/SVGStyledTransformableElement.h b/WebCore/svg/SVGStyledTransformableElement.h index cf5713e..3145e6f 100644 --- a/WebCore/svg/SVGStyledTransformableElement.h +++ b/WebCore/svg/SVGStyledTransformableElement.h @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either diff --git a/WebCore/svg/SVGSwitchElement.cpp b/WebCore/svg/SVGSwitchElement.cpp index 2867d00..6d0f5d1 100644 --- a/WebCore/svg/SVGSwitchElement.cpp +++ b/WebCore/svg/SVGSwitchElement.cpp @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005 Nikolas Zimmermann <wildfox@kde.org> 2004, 2005, 2006 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either @@ -34,6 +32,7 @@ SVGSwitchElement::SVGSwitchElement(const QualifiedName& tagName, Document* doc) , SVGTests() , SVGLangSpace() , SVGExternalResourcesRequired() + , m_externalResourcesRequired(this, SVGNames::externalResourcesRequiredAttr, false) { } diff --git a/WebCore/svg/SVGSwitchElement.h b/WebCore/svg/SVGSwitchElement.h index a2be835..f5e9a0d 100644 --- a/WebCore/svg/SVGSwitchElement.h +++ b/WebCore/svg/SVGSwitchElement.h @@ -1,9 +1,7 @@ /* - Copyright (C) 2004, 2005 Nikolas Zimmermann <wildfox@kde.org> + Copyright (C) 2004, 2005 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005, 2006 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either @@ -22,8 +20,8 @@ #ifndef SVGSwitchElement_h #define SVGSwitchElement_h -#if ENABLE(SVG) +#if ENABLE(SVG) #include "SVGExternalResourcesRequired.h" #include "SVGLangSpace.h" #include "SVGStyledTransformableElement.h" @@ -44,16 +42,14 @@ namespace WebCore { virtual RenderObject* createRenderer(RenderArena*, RenderStyle*); - protected: - virtual const SVGElement* contextElement() const { return this; } - private: - mutable bool m_insideRenderSection; + // SVGExternalResourcesRequired + ANIMATED_PROPERTY_DECLARATIONS(SVGSwitchElement, SVGExternalResourcesRequiredIdentifier, + SVGNames::externalResourcesRequiredAttrString, bool, + ExternalResourcesRequired, externalResourcesRequired) }; } // namespace WebCore #endif // ENABLE(SVG) #endif - -// vim:ts=4:noet diff --git a/WebCore/svg/SVGSymbolElement.cpp b/WebCore/svg/SVGSymbolElement.cpp index 073a13d..6f3a644 100644 --- a/WebCore/svg/SVGSymbolElement.cpp +++ b/WebCore/svg/SVGSymbolElement.cpp @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005 Nikolas Zimmermann <wildfox@kde.org> 2004, 2005, 2006 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either @@ -34,6 +32,9 @@ SVGSymbolElement::SVGSymbolElement(const QualifiedName& tagName, Document* doc) , SVGLangSpace() , SVGExternalResourcesRequired() , SVGFitToViewBox() + , m_externalResourcesRequired(this, SVGNames::externalResourcesRequiredAttr, false) + , m_viewBox(this, SVGNames::viewBoxAttr) + , m_preserveAspectRatio(this, SVGNames::preserveAspectRatioAttr, SVGPreserveAspectRatio::create()) { } @@ -47,7 +48,7 @@ void SVGSymbolElement::parseMappedAttribute(MappedAttribute* attr) return; if (SVGExternalResourcesRequired::parseMappedAttribute(attr)) return; - if (SVGFitToViewBox::parseMappedAttribute(attr)) + if (SVGFitToViewBox::parseMappedAttribute(document(), attr)) return; SVGStyledElement::parseMappedAttribute(attr); diff --git a/WebCore/svg/SVGSymbolElement.h b/WebCore/svg/SVGSymbolElement.h index a6ccbce..5c68202 100644 --- a/WebCore/svg/SVGSymbolElement.h +++ b/WebCore/svg/SVGSymbolElement.h @@ -1,9 +1,7 @@ /* - Copyright (C) 2004, 2005 Nikolas Zimmermann <wildfox@kde.org> + Copyright (C) 2004, 2005 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005, 2006 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either @@ -22,8 +20,8 @@ #ifndef SVGSymbolElement_h #define SVGSymbolElement_h -#if ENABLE(SVG) +#if ENABLE(SVG) #include "SVGExternalResourcesRequired.h" #include "SVGFitToViewBox.h" #include "SVGLangSpace.h" @@ -44,8 +42,15 @@ namespace WebCore { virtual bool rendererIsNeeded(RenderStyle*) { return false; } - protected: - virtual const SVGElement* contextElement() const { return this; } + private: + // SVGExternalResourcesRequired + ANIMATED_PROPERTY_DECLARATIONS(SVGSymbolElement, SVGExternalResourcesRequiredIdentifier, + SVGNames::externalResourcesRequiredAttrString, bool, + ExternalResourcesRequired, externalResourcesRequired) + + // SVGFitToViewBox + ANIMATED_PROPERTY_DECLARATIONS(SVGSymbolElement, SVGFitToViewBoxIdentifier, SVGNames::viewBoxAttrString, FloatRect, ViewBox, viewBox) + ANIMATED_PROPERTY_DECLARATIONS(SVGSymbolElement, SVGFitToViewBoxIdentifier, SVGNames::preserveAspectRatioAttrString, SVGPreserveAspectRatio, PreserveAspectRatio, preserveAspectRatio) }; } // namespace WebCore diff --git a/WebCore/svg/SVGTRefElement.cpp b/WebCore/svg/SVGTRefElement.cpp index 872e7c8..1f32e90 100644 --- a/WebCore/svg/SVGTRefElement.cpp +++ b/WebCore/svg/SVGTRefElement.cpp @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005 Nikolas Zimmermann <wildfox@kde.org> 2004, 2005, 2006 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either @@ -35,6 +33,7 @@ namespace WebCore { SVGTRefElement::SVGTRefElement(const QualifiedName& tagName, Document* doc) : SVGTextPositioningElement(tagName, doc) , SVGURIReference() + , m_href(this, XLinkNames::hrefAttr) { } diff --git a/WebCore/svg/SVGTRefElement.h b/WebCore/svg/SVGTRefElement.h index 88eeef1..71d40a0 100644 --- a/WebCore/svg/SVGTRefElement.h +++ b/WebCore/svg/SVGTRefElement.h @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005, 2006 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either @@ -40,11 +38,11 @@ namespace WebCore { virtual RenderObject* createRenderer(RenderArena*, RenderStyle*); bool childShouldCreateRenderer(Node*) const; - protected: - virtual const SVGElement* contextElement() const { return this; } - private: void updateReferencedText(); + + // SVGURIReference + ANIMATED_PROPERTY_DECLARATIONS(SVGTRefElement, SVGURIReferenceIdentifier, XLinkNames::hrefAttrString, String, Href, href) }; } // namespace WebCore diff --git a/WebCore/svg/SVGTSpanElement.cpp b/WebCore/svg/SVGTSpanElement.cpp index eadae1e..12bf377 100644 --- a/WebCore/svg/SVGTSpanElement.cpp +++ b/WebCore/svg/SVGTSpanElement.cpp @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005, 2006 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either diff --git a/WebCore/svg/SVGTSpanElement.h b/WebCore/svg/SVGTSpanElement.h index 7a29e96..17445d3 100644 --- a/WebCore/svg/SVGTSpanElement.h +++ b/WebCore/svg/SVGTSpanElement.h @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005, 2006 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either diff --git a/WebCore/svg/SVGTests.h b/WebCore/svg/SVGTests.h index 2d82cb4..a2abddf 100644 --- a/WebCore/svg/SVGTests.h +++ b/WebCore/svg/SVGTests.h @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005, 2006 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either diff --git a/WebCore/svg/SVGTextContentElement.cpp b/WebCore/svg/SVGTextContentElement.cpp index 86009c1..9334304 100644 --- a/WebCore/svg/SVGTextContentElement.cpp +++ b/WebCore/svg/SVGTextContentElement.cpp @@ -52,6 +52,7 @@ SVGTextContentElement::SVGTextContentElement(const QualifiedName& tagName, Docum , SVGExternalResourcesRequired() , m_textLength(this, SVGNames::textLengthAttr, LengthModeOther) , m_lengthAdjust(this, SVGNames::lengthAdjustAttr, LENGTHADJUST_SPACING) + , m_externalResourcesRequired(this, SVGNames::externalResourcesRequiredAttr, false) { } diff --git a/WebCore/svg/SVGTextContentElement.h b/WebCore/svg/SVGTextContentElement.h index 9933b2c..9b2c938 100644 --- a/WebCore/svg/SVGTextContentElement.h +++ b/WebCore/svg/SVGTextContentElement.h @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005, 2006, 2008 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either @@ -66,12 +64,14 @@ namespace WebCore { bool isKnownAttribute(const QualifiedName&); - protected: - virtual const SVGElement* contextElement() const { return this; } - private: ANIMATED_PROPERTY_DECLARATIONS(SVGTextContentElement, SVGTextContentElementIdentifier, SVGNames::textLengthAttrString, SVGLength, TextLength, textLength) ANIMATED_PROPERTY_DECLARATIONS(SVGTextContentElement, SVGTextContentElementIdentifier, SVGNames::lengthAdjustAttrString, int, LengthAdjust, lengthAdjust) + + // SVGExternalResourcesRequired + ANIMATED_PROPERTY_DECLARATIONS(SVGTextContentElement, SVGExternalResourcesRequiredIdentifier, + SVGNames::externalResourcesRequiredAttrString, bool, + ExternalResourcesRequired, externalResourcesRequired) }; } // namespace WebCore diff --git a/WebCore/svg/SVGTextElement.cpp b/WebCore/svg/SVGTextElement.cpp index b8c7331..c1481cf 100644 --- a/WebCore/svg/SVGTextElement.cpp +++ b/WebCore/svg/SVGTextElement.cpp @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005, 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005, 2006, 2008 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either diff --git a/WebCore/svg/SVGTextElement.h b/WebCore/svg/SVGTextElement.h index a5cb382..400aa47 100644 --- a/WebCore/svg/SVGTextElement.h +++ b/WebCore/svg/SVGTextElement.h @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005, 2006, 2008 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either diff --git a/WebCore/svg/SVGTextPathElement.cpp b/WebCore/svg/SVGTextPathElement.cpp index 54a4aa2..8a01ad9 100644 --- a/WebCore/svg/SVGTextPathElement.cpp +++ b/WebCore/svg/SVGTextPathElement.cpp @@ -1,8 +1,6 @@ /* Copyright (C) 2007 Nikolas Zimmermann <zimmermann@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either @@ -41,6 +39,7 @@ SVGTextPathElement::SVGTextPathElement(const QualifiedName& tagName, Document* d , m_startOffset(this, SVGNames::startOffsetAttr, LengthModeOther) , m_method(this, SVGNames::methodAttr, SVG_TEXTPATH_METHODTYPE_ALIGN) , m_spacing(this, SVGNames::spacingAttr, SVG_TEXTPATH_SPACINGTYPE_EXACT) + , m_href(this, XLinkNames::hrefAttr) { } diff --git a/WebCore/svg/SVGTextPathElement.h b/WebCore/svg/SVGTextPathElement.h index 4e8899a..1bfcc8b 100644 --- a/WebCore/svg/SVGTextPathElement.h +++ b/WebCore/svg/SVGTextPathElement.h @@ -1,8 +1,6 @@ /* Copyright (C) 2007 Nikolas Zimmermann <zimmermann@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either @@ -64,13 +62,13 @@ namespace WebCore { bool childShouldCreateRenderer(Node*) const; - protected: - virtual const SVGElement* contextElement() const { return this; } - private: ANIMATED_PROPERTY_DECLARATIONS(SVGTextPathElement, SVGNames::textPathTagString, SVGNames::startOffsetAttrString, SVGLength, StartOffset, startOffset) ANIMATED_PROPERTY_DECLARATIONS(SVGTextPathElement, SVGNames::textPathTagString, SVGNames::methodAttrString, int, Method, method) ANIMATED_PROPERTY_DECLARATIONS(SVGTextPathElement, SVGNames::textPathTagString, SVGNames::spacingAttrString, int, Spacing, spacing) + + // SVGURIReference + ANIMATED_PROPERTY_DECLARATIONS(SVGTextPathElement, SVGURIReferenceIdentifier, XLinkNames::hrefAttrString, String, Href, href) }; } // namespace WebCore diff --git a/WebCore/svg/SVGTextPositioningElement.cpp b/WebCore/svg/SVGTextPositioningElement.cpp index 32d9dc0..fd7c8aa 100644 --- a/WebCore/svg/SVGTextPositioningElement.cpp +++ b/WebCore/svg/SVGTextPositioningElement.cpp @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005, 2006, 2007, 2008 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either diff --git a/WebCore/svg/SVGTextPositioningElement.h b/WebCore/svg/SVGTextPositioningElement.h index 3e01dab..2b07d09 100644 --- a/WebCore/svg/SVGTextPositioningElement.h +++ b/WebCore/svg/SVGTextPositioningElement.h @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005, 2006, 2008 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either diff --git a/WebCore/svg/SVGTitleElement.cpp b/WebCore/svg/SVGTitleElement.cpp index 3e23a1b..5afde8d 100644 --- a/WebCore/svg/SVGTitleElement.cpp +++ b/WebCore/svg/SVGTitleElement.cpp @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005 Nikolas Zimmermann <wildfox@kde.org> 2004, 2005, 2006 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either diff --git a/WebCore/svg/SVGTitleElement.h b/WebCore/svg/SVGTitleElement.h index e053a42..340f725 100644 --- a/WebCore/svg/SVGTitleElement.h +++ b/WebCore/svg/SVGTitleElement.h @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005 Nikolas Zimmermann <wildfox@kde.org> 2004, 2005, 2006 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either diff --git a/WebCore/svg/SVGTransform.cpp b/WebCore/svg/SVGTransform.cpp index 17d9b8f..9fe770c 100644 --- a/WebCore/svg/SVGTransform.cpp +++ b/WebCore/svg/SVGTransform.cpp @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005 Nikolas Zimmermann <wildfox@kde.org> 2004, 2005 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either diff --git a/WebCore/svg/SVGTransform.h b/WebCore/svg/SVGTransform.h index 0a5e410..1e15468 100644 --- a/WebCore/svg/SVGTransform.h +++ b/WebCore/svg/SVGTransform.h @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either diff --git a/WebCore/svg/SVGTransform.idl b/WebCore/svg/SVGTransform.idl index 3163cd6..0fd3a1e 100644 --- a/WebCore/svg/SVGTransform.idl +++ b/WebCore/svg/SVGTransform.idl @@ -3,8 +3,6 @@ 2004, 2005 Rob Buis <buis@kde.org> Copyright (C) 2006 Apple Computer, Inc. All rights reserved. - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either diff --git a/WebCore/svg/SVGTransformList.cpp b/WebCore/svg/SVGTransformList.cpp index 648f1e9..f4f0965 100644 --- a/WebCore/svg/SVGTransformList.cpp +++ b/WebCore/svg/SVGTransformList.cpp @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either diff --git a/WebCore/svg/SVGTransformList.h b/WebCore/svg/SVGTransformList.h index d095fe4..9aea524 100644 --- a/WebCore/svg/SVGTransformList.h +++ b/WebCore/svg/SVGTransformList.h @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either diff --git a/WebCore/svg/SVGTransformable.h b/WebCore/svg/SVGTransformable.h index da31c75..1e87b78 100644 --- a/WebCore/svg/SVGTransformable.h +++ b/WebCore/svg/SVGTransformable.h @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either diff --git a/WebCore/svg/SVGURIReference.cpp b/WebCore/svg/SVGURIReference.cpp index 8871229..24febc3 100644 --- a/WebCore/svg/SVGURIReference.cpp +++ b/WebCore/svg/SVGURIReference.cpp @@ -30,7 +30,6 @@ namespace WebCore { char SVGURIReferenceIdentifier[] = "SVGURIReference"; SVGURIReference::SVGURIReference() - : m_href(this, XLinkNames::hrefAttr) { } diff --git a/WebCore/svg/SVGURIReference.h b/WebCore/svg/SVGURIReference.h index 35ac640..7f91b72 100644 --- a/WebCore/svg/SVGURIReference.h +++ b/WebCore/svg/SVGURIReference.h @@ -1,9 +1,7 @@ /* - Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org> + Copyright (C) 2004, 2005, 2008, 2009 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either @@ -42,10 +40,8 @@ namespace WebCore { static String getTarget(const String& url); - virtual const SVGElement* contextElement() const = 0; - - private: - ANIMATED_PROPERTY_DECLARATIONS(SVGURIReference, SVGURIReferenceIdentifier, XLinkNames::hrefAttrString, String, Href, href) + protected: + virtual void setHrefBaseValue(SVGAnimatedTypeValue<String>::DecoratedType type) = 0; }; } // namespace WebCore diff --git a/WebCore/svg/SVGUnitTypes.h b/WebCore/svg/SVGUnitTypes.h index 6be737f..b639f29 100644 --- a/WebCore/svg/SVGUnitTypes.h +++ b/WebCore/svg/SVGUnitTypes.h @@ -1,8 +1,6 @@ /* Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either diff --git a/WebCore/svg/SVGUseElement.cpp b/WebCore/svg/SVGUseElement.cpp index b73a692..a566992 100644 --- a/WebCore/svg/SVGUseElement.cpp +++ b/WebCore/svg/SVGUseElement.cpp @@ -1,8 +1,7 @@ /* Copyright (C) 2004, 2005, 2006, 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org> - - This file is part of the KDE project + Copyright (C) Research In Motion Limited 2009. 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 @@ -64,6 +63,8 @@ SVGUseElement::SVGUseElement(const QualifiedName& tagName, Document* doc) , m_y(this, SVGNames::yAttr, LengthModeHeight) , m_width(this, SVGNames::widthAttr, LengthModeWidth) , m_height(this, SVGNames::heightAttr, LengthModeHeight) + , m_href(this, XLinkNames::hrefAttr) + , m_externalResourcesRequired(this, SVGNames::externalResourcesRequiredAttr, false) { } @@ -158,6 +159,9 @@ void SVGUseElement::childrenChanged(bool changedByParser, Node* beforeChange, No static bool shadowTreeContainsChangedNodes(SVGElementInstance* target) { + if (!target) // when use is referencing an non-existing element, there will be no Instance tree built + return false; + if (target->needsUpdate()) return true; @@ -324,7 +328,7 @@ void SVGUseElement::buildPendingResource() // Spec: If the 'use' element references a simple graphics element such as a 'rect', then there is only a // single SVGElementInstance object, and the correspondingElement attribute on this SVGElementInstance object // is the SVGRectElement that corresponds to the referenced 'rect' element. - m_targetElementInstance = new SVGElementInstance(this, target); + m_targetElementInstance = SVGElementInstance::create(this, target); // Eventually enter recursion to build SVGElementInstance objects for the sub-tree children bool foundProblem = false; @@ -440,6 +444,9 @@ Path SVGUseElement::toClipPath() const if (!m_shadowTreeRootElement) const_cast<SVGUseElement*>(this)->buildPendingResource(); + if (!m_shadowTreeRootElement) + return Path(); + Node* n = m_shadowTreeRootElement->firstChild(); if (n->isSVGElement() && static_cast<SVGElement*>(n)->isStyledTransformable()) { if (!isDirectReference(n)) @@ -474,17 +481,11 @@ void SVGUseElement::buildInstanceTree(SVGElement* target, SVGElementInstance* ta continue; // Create SVGElementInstance object, for both container/non-container nodes. - SVGElementInstance* instancePtr = new SVGElementInstance(this, element); - targetInstance->appendChild(instancePtr); + RefPtr<SVGElementInstance> instancePtr = SVGElementInstance::create(this, element); + targetInstance->appendChild(instancePtr.get()); // Enter recursion, appending new instance tree nodes to the "instance" object. - if (element->hasChildNodes()) - buildInstanceTree(element, instancePtr, foundProblem); - - // Spec: If the referenced object is itself a 'use', or if there are 'use' subelements within the referenced - // object, the instance tree will contain recursive expansion of the indirect references to form a complete tree. - if (element->hasTagName(SVGNames::useTag)) - handleDeepUseReferencing(static_cast<SVGUseElement*>(element), instancePtr, foundProblem); + buildInstanceTree(element, instancePtr.get(), foundProblem); } // Spec: If the referenced object is itself a 'use', or if there are 'use' subelements within the referenced @@ -524,11 +525,11 @@ void SVGUseElement::handleDeepUseReferencing(SVGUseElement* use, SVGElementInsta } // Create an instance object, even if we're dealing with a cycle - SVGElementInstance* newInstance = new SVGElementInstance(this, target); + RefPtr<SVGElementInstance> newInstance = SVGElementInstance::create(this, target); targetInstance->appendChild(newInstance); // Eventually enter recursion to build SVGElementInstance objects for the sub-tree children - buildInstanceTree(target, newInstance, foundProblem); + buildInstanceTree(target, newInstance.get(), foundProblem); } void SVGUseElement::alterShadowTreeForSVGTag(SVGElement* target) @@ -768,18 +769,18 @@ void SVGUseElement::transferEventListenersToShadowTree(SVGElementInstance* targe ASSERT(originalElement); if (SVGElement* shadowTreeElement = target->shadowTreeElement()) { - const RegisteredEventListenerVector& listeners = originalElement->eventListeners(); - size_t size = listeners.size(); - for (size_t i = 0; i < size; ++i) { - const RegisteredEventListener& r = *listeners[i]; - EventListener* listener = r.listener(); - ASSERT(listener); - - // Event listeners created from markup have already been transfered to the shadow tree during cloning! - if (listener->wasCreatedFromMarkup()) - continue; - - shadowTreeElement->addEventListener(r.eventType(), listener, r.useCapture()); + if (EventTargetData* d = originalElement->eventTargetData()) { + EventListenerMap& map = d->eventListenerMap; + EventListenerMap::iterator end = map.end(); + for (EventListenerMap::iterator it = map.begin(); it != end; ++it) { + EventListenerVector& entry = *it->second; + for (size_t i = 0; i < entry.size(); ++i) { + // Event listeners created from markup have already been transfered to the shadow tree during cloning. + if (entry[i].listener->wasCreatedFromMarkup()) + continue; + shadowTreeElement->addEventListener(it->first, entry[i].listener, entry[i].useCapture); + } + } } } diff --git a/WebCore/svg/SVGUseElement.h b/WebCore/svg/SVGUseElement.h index 1e5b81c..45ca783 100644 --- a/WebCore/svg/SVGUseElement.h +++ b/WebCore/svg/SVGUseElement.h @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005, 2006, 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either @@ -68,15 +66,20 @@ namespace WebCore { static void removeDisallowedElementsFromSubtree(Node* element); SVGElementInstance* instanceForShadowTreeElement(Node* element) const; - protected: - virtual const SVGElement* contextElement() const { return this; } - private: ANIMATED_PROPERTY_DECLARATIONS(SVGUseElement, SVGNames::useTagString, SVGNames::xAttrString, SVGLength, X, x) ANIMATED_PROPERTY_DECLARATIONS(SVGUseElement, SVGNames::useTagString, SVGNames::yAttrString, SVGLength, Y, y) ANIMATED_PROPERTY_DECLARATIONS(SVGUseElement, SVGNames::useTagString, SVGNames::widthAttrString, SVGLength, Width, width) ANIMATED_PROPERTY_DECLARATIONS(SVGUseElement, SVGNames::useTagString, SVGNames::heightAttrString, SVGLength, Height, height) + // SVGURIReference + ANIMATED_PROPERTY_DECLARATIONS(SVGUseElement, SVGURIReferenceIdentifier, XLinkNames::hrefAttrString, String, Href, href) + + // SVGExternalResourcesRequired + ANIMATED_PROPERTY_DECLARATIONS(SVGUseElement, SVGExternalResourcesRequiredIdentifier, + SVGNames::externalResourcesRequiredAttrString, bool, + ExternalResourcesRequired, externalResourcesRequired) + private: // Instance tree handling void buildInstanceTree(SVGElement* target, SVGElementInstance* targetInstance, bool& foundCycle); diff --git a/WebCore/svg/SVGViewElement.cpp b/WebCore/svg/SVGViewElement.cpp index 61cb397..0fe6a90 100644 --- a/WebCore/svg/SVGViewElement.cpp +++ b/WebCore/svg/SVGViewElement.cpp @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005, 2007 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either @@ -40,6 +38,9 @@ SVGViewElement::SVGViewElement(const QualifiedName& tagName, Document* doc) , SVGExternalResourcesRequired() , SVGFitToViewBox() , SVGZoomAndPan() + , m_externalResourcesRequired(this, SVGNames::externalResourcesRequiredAttr, false) + , m_viewBox(this, SVGNames::viewBoxAttr) + , m_preserveAspectRatio(this, SVGNames::preserveAspectRatioAttr, SVGPreserveAspectRatio::create()) { } @@ -61,7 +62,7 @@ void SVGViewElement::parseMappedAttribute(MappedAttribute* attr) viewTarget()->reset(attr->value()); else { if (SVGExternalResourcesRequired::parseMappedAttribute(attr) - || SVGFitToViewBox::parseMappedAttribute(attr) + || SVGFitToViewBox::parseMappedAttribute(document(), attr) || SVGZoomAndPan::parseMappedAttribute(attr)) return; diff --git a/WebCore/svg/SVGViewElement.h b/WebCore/svg/SVGViewElement.h index 840dea9..33d0ae3 100644 --- a/WebCore/svg/SVGViewElement.h +++ b/WebCore/svg/SVGViewElement.h @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005, 2007 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either @@ -46,10 +44,16 @@ namespace WebCore { virtual bool rendererIsNeeded(RenderStyle*) { return false; } - protected: - virtual const SVGElement* contextElement() const { return this; } - private: + // SVGExternalResourcesRequired + ANIMATED_PROPERTY_DECLARATIONS(SVGViewElement, SVGExternalResourcesRequiredIdentifier, + SVGNames::externalResourcesRequiredAttrString, bool, + ExternalResourcesRequired, externalResourcesRequired) + + // SVGFitToViewBox + ANIMATED_PROPERTY_DECLARATIONS(SVGViewElement, SVGFitToViewBoxIdentifier, SVGNames::viewBoxAttrString, FloatRect, ViewBox, viewBox) + ANIMATED_PROPERTY_DECLARATIONS(SVGViewElement, SVGFitToViewBoxIdentifier, SVGNames::preserveAspectRatioAttrString, SVGPreserveAspectRatio, PreserveAspectRatio, preserveAspectRatio) + mutable RefPtr<SVGStringList> m_viewTarget; }; diff --git a/WebCore/svg/SVGViewSpec.cpp b/WebCore/svg/SVGViewSpec.cpp index b12b1c2..e6ded33 100644 --- a/WebCore/svg/SVGViewSpec.cpp +++ b/WebCore/svg/SVGViewSpec.cpp @@ -1,8 +1,6 @@ /* Copyright (C) 2007 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either @@ -36,8 +34,10 @@ namespace WebCore { SVGViewSpec::SVGViewSpec(const SVGSVGElement* contextElement) : SVGFitToViewBox() , SVGZoomAndPan() - , m_transform(SVGTransformList::create(SVGNames::transformAttr)) , m_contextElement(contextElement) + , m_viewBox(this, SVGNames::viewBoxAttr) + , m_preserveAspectRatio(this, SVGNames::preserveAspectRatioAttr, SVGPreserveAspectRatio::create()) + , m_transform(SVGTransformList::create(SVGNames::transformAttr)) { } @@ -55,7 +55,7 @@ void SVGViewSpec::setViewBoxString(const String& viewBox) float x, y, w, h; const UChar* c = viewBox.characters(); const UChar* end = c + viewBox.length(); - if (!parseViewBox(c, end, x, y, w, h, false)) + if (!parseViewBox(m_contextElement->document(), c, end, x, y, w, h, false)) return; setViewBoxBaseValue(FloatRect(x, y, w, h)); } @@ -74,12 +74,7 @@ void SVGViewSpec::setViewTargetString(const String& viewTargetString) SVGElement* SVGViewSpec::viewTarget() const { - return static_cast<SVGElement*>(m_contextElement->ownerDocument()->getElementById(m_viewTargetString)); -} - -const SVGElement* SVGViewSpec::contextElement() const -{ - return m_contextElement; + return static_cast<SVGElement*>(m_contextElement->document()->getElementById(m_viewTargetString)); } static const UChar svgViewSpec[] = {'s', 'v', 'g', 'V', 'i', 'e', 'w'}; @@ -111,7 +106,7 @@ bool SVGViewSpec::parseViewSpec(const String& viewSpec) return false; currViewSpec++; float x, y, w, h; - if (!parseViewBox(currViewSpec, end, x, y, w, h, false)) + if (!parseViewBox(m_contextElement->document(), currViewSpec, end, x, y, w, h, false)) return false; setViewBoxBaseValue(FloatRect(x, y, w, h)); if (currViewSpec >= end || *currViewSpec != ')') diff --git a/WebCore/svg/SVGViewSpec.h b/WebCore/svg/SVGViewSpec.h index 8624089..5f963af 100644 --- a/WebCore/svg/SVGViewSpec.h +++ b/WebCore/svg/SVGViewSpec.h @@ -1,8 +1,6 @@ /* Copyright (C) 2007 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either @@ -35,7 +33,8 @@ namespace WebCore { class SVGTransformList; class SVGViewSpec : public SVGFitToViewBox, - public SVGZoomAndPan { + public SVGZoomAndPan, + public Noncopyable { public: SVGViewSpec(const SVGSVGElement*); virtual ~SVGViewSpec(); @@ -53,11 +52,16 @@ namespace WebCore { String viewTargetString() const { return m_viewTargetString; } SVGElement* viewTarget() const; - virtual const SVGElement* contextElement() const; + const SVGSVGElement* contextElement() const { return m_contextElement; } private: - mutable RefPtr<SVGTransformList> m_transform; const SVGSVGElement* m_contextElement; + + // SVGFitToViewBox + ANIMATED_PROPERTY_DECLARATIONS(SVGViewSpec, SVGFitToViewBoxIdentifier, SVGNames::viewBoxAttrString, FloatRect, ViewBox, viewBox) + ANIMATED_PROPERTY_DECLARATIONS(SVGViewSpec, SVGFitToViewBoxIdentifier, SVGNames::preserveAspectRatioAttrString, SVGPreserveAspectRatio, PreserveAspectRatio, preserveAspectRatio) + + mutable RefPtr<SVGTransformList> m_transform; String m_viewTargetString; }; diff --git a/WebCore/svg/SVGZoomAndPan.cpp b/WebCore/svg/SVGZoomAndPan.cpp index c5eafb2..b1ea995 100644 --- a/WebCore/svg/SVGZoomAndPan.cpp +++ b/WebCore/svg/SVGZoomAndPan.cpp @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either diff --git a/WebCore/svg/SVGZoomAndPan.h b/WebCore/svg/SVGZoomAndPan.h index d7be342..c11f8e2 100644 --- a/WebCore/svg/SVGZoomAndPan.h +++ b/WebCore/svg/SVGZoomAndPan.h @@ -2,8 +2,6 @@ Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either diff --git a/WebCore/svg/SVGZoomEvent.cpp b/WebCore/svg/SVGZoomEvent.cpp index 2d5a870..92609b1 100644 --- a/WebCore/svg/SVGZoomEvent.cpp +++ b/WebCore/svg/SVGZoomEvent.cpp @@ -3,8 +3,6 @@ Copyright (C) 2004, 2005 Rob Buis <buis@kde.org> Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either diff --git a/WebCore/svg/SynchronizablePropertyController.cpp b/WebCore/svg/SynchronizablePropertyController.cpp new file mode 100644 index 0000000..be8ab78 --- /dev/null +++ b/WebCore/svg/SynchronizablePropertyController.cpp @@ -0,0 +1,145 @@ +/* + Copyright (C) Research In Motion Limited 2009. All rights reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include "config.h" + +#if ENABLE(SVG) +#include "SynchronizablePropertyController.h" + +#include "NamedNodeMap.h" +#include "Node.h" +#include "SVGAnimatedProperty.h" + +namespace WebCore { + +void SynchronizableProperties::addProperty(SVGAnimatedPropertyBase* base) +{ + m_bases.add(base); +} + +void SynchronizableProperties::synchronize() +{ + ASSERT(!m_bases.isEmpty()); + if (m_shouldSynchronize) { + BaseSet::iterator it = m_bases.begin(); + BaseSet::iterator end = m_bases.end(); + + for (; it != end; ++it) { + SVGAnimatedPropertyBase* base = *it; + ASSERT(base); + base->synchronize(); + } + } +} + +void SynchronizableProperties::startAnimation() +{ + ASSERT(!m_bases.isEmpty()); + BaseSet::iterator it = m_bases.begin(); + BaseSet::iterator end = m_bases.end(); + + for (; it != end; ++it) { + SVGAnimatedPropertyBase* base = *it; + ASSERT(base); + base->startAnimation(); + } +} + +void SynchronizableProperties::stopAnimation() +{ + ASSERT(!m_bases.isEmpty()); + BaseSet::iterator it = m_bases.begin(); + BaseSet::iterator end = m_bases.end(); + + for (; it != end; ++it) { + SVGAnimatedPropertyBase* base = *it; + ASSERT(base); + base->stopAnimation(); + } +} + +SynchronizablePropertyController::SynchronizablePropertyController() +{ +} + +void SynchronizablePropertyController::registerProperty(const QualifiedName& attrName, SVGAnimatedPropertyBase* base) +{ + // 'attrName' is ambigious. For instance in SVGMarkerElement both 'orientType' / 'orientAngle' + // SVG DOM objects are synchronized with the 'orient' attribute. This why we need a HashSet. + PropertyMap::iterator it = m_map.find(attrName.localName()); + if (it == m_map.end()) { + SynchronizableProperties properties; + properties.addProperty(base); + m_map.set(attrName.localName(), properties); + return; + } + + it->second.addProperty(base); +} + +void SynchronizablePropertyController::setPropertyNeedsSynchronization(const QualifiedName& attrName) +{ + PropertyMap::iterator itProp = m_map.find(attrName.localName()); + ASSERT(itProp != m_map.end()); + + itProp->second.setNeedsSynchronization(); +} + +void SynchronizablePropertyController::synchronizeProperty(const String& name) +{ + PropertyMap::iterator itProp = m_map.find(name); + if (itProp == m_map.end()) + return; + + itProp->second.synchronize(); +} + +void SynchronizablePropertyController::synchronizeAllProperties() +{ + if (m_map.isEmpty()) + return; + + PropertyMap::iterator itProp = m_map.begin(); + PropertyMap::iterator endProp = m_map.end(); + + for (; itProp != endProp; ++itProp) + itProp->second.synchronize(); +} + +void SynchronizablePropertyController::startAnimation(const String& name) +{ + PropertyMap::iterator itProp = m_map.find(name); + if (itProp == m_map.end()) + return; + + itProp->second.startAnimation(); +} + +void SynchronizablePropertyController::stopAnimation(const String& name) +{ + PropertyMap::iterator itProp = m_map.find(name); + if (itProp == m_map.end()) + return; + + itProp->second.stopAnimation(); +} + +} + +#endif // ENABLE(SVG) diff --git a/WebCore/svg/SynchronizablePropertyController.h b/WebCore/svg/SynchronizablePropertyController.h new file mode 100644 index 0000000..1ec5026 --- /dev/null +++ b/WebCore/svg/SynchronizablePropertyController.h @@ -0,0 +1,84 @@ +/* + Copyright (C) Research In Motion Limited 2009. All rights reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef SynchronizablePropertyController_h +#define SynchronizablePropertyController_h + +#if ENABLE(SVG) +#include "StringHash.h" +#include <wtf/HashMap.h> +#include <wtf/HashSet.h> +#include <wtf/Noncopyable.h> + +namespace WebCore { + +class QualifiedName; +class SVGAnimatedPropertyBase; + +class SynchronizableProperties { +public: + SynchronizableProperties() + : m_shouldSynchronize(false) + { + } + + void setNeedsSynchronization() + { + m_shouldSynchronize = true; + } + + void addProperty(SVGAnimatedPropertyBase*); + void synchronize(); + void startAnimation(); + void stopAnimation(); + +private: + typedef HashSet<SVGAnimatedPropertyBase*> BaseSet; + + BaseSet m_bases; + bool m_shouldSynchronize; +}; + +// Helper class used exclusively by SVGElement to keep track of all animatable properties within a SVGElement, +// and wheter they are supposed to be synchronized or not (depending wheter AnimatedPropertyTearOff's have been created) +class SynchronizablePropertyController : public Noncopyable { +public: + void registerProperty(const QualifiedName&, SVGAnimatedPropertyBase*); + void setPropertyNeedsSynchronization(const QualifiedName&); + + void synchronizeProperty(const String&); + void synchronizeAllProperties(); + + void startAnimation(const String&); + void stopAnimation(const String&); + +private: + friend class SVGElement; + SynchronizablePropertyController(); + +private: + typedef HashMap<String, SynchronizableProperties> PropertyMap; + + PropertyMap m_map; +}; + +}; + +#endif // ENABLE(SVG) +#endif // SynchronizablePropertyController_h diff --git a/WebCore/svg/animation/SMILTimeContainer.cpp b/WebCore/svg/animation/SMILTimeContainer.cpp index a37e481..f0b479d 100644 --- a/WebCore/svg/animation/SMILTimeContainer.cpp +++ b/WebCore/svg/animation/SMILTimeContainer.cpp @@ -46,6 +46,7 @@ SMILTimeContainer::SMILTimeContainer(SVGSVGElement* owner) : m_beginTime(0) , m_pauseTime(0) , m_accumulatedPauseTime(0) + , m_nextManualSampleTime(0) , m_documentOrderIndexesDirty(false) , m_timer(this, &SMILTimeContainer::timerFired) , m_ownerSVGElement(owner) @@ -207,14 +208,45 @@ String SMILTimeContainer::baseValueFor(ElementAttributePair key) m_savedBaseValues.add(key, baseValue); return baseValue; } - + +void SMILTimeContainer::sampleAnimationAtTime(const String& elementId, double newTime) +{ + ASSERT(m_beginTime); + ASSERT(!isPaused()); + + // Fast-forward to the time DRT wants to sample + m_timer.stop(); + m_nextSamplingTarget = elementId; + m_nextManualSampleTime = newTime; + + updateAnimations(elapsed()); +} + void SMILTimeContainer::updateAnimations(SMILTime elapsed) { SMILTime earliersFireTime = SMILTime::unresolved(); Vector<SVGSMILElement*> toAnimate; copyToVector(m_scheduledAnimations, toAnimate); - + + if (m_nextManualSampleTime) { + SMILTime samplingDiff; + for (unsigned n = 0; n < toAnimate.size(); ++n) { + SVGSMILElement* animation = toAnimate[n]; + ASSERT(animation->timeContainer() == this); + + SVGElement* targetElement = animation->targetElement(); + if (!targetElement || targetElement->getIDAttribute() != m_nextSamplingTarget) + continue; + + samplingDiff = animation->intervalBegin(); + break; + } + + elapsed = SMILTime(m_nextManualSampleTime) + samplingDiff; + m_nextManualSampleTime = 0; + } + // Sort according to priority. Elements with later begin time have higher priority. // In case of a tie, document order decides. // FIXME: This should also consider timing relationships between the elements. Dependents diff --git a/WebCore/svg/animation/SMILTimeContainer.h b/WebCore/svg/animation/SMILTimeContainer.h index 5cef507..a6a61c0 100644 --- a/WebCore/svg/animation/SMILTimeContainer.h +++ b/WebCore/svg/animation/SMILTimeContainer.h @@ -60,6 +60,9 @@ namespace WebCore { void setDocumentOrderIndexesDirty() { m_documentOrderIndexesDirty = true; } + // Move to a specific time. Only used for DRT testing purposes. + void sampleAnimationAtTime(const String& elementId, double seconds); + private: SMILTimeContainer(SVGSVGElement* owner); @@ -76,7 +79,9 @@ namespace WebCore { double m_beginTime; double m_pauseTime; double m_accumulatedPauseTime; - + double m_nextManualSampleTime; + String m_nextSamplingTarget; + bool m_documentOrderIndexesDirty; Timer<SMILTimeContainer> m_timer; diff --git a/WebCore/svg/animation/SVGSMILElement.cpp b/WebCore/svg/animation/SVGSMILElement.cpp index 63a0d82..3957b81 100644 --- a/WebCore/svg/animation/SVGSMILElement.cpp +++ b/WebCore/svg/animation/SVGSMILElement.cpp @@ -61,6 +61,15 @@ public: return adoptRef(new ConditionEventListener(animation, eventBase, condition)); } + static const ConditionEventListener* cast(const EventListener* listener) + { + return listener->type() == ConditionEventListenerType + ? static_cast<const ConditionEventListener*>(listener) + : 0; + } + + virtual bool operator==(const EventListener& other); + void unregister() { // If this has only one ref then the event base is dead already and we don't need to remove ourself. @@ -68,25 +77,37 @@ public: m_eventBase->removeEventListener(m_condition->m_name, this, false); } - virtual void handleEvent(Event* event, bool) - { - m_animation->handleConditionEvent(event, m_condition); - } - private: ConditionEventListener(SVGSMILElement* animation, Element* eventBase, SVGSMILElement::Condition* condition) - : m_animation(animation) + : EventListener(ConditionEventListenerType) + , m_animation(animation) , m_condition(condition) , m_eventBase(eventBase) { m_eventBase->addEventListener(m_condition->m_name, this, false); } + virtual void handleEvent(ScriptExecutionContext*, Event*); + SVGSMILElement* m_animation; SVGSMILElement::Condition* m_condition; Element* m_eventBase; }; - + +bool ConditionEventListener::operator==(const EventListener& listener) +{ + if (const ConditionEventListener* conditionEventListener = ConditionEventListener::cast(&listener)) + return m_animation == conditionEventListener->m_animation + && m_condition == conditionEventListener->m_condition + && m_eventBase == conditionEventListener->m_eventBase; + return false; +} + +void ConditionEventListener::handleEvent(ScriptExecutionContext*, Event* event) +{ + m_animation->handleConditionEvent(event, m_condition); +} + SVGSMILElement::Condition::Condition(Type type, BeginOrEnd beginOrEnd, const String& baseID, const String& name, SMILTime offset, int repeats) : m_type(type) , m_beginOrEnd(beginOrEnd) diff --git a/WebCore/svg/graphics/SVGImage.cpp b/WebCore/svg/graphics/SVGImage.cpp index 64eb0e7..c4be11e 100644 --- a/WebCore/svg/graphics/SVGImage.cpp +++ b/WebCore/svg/graphics/SVGImage.cpp @@ -173,7 +173,7 @@ bool SVGImage::hasRelativeHeight() const return rootElement->height().unitType() == LengthTypePercentage; } -void SVGImage::draw(GraphicsContext* context, const FloatRect& dstRect, const FloatRect& srcRect, CompositeOperator compositeOp) +void SVGImage::draw(GraphicsContext* context, const FloatRect& dstRect, const FloatRect& srcRect, ColorSpace, CompositeOperator compositeOp) { if (!m_page) return; @@ -228,26 +228,34 @@ bool SVGImage::dataChanged(bool allDataReceived) if (allDataReceived) { static FrameLoaderClient* dummyFrameLoaderClient = new EmptyFrameLoaderClient; static EditorClient* dummyEditorClient = new EmptyEditorClient; +#if ENABLE(CONTEXT_MENUS) static ContextMenuClient* dummyContextMenuClient = new EmptyContextMenuClient; +#else + static ContextMenuClient* dummyContextMenuClient = 0; +#endif +#if ENABLE(DRAG_SUPPORT) static DragClient* dummyDragClient = new EmptyDragClient; +#else + static DragClient* dummyDragClient = 0; +#endif static InspectorClient* dummyInspectorClient = new EmptyInspectorClient; m_chromeClient.set(new SVGImageChromeClient(this)); // FIXME: If this SVG ends up loading itself, we might leak the world. - // THe comment said that the Cache code does not know about CachedImages + // The comment said that the Cache code does not know about CachedImages // holding Frames and won't know to break the cycle. But - m_page.set(new Page(m_chromeClient.get(), dummyContextMenuClient, dummyEditorClient, dummyDragClient, dummyInspectorClient)); + m_page.set(new Page(m_chromeClient.get(), dummyContextMenuClient, dummyEditorClient, dummyDragClient, dummyInspectorClient, 0)); m_page->settings()->setJavaScriptEnabled(false); m_page->settings()->setPluginsEnabled(false); RefPtr<Frame> frame = Frame::create(m_page.get(), 0, dummyFrameLoaderClient); frame->setView(FrameView::create(frame.get())); frame->init(); - ResourceRequest fakeRequest(KURL("")); + ResourceRequest fakeRequest(KURL(ParsedURLString, "")); FrameLoader* loader = frame->loader(); loader->load(fakeRequest, false); // Make sure the DocumentLoader is created - loader->cancelContentPolicyCheck(); // cancel any policy checks + loader->policyChecker()->cancelCheck(); // cancel any policy checks loader->commitProvisionalLoad(0); loader->setResponseMIMEType("image/svg+xml"); loader->begin(KURL()); // create the empty document diff --git a/WebCore/svg/graphics/SVGImage.h b/WebCore/svg/graphics/SVGImage.h index 2cea91a..10f39ba 100644 --- a/WebCore/svg/graphics/SVGImage.h +++ b/WebCore/svg/graphics/SVGImage.h @@ -64,7 +64,7 @@ namespace WebCore { virtual NativeImagePtr frameAtIndex(size_t) { return 0; } SVGImage(ImageObserver*); - virtual void draw(GraphicsContext*, const FloatRect& fromRect, const FloatRect& toRect, CompositeOperator); + virtual void draw(GraphicsContext*, const FloatRect& fromRect, const FloatRect& toRect, ColorSpace styleColorSpace, CompositeOperator); virtual NativeImagePtr nativeImageForCurrentFrame(); diff --git a/WebCore/svg/graphics/SVGPaintServer.cpp b/WebCore/svg/graphics/SVGPaintServer.cpp index 728ff1b..6b81f72 100644 --- a/WebCore/svg/graphics/SVGPaintServer.cpp +++ b/WebCore/svg/graphics/SVGPaintServer.cpp @@ -38,7 +38,7 @@ #include "SVGStyledElement.h" #include "SVGURIReference.h" -#if PLATFORM(SKIA) +#if PLATFORM(SKIA) && !PLATFORM(ANDROID) #include "PlatformContextSkia.h" #endif @@ -184,7 +184,7 @@ void SVGPaintServer::renderPath(GraphicsContext*& context, const RenderObject* p context->strokePath(); } -#if PLATFORM(SKIA) +#if PLATFORM(SKIA) && !PLATFORM(ANDROID) void SVGPaintServer::teardown(GraphicsContext*& context, const RenderObject*, SVGPaintTargetType, bool) const { // FIXME: Move this into the GraphicsContext diff --git a/WebCore/svg/graphics/SVGPaintServerGradient.cpp b/WebCore/svg/graphics/SVGPaintServerGradient.cpp index 4a8e9e0..74e3c22 100644 --- a/WebCore/svg/graphics/SVGPaintServerGradient.cpp +++ b/WebCore/svg/graphics/SVGPaintServerGradient.cpp @@ -233,7 +233,7 @@ bool SVGPaintServerGradient::setup(GraphicsContext*& context, const RenderObject // lines or rectangles without width or height. if (bbox.width() == 0 || bbox.height() == 0) { Color color(0, 0, 0); - context->setStrokeColor(color); + context->setStrokeColor(color, object->style()->colorSpace()); return true; } matrix.translate(bbox.x(), bbox.y()); diff --git a/WebCore/svg/graphics/SVGPaintServerPattern.cpp b/WebCore/svg/graphics/SVGPaintServerPattern.cpp index e825a0b..289c40c 100644 --- a/WebCore/svg/graphics/SVGPaintServerPattern.cpp +++ b/WebCore/svg/graphics/SVGPaintServerPattern.cpp @@ -131,7 +131,7 @@ bool SVGPaintServerPattern::setup(GraphicsContext*& context, const RenderObject* tileImageContext->translate(0, patternBoundaries().height()); for (int j = numX; j > 0; j--) { tileImageContext->translate(patternBoundaries().width(), 0); - tileImageContext->drawImage(tile()->image(), tileRect, tileRect); + tileImageContext->drawImage(tile()->image(), object->style()->colorSpace(), tileRect, tileRect); } tileImageContext->translate(-patternBoundaries().width() * numX, 0); } diff --git a/WebCore/svg/graphics/SVGPaintServerSolid.cpp b/WebCore/svg/graphics/SVGPaintServerSolid.cpp index b333042..72baad2 100644 --- a/WebCore/svg/graphics/SVGPaintServerSolid.cpp +++ b/WebCore/svg/graphics/SVGPaintServerSolid.cpp @@ -64,10 +64,11 @@ bool SVGPaintServerSolid::setup(GraphicsContext*& context, const RenderObject* o { RenderStyle* style = object ? object->style() : 0; 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()); + context->setFillColor(color().rgb(), colorSpace); context->setFillRule(style ? svgStyle->fillRule() : RULE_NONZERO); if (isPaintingText) @@ -76,7 +77,7 @@ bool SVGPaintServerSolid::setup(GraphicsContext*& context, const RenderObject* o if ((type & ApplyToStrokeTargetType) && (!style || svgStyle->hasStroke())) { context->setAlpha(style ? svgStyle->strokeOpacity() : 1); - context->setStrokeColor(color().rgb()); + context->setStrokeColor(color().rgb(), colorSpace); if (style) applyStrokeStyleToContext(context, style, object); diff --git a/WebCore/svg/graphics/SVGResource.cpp b/WebCore/svg/graphics/SVGResource.cpp index 049edc7..514b70d 100644 --- a/WebCore/svg/graphics/SVGResource.cpp +++ b/WebCore/svg/graphics/SVGResource.cpp @@ -39,7 +39,7 @@ SVGResource::SVGResource() { } -struct ResourceSet { +struct ResourceSet : Noncopyable { ResourceSet() { for (int i = 0; i < _ResourceTypeCount; i++) diff --git a/WebCore/svg/graphics/SVGResourceFilter.cpp b/WebCore/svg/graphics/SVGResourceFilter.cpp index 4a4bdd5..fcf0e40 100644 --- a/WebCore/svg/graphics/SVGResourceFilter.cpp +++ b/WebCore/svg/graphics/SVGResourceFilter.cpp @@ -31,56 +31,100 @@ #include "PlatformString.h" #include "SVGFilter.h" #include "SVGFilterBuilder.h" +#include "SVGFilterElement.h" #include "SVGRenderTreeAsText.h" #include "SVGFilterPrimitiveStandardAttributes.h" +static const float kMaxFilterSize = 5000.0f; + +using std::min; + namespace WebCore { -SVGResourceFilter::SVGResourceFilter() - : m_filterBBoxMode(false) +SVGResourceFilter::SVGResourceFilter(const SVGFilterElement* ownerElement) + : SVGResource() + , m_ownerElement(ownerElement) + , m_filterBBoxMode(false) , m_effectBBoxMode(false) - , m_xBBoxMode(false) - , m_yBBoxMode(false) + , m_filterRes(false) + , m_scaleX(1.f) + , m_scaleY(1.f) , m_savedContext(0) , m_sourceGraphicBuffer(0) { m_filterBuilder.set(new SVGFilterBuilder()); } +SVGResourceFilter::~SVGResourceFilter() +{ +} + +static inline bool shouldProcessFilter(SVGResourceFilter* filter) +{ + return (!filter->scaleX() || !filter->scaleY() || !filter->filterBoundingBox().width() + || !filter->filterBoundingBox().height()); +} + void SVGResourceFilter::addFilterEffect(SVGFilterPrimitiveStandardAttributes* effectAttributes, PassRefPtr<FilterEffect> effect) { effectAttributes->setStandardAttributes(this, effect.get()); builder()->add(effectAttributes->result(), effect); } -FloatRect SVGResourceFilter::filterBBoxForItemBBox(const FloatRect& itemBBox) const +bool SVGResourceFilter::fitsInMaximumImageSize(const FloatSize& size) { - FloatRect filterBBox = filterRect(); - - if (filterBoundingBoxMode()) - filterBBox = FloatRect(itemBBox.x() + filterBBox.x() * itemBBox.width(), - itemBBox.y() + filterBBox.y() * itemBBox.height(), - filterBBox.width() * itemBBox.width(), - filterBBox.height() * itemBBox.height()); + bool matchesFilterSize = true; + if (size.width() > kMaxFilterSize) { + m_scaleX *= kMaxFilterSize / size.width(); + matchesFilterSize = false; + } + if (size.height() > kMaxFilterSize) { + m_scaleY *= kMaxFilterSize / size.height(); + matchesFilterSize = false; + } - return filterBBox; + return matchesFilterSize; } void SVGResourceFilter::prepareFilter(GraphicsContext*& context, const RenderObject* object) { - m_itemBBox = object->objectBoundingBox(); - m_filterBBox = filterBBoxForItemBBox(m_itemBBox); + FloatRect targetRect = object->objectBoundingBox(); + m_ownerElement->buildFilter(targetRect); + + if (shouldProcessFilter(this)) + return; // clip sourceImage to filterRegion - FloatRect clippedSourceRect = m_itemBBox; + FloatRect clippedSourceRect = targetRect; clippedSourceRect.intersect(m_filterBBox); + // scale filter size to filterRes + FloatRect tempSourceRect = clippedSourceRect; + if (m_filterRes) { + m_scaleX = m_filterResSize.width() / m_filterBBox.width(); + m_scaleY = m_filterResSize.height() / m_filterBBox.height(); + } + + // scale to big sourceImage size to kMaxFilterSize + tempSourceRect.scale(m_scaleX, m_scaleY); + fitsInMaximumImageSize(tempSourceRect.size()); + // prepare Filters - m_filter = SVGFilter::create(m_itemBBox, m_filterBBox, m_effectBBoxMode, m_filterBBoxMode); + m_filter = SVGFilter::create(targetRect, m_filterBBox, m_effectBBoxMode); + m_filter->setFilterResolution(FloatSize(m_scaleX, m_scaleY)); FilterEffect* lastEffect = m_filterBuilder->lastEffect(); - if (lastEffect) + if (lastEffect) { lastEffect->calculateEffectRect(m_filter.get()); + // at least one FilterEffect has a too big image size, + // recalculate the effect sizes with new scale factors + if (!fitsInMaximumImageSize(m_filter->maxImageSize())) { + m_filter->setFilterResolution(FloatSize(m_scaleX, m_scaleY)); + lastEffect->calculateEffectRect(m_filter.get()); + } + } + + clippedSourceRect.scale(m_scaleX, m_scaleY); // Draw the content of the current element and it's childs to a imageBuffer to get the SourceGraphic. // The size of the SourceGraphic is clipped to the size of the filterRegion. @@ -91,16 +135,20 @@ void SVGResourceFilter::prepareFilter(GraphicsContext*& context, const RenderObj return; GraphicsContext* sourceGraphicContext = sourceGraphic->context(); - sourceGraphicContext->translate(-m_itemBBox.x(), -m_itemBBox.y()); - sourceGraphicContext->clearRect(FloatRect(FloatPoint(), m_itemBBox.size())); + sourceGraphicContext->scale(FloatSize(m_scaleX, m_scaleY)); + sourceGraphicContext->translate(-targetRect.x(), -targetRect.y()); + sourceGraphicContext->clearRect(FloatRect(FloatPoint(), targetRect.size())); m_sourceGraphicBuffer.set(sourceGraphic.release()); m_savedContext = context; context = sourceGraphicContext; } -void SVGResourceFilter::applyFilter(GraphicsContext*& context, const RenderObject*) +void SVGResourceFilter::applyFilter(GraphicsContext*& context, const RenderObject* object) { + if (shouldProcessFilter(this)) + return; + if (!m_savedContext) return; @@ -121,7 +169,10 @@ void SVGResourceFilter::applyFilter(GraphicsContext*& context, const RenderObjec #if !PLATFORM(CG) resultImage->transformColorSpace(LinearRGB, DeviceRGB); #endif - context->drawImage(resultImage->image(), lastEffect->subRegion()); + ColorSpace colorSpace = DeviceColorSpace; + if (object) + colorSpace = object->style()->colorSpace(); + context->drawImage(resultImage->image(), colorSpace, lastEffect->subRegion()); } } diff --git a/WebCore/svg/graphics/SVGResourceFilter.h b/WebCore/svg/graphics/SVGResourceFilter.h index ee1efca..ffd926d 100644 --- a/WebCore/svg/graphics/SVGResourceFilter.h +++ b/WebCore/svg/graphics/SVGResourceFilter.h @@ -43,58 +43,59 @@ class Filter; class FilterEffect; class GraphicsContext; class SVGFilterBuilder; +class SVGFilterElement; class SVGFilterPrimitiveStandardAttributes; class SVGResourceFilter : public SVGResource { public: - SVGResourceFilter(); + static PassRefPtr<SVGResourceFilter> create(const SVGFilterElement* ownerElement) { return adoptRef(new SVGResourceFilter(ownerElement)); } + virtual ~SVGResourceFilter(); virtual SVGResourceType resourceType() const { return FilterResourceType; } + void setFilterResolution(const FloatSize& filterResSize) { m_filterResSize = filterResSize; } + void setHasFilterResolution(bool filterRes) { m_filterRes = filterRes; } + bool filterBoundingBoxMode() const { return m_filterBBoxMode; } void setFilterBoundingBoxMode(bool bboxMode) { m_filterBBoxMode = bboxMode; } bool effectBoundingBoxMode() const { return m_effectBBoxMode; } void setEffectBoundingBoxMode(bool bboxMode) { m_effectBBoxMode = bboxMode; } - bool xBoundingBoxMode() const { return m_xBBoxMode; } - void setXBoundingBoxMode(bool bboxMode) { m_xBBoxMode = bboxMode; } - - bool yBoundingBoxMode() const { return m_yBBoxMode; } - void setYBoundingBoxMode(bool bboxMode) { m_yBBoxMode = bboxMode; } - FloatRect filterRect() const { return m_filterRect; } void setFilterRect(const FloatRect& rect) { m_filterRect = rect; } + float scaleX() const { return m_scaleX; } + float scaleY() const { return m_scaleY; } + FloatRect filterBoundingBox() { return m_filterBBox; } void setFilterBoundingBox(const FloatRect& rect) { m_filterBBox = rect; } - FloatRect itemBoundingBox() { return m_itemBBox; } - void setItemBoundingBox(const FloatRect& rect) { m_itemBBox = rect; } - - FloatRect filterBBoxForItemBBox(const FloatRect& itemBBox) const; - - virtual TextStream& externalRepresentation(TextStream&) const; - void prepareFilter(GraphicsContext*&, const RenderObject*); void applyFilter(GraphicsContext*&, const RenderObject*); + bool fitsInMaximumImageSize(const FloatSize&); + void addFilterEffect(SVGFilterPrimitiveStandardAttributes*, PassRefPtr<FilterEffect>); SVGFilterBuilder* builder() { return m_filterBuilder.get(); } + + virtual TextStream& externalRepresentation(TextStream&) const; private: + SVGResourceFilter(const SVGFilterElement*); + + const SVGFilterElement* m_ownerElement; bool m_filterBBoxMode : 1; bool m_effectBBoxMode : 1; - - bool m_xBBoxMode : 1; - bool m_yBBoxMode : 1; + bool m_filterRes : 1; + float m_scaleX; + float m_scaleY; FloatRect m_filterRect; - FloatRect m_filterBBox; - FloatRect m_itemBBox; + FloatSize m_filterResSize; OwnPtr<SVGFilterBuilder> m_filterBuilder; GraphicsContext* m_savedContext; diff --git a/WebCore/svg/graphics/SVGResourceMasker.cpp b/WebCore/svg/graphics/SVGResourceMasker.cpp index d6c401b..97467c1 100644 --- a/WebCore/svg/graphics/SVGResourceMasker.cpp +++ b/WebCore/svg/graphics/SVGResourceMasker.cpp @@ -76,8 +76,8 @@ void SVGResourceMasker::applyMask(GraphicsContext* context, const FloatRect& bou if (!luminancedImage) return; - PassRefPtr<CanvasPixelArray> srcPixelArray(m_mask->getImageData(intImageRect)->data()); - PassRefPtr<ImageData> destImageData(luminancedImage->getImageData(intImageRect)); + PassRefPtr<CanvasPixelArray> srcPixelArray(m_mask->getUnmultipliedImageData(intImageRect)->data()); + PassRefPtr<ImageData> destImageData(luminancedImage->getUnmultipliedImageData(intImageRect)); for (unsigned pixelOffset = 0; pixelOffset < srcPixelArray->length(); pixelOffset++) { unsigned pixelByteOffset = pixelOffset * 4; @@ -93,7 +93,7 @@ void SVGResourceMasker::applyMask(GraphicsContext* context, const FloatRect& bou destImageData->data()->set(pixelByteOffset + 3, luma); } - luminancedImage->putImageData(destImageData.get(), intImageRect, IntPoint(0, 0)); + luminancedImage->putUnmultipliedImageData(destImageData.get(), intImageRect, IntPoint(0, 0)); context->clipToImageBuffer(m_maskRect, luminancedImage.get()); } diff --git a/WebCore/svg/graphics/cairo/SVGResourceFilterCairo.cpp b/WebCore/svg/graphics/cairo/SVGResourceFilterCairo.cpp deleted file mode 100644 index a27038a..0000000 --- a/WebCore/svg/graphics/cairo/SVGResourceFilterCairo.cpp +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (C) 2008 Collabora Ltd. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "config.h" - -#if ENABLE(SVG) && ENABLE(SVG_FILTERS) - -#include "NotImplemented.h" -#include "SVGResourceFilter.h" - -namespace WebCore { - -SVGResourceFilterPlatformData* SVGResourceFilter::createPlatformData() -{ - notImplemented(); - return 0; -} - -void SVGResourceFilter::prepareFilter(GraphicsContext*&, const FloatRect&) -{ - notImplemented(); -} - -void SVGResourceFilter::applyFilter(GraphicsContext*&, const FloatRect&) -{ - notImplemented(); -} - -} // namespace WebCore - -#endif - diff --git a/WebCore/svg/graphics/cg/SVGResourceFilterCg.cpp b/WebCore/svg/graphics/cg/SVGResourceFilterCg.cpp deleted file mode 100644 index ecfcdd8..0000000 --- a/WebCore/svg/graphics/cg/SVGResourceFilterCg.cpp +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (C) 2005, 2006, 2007 Apple Inc. All rights reserved. - * Copyright (C) 2006 Dave MacLachlan (dmaclach@mac.com) - * 2006 Rob Buis <buis@kde.org> - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - - -#include "config.h" -#if ENABLE(SVG) && ENABLE(SVG_FILTERS) -#include "NotImplemented.h" -#include "SVGResourceFilter.h" - -namespace WebCore { - -SVGResourceFilterPlatformData* SVGResourceFilter::createPlatformData() -{ - return 0; -} - -void SVGResourceFilter::prepareFilter(GraphicsContext*&, const FloatRect&) -{ - notImplemented(); -} - -void SVGResourceFilter::applyFilter(GraphicsContext*&, const FloatRect&) -{ - notImplemented(); -} - -} - -#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS) diff --git a/WebCore/svg/graphics/cg/SVGResourceFilterCg.mm b/WebCore/svg/graphics/cg/SVGResourceFilterCg.mm deleted file mode 100644 index a89ec1d..0000000 --- a/WebCore/svg/graphics/cg/SVGResourceFilterCg.mm +++ /dev/null @@ -1,143 +0,0 @@ -/* - * Copyright (C) 2005 Apple Computer, Inc. All rights reserved. - * (C) 2007 Nikolas Zimmermann <zimmermann@kde.org> - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "config.h" - -#if ENABLE(SVG) && ENABLE(SVG_FILTERS) -#include "SVGResourceFilter.h" - -#include "TransformationMatrix.h" -#include "GraphicsContext.h" - -#include "SVGResourceFilterPlatformDataMac.h" - -#include <QuartzCore/CoreImage.h> - -// Setting to a value > 0 allows to dump the output image as JPEG. -#define DEBUG_OUTPUT_IMAGE 0 - -namespace WebCore { - -SVGResourceFilterPlatformData* SVGResourceFilter::createPlatformData() -{ - return new SVGResourceFilterPlatformDataMac(this); -} - -void SVGResourceFilter::prepareFilter(GraphicsContext*& context, const FloatRect& bbox) -{ - if (bbox.isEmpty() || m_effects.isEmpty()) - return; - - SVGResourceFilterPlatformDataMac* platform = static_cast<SVGResourceFilterPlatformDataMac*>(platformData()); - - CGContextRef cgContext = context->platformContext(); - - // Use of CGBegin/EndTransparencyLayer around this call causes over release - // of cgContext due to it being created on an autorelease pool, and released - // after CGEndTransparencyLayer. Create local pool to fix. - // <http://bugs.webkit.org/show_bug.cgi?id=8425> - // <http://bugs.webkit.org/show_bug.cgi?id=6947> - // <rdar://problem/4647735> - NSAutoreleasePool* filterContextPool = [[NSAutoreleasePool alloc] init]; - platform->m_filterCIContext = [CIContext contextWithCGContext:cgContext options:nil]; - [filterContextPool drain]; - - FloatRect filterRect = filterBBoxForItemBBox(bbox); - - // TODO: Ensure the size is not greater than the nearest <svg> size and/or the window size. - // This is also needed for masking & gradients-on-stroke-of-text. File a bug on this. - float width = filterRect.width(); - float height = filterRect.height(); - - platform->m_filterCGLayer = [platform->m_filterCIContext.get() createCGLayerWithSize:CGSizeMake(width, height) info:NULL]; - - context = new GraphicsContext(CGLayerGetContext(platform->m_filterCGLayer)); - context->save(); - - context->translate(-filterRect.x(), -filterRect.y()); -} - -#ifndef NDEBUG -// Extremly helpful debugging utilities for any paint server / resource that creates -// internal image buffers (ie. gradients on text, masks, filters...) -void dumpCIOutputImage(CIImage* outputImage, NSString* fileName) -{ - CGSize extentSize = [outputImage extent].size; - NSImage* image = [[[NSImage alloc] initWithSize:NSMakeSize(extentSize.width, extentSize.height)] autorelease]; - [image addRepresentation:[NSCIImageRep imageRepWithCIImage:outputImage]]; - - NSData* imageData = [image TIFFRepresentation]; - NSBitmapImageRep* imageRep = [NSBitmapImageRep imageRepWithData:imageData]; - imageData = [imageRep representationUsingType:NSJPEGFileType properties:nil]; - - [imageData writeToFile:fileName atomically:YES]; -} - -void dumpCGOutputImage(CGImage* outputImage, NSString* fileName) -{ - if (CIImage* ciOutputImage = [CIImage imageWithCGImage:outputImage]) - dumpCIOutputImage(ciOutputImage, fileName); -} -#endif - -void SVGResourceFilter::applyFilter(GraphicsContext*& context, const FloatRect& bbox) -{ - if (bbox.isEmpty() || m_effects.isEmpty()) - return; - - SVGResourceFilterPlatformDataMac* platform = static_cast<SVGResourceFilterPlatformDataMac*>(platformData()); - - // actually apply the filter effects - CIImage* inputImage = [CIImage imageWithCGLayer:platform->m_filterCGLayer]; - NSArray* filterStack = platform->getCIFilterStack(inputImage, bbox); - if ([filterStack count]) { - CIImage* outputImage = [[filterStack lastObject] valueForKey:@"outputImage"]; - - if (outputImage) { -#if DEBUG_OUTPUT_IMAGE > 0 - dumpOutputImage(outputImage); -#endif - - FloatRect filterRect = filterBBoxForItemBBox(bbox); - FloatPoint destOrigin = filterRect.location(); - filterRect.setLocation(FloatPoint(0.0f, 0.0f)); - - [platform->m_filterCIContext.get() drawImage:outputImage atPoint:CGPoint(destOrigin) fromRect:filterRect]; - } - } - - CGLayerRelease(platform->m_filterCGLayer); - platform->m_filterCGLayer = 0; - - platform->m_filterCIContext = 0; - - delete context; - context = 0; -} - -} - -#endif // ENABLE(SVG) ENABLE(SVG_FILTERS) diff --git a/WebCore/svg/graphics/filters/SVGDistantLightSource.h b/WebCore/svg/graphics/filters/SVGDistantLightSource.h index 07ac16c..db9b59d 100644 --- a/WebCore/svg/graphics/filters/SVGDistantLightSource.h +++ b/WebCore/svg/graphics/filters/SVGDistantLightSource.h @@ -30,11 +30,10 @@ namespace WebCore { class DistantLightSource : public LightSource { public: - DistantLightSource(float azimuth, float elevation) - : LightSource(LS_DISTANT) - , m_azimuth(azimuth) - , m_elevation(elevation) - { } + static PassRefPtr<DistantLightSource> create(float azimuth, float elevation) + { + return adoptRef(new DistantLightSource(azimuth, elevation)); + } float azimuth() const { return m_azimuth; } float elevation() const { return m_elevation; } @@ -42,6 +41,13 @@ namespace WebCore { virtual TextStream& externalRepresentation(TextStream&) const; private: + DistantLightSource(float azimuth, float elevation) + : LightSource(LS_DISTANT) + , m_azimuth(azimuth) + , m_elevation(elevation) + { + } + float m_azimuth; float m_elevation; }; diff --git a/WebCore/svg/graphics/filters/SVGFEDiffuseLighting.cpp b/WebCore/svg/graphics/filters/SVGFEDiffuseLighting.cpp index c536478..93921df 100644 --- a/WebCore/svg/graphics/filters/SVGFEDiffuseLighting.cpp +++ b/WebCore/svg/graphics/filters/SVGFEDiffuseLighting.cpp @@ -30,7 +30,7 @@ namespace WebCore { FEDiffuseLighting::FEDiffuseLighting(FilterEffect* in , const Color& lightingColor, const float& surfaceScale, - const float& diffuseConstant, const float& kernelUnitLengthX, const float& kernelUnitLengthY, LightSource* lightSource) + const float& diffuseConstant, const float& kernelUnitLengthX, const float& kernelUnitLengthY, PassRefPtr<LightSource> lightSource) : FilterEffect() , m_in(in) , m_lightingColor(lightingColor) @@ -44,7 +44,7 @@ FEDiffuseLighting::FEDiffuseLighting(FilterEffect* in , const Color& lightingCol PassRefPtr<FEDiffuseLighting> FEDiffuseLighting::create(FilterEffect* in , const Color& lightingColor, const float& surfaceScale, const float& diffuseConstant, const float& kernelUnitLengthX, - const float& kernelUnitLengthY, LightSource* lightSource) + const float& kernelUnitLengthY, PassRefPtr<LightSource> lightSource) { return adoptRef(new FEDiffuseLighting(in, lightingColor, surfaceScale, diffuseConstant, kernelUnitLengthX, kernelUnitLengthY, lightSource)); } @@ -108,7 +108,7 @@ const LightSource* FEDiffuseLighting::lightSource() const return m_lightSource.get(); } -void FEDiffuseLighting::setLightSource(LightSource* lightSource) +void FEDiffuseLighting::setLightSource(PassRefPtr<LightSource> lightSource) { m_lightSource = lightSource; } diff --git a/WebCore/svg/graphics/filters/SVGFEDiffuseLighting.h b/WebCore/svg/graphics/filters/SVGFEDiffuseLighting.h index 71f8e22..bf7f28e 100644 --- a/WebCore/svg/graphics/filters/SVGFEDiffuseLighting.h +++ b/WebCore/svg/graphics/filters/SVGFEDiffuseLighting.h @@ -34,7 +34,7 @@ namespace WebCore { class FEDiffuseLighting : public FilterEffect { public: static PassRefPtr<FEDiffuseLighting> create(FilterEffect*, const Color&, const float&, const float&, - const float&, const float&, LightSource*); + const float&, const float&, PassRefPtr<LightSource>); virtual ~FEDiffuseLighting(); Color lightingColor() const; @@ -53,7 +53,7 @@ namespace WebCore { void setKernelUnitLengthY(float); const LightSource* lightSource() const; - void setLightSource(LightSource*); + void setLightSource(PassRefPtr<LightSource>); virtual FloatRect uniteChildEffectSubregions(Filter* filter) { return calculateUnionOfChildEffectSubregions(filter, m_in.get()); } void apply(Filter*); @@ -62,7 +62,7 @@ namespace WebCore { private: FEDiffuseLighting(FilterEffect*, const Color&, const float&, const float&, - const float&, const float&, LightSource*); + const float&, const float&, PassRefPtr<LightSource>); RefPtr<FilterEffect> m_in; Color m_lightingColor; diff --git a/WebCore/svg/graphics/filters/SVGFEDisplacementMap.cpp b/WebCore/svg/graphics/filters/SVGFEDisplacementMap.cpp index abb57ee..a22bc94 100644 --- a/WebCore/svg/graphics/filters/SVGFEDisplacementMap.cpp +++ b/WebCore/svg/graphics/filters/SVGFEDisplacementMap.cpp @@ -2,6 +2,7 @@ Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005 Rob Buis <buis@kde.org> 2005 Eric Seidel <eric@webkit.org> + 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 @@ -23,8 +24,12 @@ #if ENABLE(SVG) && ENABLE(FILTERS) #include "SVGFEDisplacementMap.h" -#include "SVGRenderTreeAsText.h" + +#include "CanvasPixelArray.h" #include "Filter.h" +#include "GraphicsContext.h" +#include "ImageData.h" +#include "SVGRenderTreeAsText.h" namespace WebCore { @@ -75,8 +80,53 @@ void FEDisplacementMap::setScale(float scale) m_scale = scale; } -void FEDisplacementMap::apply(Filter*) +void FEDisplacementMap::apply(Filter* filter) { + m_in->apply(filter); + m_in2->apply(filter); + if (!m_in->resultImage() || !m_in2->resultImage()) + return; + + if (m_xChannelSelector == CHANNEL_UNKNOWN || m_yChannelSelector == CHANNEL_UNKNOWN) + return; + + if (!getEffectContext()) + return; + + IntRect effectADrawingRect = calculateDrawingIntRect(m_in->scaledSubRegion()); + RefPtr<CanvasPixelArray> srcPixelArrayA(m_in->resultImage()->getPremultipliedImageData(effectADrawingRect)->data()); + + IntRect effectBDrawingRect = calculateDrawingIntRect(m_in2->scaledSubRegion()); + RefPtr<CanvasPixelArray> srcPixelArrayB(m_in2->resultImage()->getUnmultipliedImageData(effectBDrawingRect)->data()); + + IntRect imageRect(IntPoint(), resultImage()->size()); + RefPtr<ImageData> imageData = ImageData::create(imageRect.width(), imageRect.height()); + + ASSERT(srcPixelArrayA->length() == srcPixelArrayB->length()); + + float scaleX = m_scale / 255.f * filter->filterResolution().width(); + float scaleY = m_scale / 255.f * filter->filterResolution().height(); + float scaleAdjustmentX = (0.5f - 0.5f * m_scale) * filter->filterResolution().width(); + float scaleAdjustmentY = (0.5f - 0.5f * m_scale) * filter->filterResolution().height(); + int stride = imageRect.width() * 4; + for (int y = 0; y < imageRect.height(); ++y) { + int line = y * stride; + for (int x = 0; x < imageRect.width(); ++x) { + int dstIndex = line + x * 4; + int srcX = x + static_cast<int>(scaleX * srcPixelArrayB->get(dstIndex + m_xChannelSelector - 1) + scaleAdjustmentX); + int srcY = y + static_cast<int>(scaleY * srcPixelArrayB->get(dstIndex + m_yChannelSelector - 1) + scaleAdjustmentY); + for (unsigned channel = 0; channel < 4; ++channel) { + if (srcX < 0 || srcX >= imageRect.width() || srcY < 0 || srcY >= imageRect.height()) + imageData->data()->set(dstIndex + channel, static_cast<unsigned char>(0)); + else { + unsigned char pixelValue = srcPixelArrayA->get(srcY * stride + srcX * 4 + channel); + imageData->data()->set(dstIndex + channel, pixelValue); + } + } + + } + } + resultImage()->putPremultipliedImageData(imageData.get(), imageRect, IntPoint()); } void FEDisplacementMap::dump() diff --git a/WebCore/svg/graphics/filters/SVGFEFlood.cpp b/WebCore/svg/graphics/filters/SVGFEFlood.cpp index 3f4a6d7..648bf54 100644 --- a/WebCore/svg/graphics/filters/SVGFEFlood.cpp +++ b/WebCore/svg/graphics/filters/SVGFEFlood.cpp @@ -31,17 +31,16 @@ namespace WebCore { -FEFlood::FEFlood(FilterEffect* in, const Color& floodColor, const float& floodOpacity) +FEFlood::FEFlood(const Color& floodColor, const float& floodOpacity) : FilterEffect() - , m_in(in) , m_floodColor(floodColor) , m_floodOpacity(floodOpacity) { } -PassRefPtr<FEFlood> FEFlood::create(FilterEffect* in, const Color& floodColor, const float& floodOpacity) +PassRefPtr<FEFlood> FEFlood::create(const Color& floodColor, const float& floodOpacity) { - return adoptRef(new FEFlood(in, floodColor, floodOpacity)); + return adoptRef(new FEFlood(floodColor, floodOpacity)); } Color FEFlood::floodColor() const @@ -71,7 +70,7 @@ void FEFlood::apply(Filter*) return; Color color = colorWithOverrideAlpha(floodColor().rgb(), floodOpacity()); - filterContext->fillRect(FloatRect(FloatPoint(), subRegion().size()), color); + filterContext->fillRect(FloatRect(FloatPoint(), scaledSubRegion().size()), color, DeviceColorSpace); } void FEFlood::dump() diff --git a/WebCore/svg/graphics/filters/SVGFEFlood.h b/WebCore/svg/graphics/filters/SVGFEFlood.h index 21985db..91795dd 100644 --- a/WebCore/svg/graphics/filters/SVGFEFlood.h +++ b/WebCore/svg/graphics/filters/SVGFEFlood.h @@ -31,7 +31,7 @@ namespace WebCore { class FEFlood : public FilterEffect { public: - static PassRefPtr<FEFlood> create(FilterEffect*, const Color&, const float&); + static PassRefPtr<FEFlood> create(const Color&, const float&); Color floodColor() const; void setFloodColor(const Color &); @@ -44,9 +44,8 @@ namespace WebCore { TextStream& externalRepresentation(TextStream& ts) const; private: - FEFlood(FilterEffect*, const Color&, const float&); + FEFlood(const Color&, const float&); - RefPtr<FilterEffect> m_in; Color m_floodColor; float m_floodOpacity; }; diff --git a/WebCore/svg/graphics/filters/SVGFEGaussianBlur.cpp b/WebCore/svg/graphics/filters/SVGFEGaussianBlur.cpp deleted file mode 100644 index 601c39e..0000000 --- a/WebCore/svg/graphics/filters/SVGFEGaussianBlur.cpp +++ /dev/null @@ -1,82 +0,0 @@ -/* - Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org> - 2004, 2005 Rob Buis <buis@kde.org> - 2005 Eric Seidel <eric@webkit.org> - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - aint with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#include "config.h" - -#if ENABLE(SVG) && ENABLE(FILTERS) -#include "SVGFEGaussianBlur.h" -#include "SVGRenderTreeAsText.h" -#include "Filter.h" - -namespace WebCore { - -FEGaussianBlur::FEGaussianBlur(FilterEffect* in, const float& x, const float& y) - : FilterEffect() - , m_in(in) - , m_x(x) - , m_y(y) -{ -} - -PassRefPtr<FEGaussianBlur> FEGaussianBlur::create(FilterEffect* in, const float& x, const float& y) -{ - return adoptRef(new FEGaussianBlur(in, x, y)); -} - -float FEGaussianBlur::stdDeviationX() const -{ - return m_x; -} - -void FEGaussianBlur::setStdDeviationX(float x) -{ - m_x = x; -} - -float FEGaussianBlur::stdDeviationY() const -{ - return m_y; -} - -void FEGaussianBlur::setStdDeviationY(float y) -{ - m_y = y; -} - -void FEGaussianBlur::apply(Filter*) -{ -} - -void FEGaussianBlur::dump() -{ -} - -TextStream& FEGaussianBlur::externalRepresentation(TextStream& ts) const -{ - ts << "[type=GAUSSIAN-BLUR] "; - FilterEffect::externalRepresentation(ts); - ts << " [std dev. x=" << stdDeviationX() << " y=" << stdDeviationY() << "]"; - return ts; -} - -} // namespace WebCore - -#endif // ENABLE(SVG) && ENABLE(FILTERS) diff --git a/WebCore/svg/graphics/filters/SVGFEGaussianBlur.h b/WebCore/svg/graphics/filters/SVGFEGaussianBlur.h deleted file mode 100644 index 69f1cc5..0000000 --- a/WebCore/svg/graphics/filters/SVGFEGaussianBlur.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org> - 2004, 2005 Rob Buis <buis@kde.org> - 2005 Eric Seidel <eric@webkit.org> - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - aint with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#ifndef SVGFEGaussianBlur_h -#define SVGFEGaussianBlur_h - -#if ENABLE(SVG) && ENABLE(FILTERS) -#include "FilterEffect.h" -#include "Filter.h" - -namespace WebCore { - - class FEGaussianBlur : public FilterEffect { - public: - static PassRefPtr<FEGaussianBlur> create(FilterEffect*, const float&, const float&); - - float stdDeviationX() const; - void setStdDeviationX(float); - - float stdDeviationY() const; - void setStdDeviationY(float); - - virtual FloatRect uniteChildEffectSubregions(Filter* filter) { return calculateUnionOfChildEffectSubregions(filter, m_in.get()); } - void apply(Filter*); - void dump(); - TextStream& externalRepresentation(TextStream& ts) const; - - private: - FEGaussianBlur(FilterEffect*, const float&, const float&); - - RefPtr<FilterEffect> m_in; - float m_x; - float m_y; - }; - -} // namespace WebCore - -#endif // ENABLE(SVG) && ENABLE(FILTERS) - -#endif // SVGFEGaussianBlur_h diff --git a/WebCore/svg/graphics/filters/SVGFEMerge.cpp b/WebCore/svg/graphics/filters/SVGFEMerge.cpp index acf3c45..3f9ad38 100644 --- a/WebCore/svg/graphics/filters/SVGFEMerge.cpp +++ b/WebCore/svg/graphics/filters/SVGFEMerge.cpp @@ -78,8 +78,8 @@ void FEMerge::apply(Filter* filter) return; for (unsigned i = 0; i < m_mergeInputs.size(); i++) { - FloatRect destRect = calculateDrawingRect(m_mergeInputs[i]->subRegion()); - filterContext->drawImage(m_mergeInputs[i]->resultImage()->image(), destRect); + FloatRect destRect = calculateDrawingRect(m_mergeInputs[i]->scaledSubRegion()); + filterContext->drawImage(m_mergeInputs[i]->resultImage()->image(), DeviceColorSpace, destRect); } } diff --git a/WebCore/svg/graphics/filters/SVGFEMorphology.cpp b/WebCore/svg/graphics/filters/SVGFEMorphology.cpp index 3767734..20d109a 100644 --- a/WebCore/svg/graphics/filters/SVGFEMorphology.cpp +++ b/WebCore/svg/graphics/filters/SVGFEMorphology.cpp @@ -2,6 +2,7 @@ Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org> 2004, 2005 Rob Buis <buis@kde.org> 2005 Eric Seidel <eric@webkit.org> + 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 @@ -23,12 +24,20 @@ #if ENABLE(SVG) && ENABLE(FILTERS) #include "SVGFEMorphology.h" -#include "SVGRenderTreeAsText.h" + +#include "CanvasPixelArray.h" #include "Filter.h" +#include "ImageData.h" +#include "SVGRenderTreeAsText.h" + +#include <wtf/Vector.h> + +using std::min; +using std::max; namespace WebCore { -FEMorphology::FEMorphology(FilterEffect* in, MorphologyOperatorType type, const float& radiusX, const float& radiusY) +FEMorphology::FEMorphology(FilterEffect* in, MorphologyOperatorType type, float radiusX, float radiusY) : FilterEffect() , m_in(in) , m_type(type) @@ -37,7 +46,7 @@ FEMorphology::FEMorphology(FilterEffect* in, MorphologyOperatorType type, const { } -PassRefPtr<FEMorphology> FEMorphology::create(FilterEffect* in, MorphologyOperatorType type, const float& radiusX, const float& radiusY) +PassRefPtr<FEMorphology> FEMorphology::create(FilterEffect* in, MorphologyOperatorType type, float radiusX, float radiusY) { return adoptRef(new FEMorphology(in, type, radiusX, radiusY)); } @@ -72,8 +81,73 @@ void FEMorphology::setRadiusY(float radiusY) m_radiusY = radiusY; } -void FEMorphology::apply(Filter*) +void FEMorphology::apply(Filter* filter) { + m_in->apply(filter); + if (!m_in->resultImage()) + return; + + if (!getEffectContext()) + return; + + if (!m_radiusX || !m_radiusY) + return; + + IntRect imageRect(IntPoint(), resultImage()->size()); + IntRect effectDrawingRect = calculateDrawingIntRect(m_in->scaledSubRegion()); + RefPtr<CanvasPixelArray> srcPixelArray(m_in->resultImage()->getPremultipliedImageData(effectDrawingRect)->data()); + RefPtr<ImageData> imageData = ImageData::create(imageRect.width(), imageRect.height()); + + int radiusX = static_cast<int>(m_radiusX * filter->filterResolution().width()); + int radiusY = static_cast<int>(m_radiusY * filter->filterResolution().height()); + int effectWidth = effectDrawingRect.width() * 4; + + // Limit the radius size to effect width + radiusX = min(effectDrawingRect.width() - 1, radiusX); + + Vector<unsigned char> extrema; + for (int y = 0; y < effectDrawingRect.height(); ++y) { + int startY = max(0, y - radiusY); + int endY = min(effectDrawingRect.height() - 1, y + radiusY); + for (unsigned channel = 0; channel < 4; ++channel) { + // Fill the kernel + extrema.clear(); + for (int j = 0; j <= radiusX; ++j) { + unsigned char columnExtrema = srcPixelArray->get(startY * effectWidth + 4 * j + channel); + for (int i = startY; i <= endY; ++i) { + unsigned char pixel = srcPixelArray->get(i * effectWidth + 4 * j + channel); + if ((m_type == FEMORPHOLOGY_OPERATOR_ERODE && pixel <= columnExtrema) || + (m_type == FEMORPHOLOGY_OPERATOR_DILATE && pixel >= columnExtrema)) + columnExtrema = pixel; + } + extrema.append(columnExtrema); + } + + // Kernel is filled, get extrema of next column + for (int x = 0; x < effectDrawingRect.width(); ++x) { + unsigned endX = min(x + radiusX, effectDrawingRect.width() - 1); + unsigned char columnExtrema = srcPixelArray->get(startY * effectWidth + endX * 4 + channel); + for (int i = startY; i <= endY; ++i) { + unsigned char pixel = srcPixelArray->get(i * effectWidth + endX * 4 + channel); + if ((m_type == FEMORPHOLOGY_OPERATOR_ERODE && pixel <= columnExtrema) || + (m_type == FEMORPHOLOGY_OPERATOR_DILATE && pixel >= columnExtrema)) + columnExtrema = pixel; + } + if (x - radiusX >= 0) + extrema.remove(0); + if (x + radiusX <= effectDrawingRect.width()) + extrema.append(columnExtrema); + unsigned char entireExtrema = extrema[0]; + for (unsigned kernelIndex = 0; kernelIndex < extrema.size(); ++kernelIndex) { + if ((m_type == FEMORPHOLOGY_OPERATOR_ERODE && extrema[kernelIndex] <= entireExtrema) || + (m_type == FEMORPHOLOGY_OPERATOR_DILATE && extrema[kernelIndex] >= entireExtrema)) + entireExtrema = extrema[kernelIndex]; + } + imageData->data()->set(y * effectWidth + 4 * x + channel, entireExtrema); + } + } + } + resultImage()->putPremultipliedImageData(imageData.get(), imageRect, IntPoint()); } void FEMorphology::dump() @@ -88,8 +162,8 @@ static TextStream& operator<<(TextStream& ts, MorphologyOperatorType t) ts << "UNKNOWN"; break; case FEMORPHOLOGY_OPERATOR_ERODE: ts << "ERODE"; break; - case FEMORPHOLOGY_OPERATOR_DIALATE: - ts << "DIALATE"; break; + case FEMORPHOLOGY_OPERATOR_DILATE: + ts << "DILATE"; break; } return ts; } diff --git a/WebCore/svg/graphics/filters/SVGFEMorphology.h b/WebCore/svg/graphics/filters/SVGFEMorphology.h index bdc2b9b..6a321c8 100644 --- a/WebCore/svg/graphics/filters/SVGFEMorphology.h +++ b/WebCore/svg/graphics/filters/SVGFEMorphology.h @@ -31,12 +31,12 @@ namespace WebCore { enum MorphologyOperatorType { FEMORPHOLOGY_OPERATOR_UNKNOWN = 0, FEMORPHOLOGY_OPERATOR_ERODE = 1, - FEMORPHOLOGY_OPERATOR_DIALATE = 2 + FEMORPHOLOGY_OPERATOR_DILATE = 2 }; class FEMorphology : public FilterEffect { public: - PassRefPtr<FEMorphology> create(FilterEffect*, MorphologyOperatorType, const float&, const float&); + static PassRefPtr<FEMorphology> create(FilterEffect*, MorphologyOperatorType, float radiusX, float radiusY); MorphologyOperatorType morphologyOperator() const; void setMorphologyOperator(MorphologyOperatorType); @@ -52,7 +52,7 @@ namespace WebCore { TextStream& externalRepresentation(TextStream& ts) const; private: - FEMorphology(FilterEffect*, MorphologyOperatorType, const float&, const float&); + FEMorphology(FilterEffect*, MorphologyOperatorType, float radiusX, float radiusY); RefPtr<FilterEffect> m_in; MorphologyOperatorType m_type; diff --git a/WebCore/svg/graphics/filters/SVGFEOffset.cpp b/WebCore/svg/graphics/filters/SVGFEOffset.cpp index ce9ee3d..9fd50ed 100644 --- a/WebCore/svg/graphics/filters/SVGFEOffset.cpp +++ b/WebCore/svg/graphics/filters/SVGFEOffset.cpp @@ -74,17 +74,22 @@ void FEOffset::apply(Filter* filter) if (!filterContext) return; + FloatRect sourceImageRect = filter->sourceImageRect(); + sourceImageRect.scale(filter->filterResolution().width(), filter->filterResolution().height()); + if (filter->effectBoundingBoxMode()) { - setDx(dx() * filter->sourceImageRect().width()); - setDy(dy() * filter->sourceImageRect().height()); + m_dx *= sourceImageRect.width(); + m_dy *= sourceImageRect.height(); } + m_dx *= filter->filterResolution().width(); + m_dy *= filter->filterResolution().height(); - FloatRect dstRect = FloatRect(dx() + m_in->subRegion().x() - subRegion().x(), - dy() + m_in->subRegion().y() - subRegion().y(), - m_in->subRegion().width(), - m_in->subRegion().height()); + FloatRect dstRect = FloatRect(m_dx + m_in->scaledSubRegion().x() - scaledSubRegion().x(), + m_dy + m_in->scaledSubRegion().y() - scaledSubRegion().y(), + m_in->scaledSubRegion().width(), + m_in->scaledSubRegion().height()); - filterContext->drawImage(m_in->resultImage()->image(), dstRect); + filterContext->drawImage(m_in->resultImage()->image(), DeviceColorSpace, dstRect); } void FEOffset::dump() diff --git a/WebCore/svg/graphics/filters/SVGFESpecularLighting.cpp b/WebCore/svg/graphics/filters/SVGFESpecularLighting.cpp index eb0c280..0b43aba 100644 --- a/WebCore/svg/graphics/filters/SVGFESpecularLighting.cpp +++ b/WebCore/svg/graphics/filters/SVGFESpecularLighting.cpp @@ -30,7 +30,7 @@ namespace WebCore { FESpecularLighting::FESpecularLighting(FilterEffect* in, const Color& lightingColor, const float& surfaceScale, const float& specularConstant, const float& specularExponent, const float& kernelUnitLengthX, - const float& kernelUnitLengthY, LightSource* lightSource) + const float& kernelUnitLengthY, PassRefPtr<LightSource> lightSource) : FilterEffect() , m_in(in) , m_lightingColor(lightingColor) @@ -45,7 +45,7 @@ FESpecularLighting::FESpecularLighting(FilterEffect* in, const Color& lightingCo PassRefPtr<FESpecularLighting> FESpecularLighting::create(FilterEffect* in, const Color& lightingColor, const float& surfaceScale, const float& specularConstant, const float& specularExponent, - const float& kernelUnitLengthX, const float& kernelUnitLengthY, LightSource* lightSource) + const float& kernelUnitLengthX, const float& kernelUnitLengthY, PassRefPtr<LightSource> lightSource) { return adoptRef(new FESpecularLighting(in, lightingColor, surfaceScale, specularConstant, specularExponent, kernelUnitLengthX, kernelUnitLengthY, lightSource)); @@ -120,7 +120,7 @@ const LightSource* FESpecularLighting::lightSource() const return m_lightSource.get(); } -void FESpecularLighting::setLightSource(LightSource* lightSource) +void FESpecularLighting::setLightSource(PassRefPtr<LightSource> lightSource) { m_lightSource = lightSource; } diff --git a/WebCore/svg/graphics/filters/SVGFESpecularLighting.h b/WebCore/svg/graphics/filters/SVGFESpecularLighting.h index dec5163..f4947fd 100644 --- a/WebCore/svg/graphics/filters/SVGFESpecularLighting.h +++ b/WebCore/svg/graphics/filters/SVGFESpecularLighting.h @@ -33,7 +33,7 @@ namespace WebCore { class FESpecularLighting : public FilterEffect { public: static PassRefPtr<FESpecularLighting> create(FilterEffect*, const Color&, const float&, const float&, - const float&, const float&, const float&, LightSource*); + const float&, const float&, const float&, PassRefPtr<LightSource>); virtual ~FESpecularLighting(); Color lightingColor() const; @@ -55,7 +55,7 @@ namespace WebCore { void setKernelUnitLengthY(float); const LightSource* lightSource() const; - void setLightSource(LightSource*); + void setLightSource(PassRefPtr<LightSource>); virtual FloatRect uniteEffectRect(Filter* filter) { return calculateUnionOfChildEffectSubregions(filter, m_in.get()); } void apply(Filter*); @@ -64,7 +64,7 @@ namespace WebCore { private: FESpecularLighting(FilterEffect*, const Color&, const float&, const float&, const float&, - const float&, const float&, LightSource*); + const float&, const float&, PassRefPtr<LightSource>); RefPtr<FilterEffect> m_in; Color m_lightingColor; diff --git a/WebCore/svg/graphics/filters/SVGFETile.cpp b/WebCore/svg/graphics/filters/SVGFETile.cpp index 3071501..e97f68f 100644 --- a/WebCore/svg/graphics/filters/SVGFETile.cpp +++ b/WebCore/svg/graphics/filters/SVGFETile.cpp @@ -58,24 +58,27 @@ void FETile::apply(Filter* filter) if (!filterContext) return; - IntRect tileRect = enclosingIntRect(m_in->subRegion()); + IntRect tileRect = enclosingIntRect(m_in->scaledSubRegion()); // Source input needs more attention. It has the size of the filterRegion but gives the // size of the cutted sourceImage back. This is part of the specification and optimization. - if (m_in->isSourceInput()) - tileRect = enclosingIntRect(filter->filterRegion()); + if (m_in->isSourceInput()) { + FloatRect filterRegion = filter->filterRegion(); + filterRegion.scale(filter->filterResolution().width(), filter->filterResolution().height()); + tileRect = enclosingIntRect(filterRegion); + } OwnPtr<ImageBuffer> tileImage = ImageBuffer::create(tileRect.size()); GraphicsContext* tileImageContext = tileImage->context(); - tileImageContext->drawImage(m_in->resultImage()->image(), IntPoint()); + tileImageContext->drawImage(m_in->resultImage()->image(), DeviceColorSpace, IntPoint()); RefPtr<Pattern> pattern = Pattern::create(tileImage->image(), true, true); TransformationMatrix matrix; - matrix.translate(m_in->subRegion().x() - subRegion().x(), m_in->subRegion().y() - subRegion().y()); + matrix.translate(m_in->scaledSubRegion().x() - scaledSubRegion().x(), m_in->scaledSubRegion().y() - scaledSubRegion().y()); pattern.get()->setPatternSpaceTransform(matrix); filterContext->setFillPattern(pattern); - filterContext->fillRect(FloatRect(FloatPoint(), subRegion().size())); + filterContext->fillRect(FloatRect(FloatPoint(), scaledSubRegion().size())); } void FETile::dump() diff --git a/WebCore/svg/graphics/filters/SVGFilter.cpp b/WebCore/svg/graphics/filters/SVGFilter.cpp index c892ee9..4ec4e6e 100644 --- a/WebCore/svg/graphics/filters/SVGFilter.cpp +++ b/WebCore/svg/graphics/filters/SVGFilter.cpp @@ -24,20 +24,18 @@ namespace WebCore { -SVGFilter::SVGFilter(const FloatRect& itemBox, const FloatRect& filterRect, bool effectBBoxMode, bool filterBBoxMode) +SVGFilter::SVGFilter(const FloatRect& itemBox, const FloatRect& filterRect, bool effectBBoxMode) : Filter() , m_itemBox(itemBox) , m_filterRect(filterRect) , m_effectBBoxMode(effectBBoxMode) - , m_filterBBoxMode(filterBBoxMode) { } void SVGFilter::calculateEffectSubRegion(FilterEffect* effect) { - FloatRect subRegionBBox = effect->subRegion(); + FloatRect subRegionBBox = effect->effectBoundaries(); FloatRect useBBox = effect->unionOfChildEffectSubregions(); - FloatRect newSubRegion = subRegionBBox; if (m_effectBBoxMode) { @@ -55,28 +53,31 @@ void SVGFilter::calculateEffectSubRegion(FilterEffect* effect) if (effect->hasHeight()) newSubRegion.setHeight(subRegionBBox.height() * m_itemBox.height()); } else { - if (effect->xBoundingBoxMode()) - newSubRegion.setX(useBBox.x() + subRegionBBox.x() * useBBox.width()); + if (!effect->hasX()) + newSubRegion.setX(useBBox.x()); - if (effect->yBoundingBoxMode()) - newSubRegion.setY(useBBox.y() + subRegionBBox.y() * useBBox.height()); + if (!effect->hasY()) + newSubRegion.setY(useBBox.y()); - if (effect->widthBoundingBoxMode()) - newSubRegion.setWidth(subRegionBBox.width() * useBBox.width()); + if (!effect->hasWidth()) + newSubRegion.setWidth(useBBox.width()); - if (effect->heightBoundingBoxMode()) - newSubRegion.setHeight(subRegionBBox.height() * useBBox.height()); + if (!effect->hasHeight()) + newSubRegion.setHeight(useBBox.height()); } // clip every filter effect to the filter region newSubRegion.intersect(m_filterRect); effect->setSubRegion(newSubRegion); + newSubRegion.scale(filterResolution().width(), filterResolution().height()); + effect->setScaledSubRegion(newSubRegion); + m_maxImageSize = m_maxImageSize.expandedTo(newSubRegion.size()); } -PassRefPtr<SVGFilter> SVGFilter::create(const FloatRect& itemBox, const FloatRect& filterRect, bool effectBBoxMode, bool filterBBoxMode) +PassRefPtr<SVGFilter> SVGFilter::create(const FloatRect& itemBox, const FloatRect& filterRect, bool effectBBoxMode) { - return adoptRef(new SVGFilter(itemBox, filterRect, effectBBoxMode, filterBBoxMode)); + return adoptRef(new SVGFilter(itemBox, filterRect, effectBBoxMode)); } } // namespace WebCore diff --git a/WebCore/svg/graphics/filters/SVGFilter.h b/WebCore/svg/graphics/filters/SVGFilter.h index d6e5f77..c4714c6 100644 --- a/WebCore/svg/graphics/filters/SVGFilter.h +++ b/WebCore/svg/graphics/filters/SVGFilter.h @@ -24,6 +24,7 @@ #include "Filter.h" #include "FilterEffect.h" #include "FloatRect.h" +#include "FloatSize.h" #include <wtf/PassRefPtr.h> #include <wtf/RefCounted.h> @@ -33,21 +34,23 @@ namespace WebCore { class SVGFilter : public Filter { public: - static PassRefPtr<SVGFilter> create(const FloatRect&, const FloatRect&, bool, bool); + static PassRefPtr<SVGFilter> create(const FloatRect&, const FloatRect&, bool); - bool effectBoundingBoxMode() { return m_effectBBoxMode; } + virtual bool effectBoundingBoxMode() const { return m_effectBBoxMode; } - FloatRect filterRegion() { return m_filterRect; } - FloatRect sourceImageRect() { return m_itemBox; } - void calculateEffectSubRegion(FilterEffect*); + virtual FloatRect filterRegion() const { return m_filterRect; } + virtual FloatRect sourceImageRect() const { return m_itemBox; } + + virtual FloatSize maxImageSize() const { return m_maxImageSize; } + virtual void calculateEffectSubRegion(FilterEffect*); private: - SVGFilter(const FloatRect& itemBox, const FloatRect& filterRect, bool itemBBoxMode, bool filterBBoxMode); + SVGFilter(const FloatRect& itemBox, const FloatRect& filterRect, bool effectBBoxMode); + FloatSize m_maxImageSize; FloatRect m_itemBox; FloatRect m_filterRect; bool m_effectBBoxMode; - bool m_filterBBoxMode; }; } // namespace WebCore diff --git a/WebCore/svg/graphics/filters/SVGLightSource.h b/WebCore/svg/graphics/filters/SVGLightSource.h index 22b43c8..6f0075c 100644 --- a/WebCore/svg/graphics/filters/SVGLightSource.h +++ b/WebCore/svg/graphics/filters/SVGLightSource.h @@ -24,6 +24,7 @@ #define SVGLightSource_h #if ENABLE(SVG) && ENABLE(FILTERS) +#include <wtf/PassRefPtr.h> #include <wtf/RefCounted.h> namespace WebCore { diff --git a/WebCore/svg/graphics/filters/SVGPointLightSource.h b/WebCore/svg/graphics/filters/SVGPointLightSource.h index 772e278..1e966cc 100644 --- a/WebCore/svg/graphics/filters/SVGPointLightSource.h +++ b/WebCore/svg/graphics/filters/SVGPointLightSource.h @@ -31,16 +31,22 @@ namespace WebCore { class PointLightSource : public LightSource { public: - PointLightSource(const FloatPoint3D& position) - : LightSource(LS_POINT) - , m_position(position) - { } + static PassRefPtr<PointLightSource> create(const FloatPoint3D& position) + { + return adoptRef(new PointLightSource(position)); + } const FloatPoint3D& position() const { return m_position; } virtual TextStream& externalRepresentation(TextStream&) const; private: + PointLightSource(const FloatPoint3D& position) + : LightSource(LS_POINT) + , m_position(position) + { + } + FloatPoint3D m_position; }; diff --git a/WebCore/svg/graphics/filters/SVGSpotLightSource.h b/WebCore/svg/graphics/filters/SVGSpotLightSource.h index 9a787fb..05280d2 100644 --- a/WebCore/svg/graphics/filters/SVGSpotLightSource.h +++ b/WebCore/svg/graphics/filters/SVGSpotLightSource.h @@ -31,13 +31,11 @@ namespace WebCore { class SpotLightSource : public LightSource { public: - SpotLightSource(const FloatPoint3D& position, const FloatPoint3D& direction, float specularExponent, float limitingConeAngle) - : LightSource(LS_SPOT) - , m_position(position) - , m_direction(direction) - , m_specularExponent(specularExponent) - , m_limitingConeAngle(limitingConeAngle) - { } + static PassRefPtr<SpotLightSource> create(const FloatPoint3D& position, const FloatPoint3D& direction, + float specularExponent, float limitingConeAngle) + { + return adoptRef(new SpotLightSource(position, direction, specularExponent, limitingConeAngle)); + } const FloatPoint3D& position() const { return m_position; } const FloatPoint3D& direction() const { return m_direction; } @@ -48,6 +46,16 @@ namespace WebCore { virtual TextStream& externalRepresentation(TextStream&) const; private: + SpotLightSource(const FloatPoint3D& position, const FloatPoint3D& direction, + float specularExponent, float limitingConeAngle) + : LightSource(LS_SPOT) + , m_position(position) + , m_direction(direction) + , m_specularExponent(specularExponent) + , m_limitingConeAngle(limitingConeAngle) + { + } + FloatPoint3D m_position; FloatPoint3D m_direction; diff --git a/WebCore/svg/graphics/filters/cg/SVGFEHelpersCg.h b/WebCore/svg/graphics/filters/cg/SVGFEHelpersCg.h deleted file mode 100644 index f35e028..0000000 --- a/WebCore/svg/graphics/filters/cg/SVGFEHelpersCg.h +++ /dev/null @@ -1,88 +0,0 @@ -/* - Copyright (C) 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org> - - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - aint with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#if ENABLE(SVG) && ENABLE(SVG_FILTERS) - -#include "BlockExceptions.h" -#include "SVGFEDisplacementMap.h" -#include "SVGResourceFilter.h" -#include "SVGResourceFilterPlatformDataMac.h" -#include <QuartzCore/CoreImage.h> -#include <wtf/MathExtras.h> - -class Color; -class LightSource; - -namespace WebCore { - -CIVector* getVectorForChannel(ChannelSelectorType channel); -CIColor* ciColor(const Color& c); - -// Lighting -CIFilter* getPointLightVectors(CIFilter* normals, CIVector* lightPosition, float surfaceScale); -CIFilter* getLightVectors(CIFilter* normals, const LightSource* light, float surfaceScale); -CIFilter* getNormalMap(CIImage* bumpMap, float scale); - -}; - -// Macros used by the SVGFE*Cg classes -#define FE_QUARTZ_SETUP_INPUT(name) \ - SVGResourceFilterPlatformDataMac* filterPlatformData = static_cast<SVGResourceFilterPlatformDataMac*>(svgFilter->platformData()); \ - CIImage* inputImage = filterPlatformData->inputImage(this); \ - FE_QUARTZ_CHECK_INPUT(inputImage) \ - CIFilter* filter; \ - BEGIN_BLOCK_OBJC_EXCEPTIONS; \ - filter = [CIFilter filterWithName:name]; \ - [filter setDefaults]; \ - [filter setValue:inputImage forKey:@"inputImage"]; - -#define FE_QUARTZ_CHECK_INPUT(input) \ - if (!input) \ - return nil; - -#define FE_QUARTZ_OUTPUT_RETURN \ - filterPlatformData->setOutputImage(this, [filter valueForKey:@"outputImage"]); \ - return filter; \ - END_BLOCK_OBJC_EXCEPTIONS; \ - return nil; - -#define FE_QUARTZ_MAP_TO_SUBREGION_PREPARE(bbox) \ - FloatRect filterRect = svgFilter->filterBBoxForItemBBox(bbox); \ - FloatRect cropRect = primitiveBBoxForFilterBBox(filterRect, bbox); \ - cropRect.intersect(filterRect); \ - cropRect.move(-filterRect.x(), -filterRect.y()); - -#define FE_QUARTZ_MAP_TO_SUBREGION_APPLY(cropRect) \ - { \ - CIFilter* crop = [CIFilter filterWithName:@"CICrop"]; \ - [crop setDefaults]; \ - if (CIImage* currentFilterOutputImage = [filter valueForKey:@"outputImage"]) { \ - [crop setValue:currentFilterOutputImage forKey:@"inputImage"]; \ - [crop setValue:[CIVector vectorWithX:cropRect.x() Y:cropRect.y() Z:cropRect.width() W:cropRect.height()] forKey:@"inputRectangle"]; \ - filter = crop; \ - } \ - } - -#define FE_QUARTZ_MAP_TO_SUBREGION(bbox) \ - FE_QUARTZ_MAP_TO_SUBREGION_PREPARE(bbox); \ - FE_QUARTZ_MAP_TO_SUBREGION_APPLY(cropRect); - -#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS) diff --git a/WebCore/svg/graphics/filters/cg/SVGFEHelpersCg.mm b/WebCore/svg/graphics/filters/cg/SVGFEHelpersCg.mm deleted file mode 100644 index 399d4c1..0000000 --- a/WebCore/svg/graphics/filters/cg/SVGFEHelpersCg.mm +++ /dev/null @@ -1,162 +0,0 @@ -/* - Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org> - - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - aint with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#include "config.h" - -#if ENABLE(SVG) && ENABLE(SVG_FILTERS) -#include "SVGFEHelpersCg.h" - -#include "Color.h" -#include "SVGDistantLightSource.h" -#include "SVGLightSource.h" -#include "SVGPointLightSource.h" -#include "SVGSpotLightSource.h" - -#import "WKDistantLightFilter.h" -#import "WKNormalMapFilter.h" -#import "WKPointLightFilter.h" -#import "WKSpotLightFilter.h" - -#include <wtf/MathExtras.h> - -namespace WebCore { - -CIVector* getVectorForChannel(ChannelSelectorType channel) -{ - switch (channel) { - case CHANNEL_UNKNOWN: - return nil; - case CHANNEL_R: - return [CIVector vectorWithX:1.0f Y:0.0f Z:0.0f W:0.0f]; - case CHANNEL_G: - return [CIVector vectorWithX:0.0f Y:1.0f Z:0.0f W:0.0f]; - case CHANNEL_B: - return [CIVector vectorWithX:0.0f Y:0.0f Z:1.0f W:0.0f]; - case CHANNEL_A: - return [CIVector vectorWithX:0.0f Y:0.0f Z:0.0f W:1.0f]; - default: - return [CIVector vectorWithX:0.0f Y:0.0f Z:0.0f W:0.0f]; - } -} - -CIColor* ciColor(const Color& c) -{ - CGColorRef colorCG = createCGColor(c); - CIColor* colorCI = [CIColor colorWithCGColor:colorCG]; - CGColorRelease(colorCG); - return colorCI; -} - -// Lighting -CIFilter* getPointLightVectors(CIFilter* normals, CIVector* lightPosition, float surfaceScale) -{ - CIFilter* filter; - BEGIN_BLOCK_OBJC_EXCEPTIONS; - filter = [CIFilter filterWithName:@"WKPointLight"]; - if (!filter) - return nil; - [filter setDefaults]; - [filter setValue:[normals valueForKey:@"outputImage"] forKey:@"inputNormalMap"]; - [filter setValue:lightPosition forKey:@"inputLightPosition"]; - [filter setValue:[NSNumber numberWithFloat:surfaceScale] forKey:@"inputSurfaceScale"]; - return filter; - END_BLOCK_OBJC_EXCEPTIONS; - return nil; -} - -CIFilter* getLightVectors(CIFilter* normals, const LightSource* light, float surfaceScale) -{ - [WKDistantLightFilter class]; - [WKPointLightFilter class]; - [WKSpotLightFilter class]; - - CIFilter* filter = nil; - BEGIN_BLOCK_OBJC_EXCEPTIONS; - - switch (light->type()) { - case LS_DISTANT: - { - const DistantLightSource* dlight = static_cast<const DistantLightSource*>(light); - - filter = [CIFilter filterWithName:@"WKDistantLight"]; - if (!filter) - return nil; - [filter setDefaults]; - - float azimuth = dlight->azimuth(); - float elevation = dlight->elevation(); - azimuth = deg2rad(azimuth); - elevation = deg2rad(elevation); - float Lx = cosf(azimuth)*cosf(elevation); - float Ly = sinf(azimuth)*cosf(elevation); - float Lz = sinf(elevation); - - [filter setValue:[normals valueForKey:@"outputImage"] forKey:@"inputNormalMap"]; - [filter setValue:[CIVector vectorWithX:Lx Y:Ly Z:Lz] forKey:@"inputLightDirection"]; - return filter; - } - case LS_POINT: - { - const PointLightSource* plight = static_cast<const PointLightSource*>(light); - return getPointLightVectors(normals, [CIVector vectorWithX:plight->position().x() Y:plight->position().y() Z:plight->position().z()], surfaceScale); - } - case LS_SPOT: - { - const SpotLightSource* slight = static_cast<const SpotLightSource*>(light); - filter = [CIFilter filterWithName:@"WKSpotLight"]; - if (!filter) - return nil; - - CIFilter* pointLightFilter = getPointLightVectors(normals, [CIVector vectorWithX:slight->position().x() Y:slight->position().y() Z:slight->position().z()], surfaceScale); - if (!pointLightFilter) - return nil; - [filter setDefaults]; - - [filter setValue:[pointLightFilter valueForKey:@"outputImage"] forKey:@"inputLightVectors"]; - [filter setValue:[CIVector vectorWithX:slight->direction().x() Y:slight->direction().y() Z:slight->direction().z()] forKey:@"inputLightDirection"]; - [filter setValue:[NSNumber numberWithFloat:slight->specularExponent()] forKey:@"inputSpecularExponent"]; - [filter setValue:[NSNumber numberWithFloat:deg2rad(slight->limitingConeAngle())] forKey:@"inputLimitingConeAngle"]; - return filter; - } - } - - END_BLOCK_OBJC_EXCEPTIONS; - return nil; -} - -CIFilter* getNormalMap(CIImage* bumpMap, float scale) -{ - [WKNormalMapFilter class]; - CIFilter* filter; - BEGIN_BLOCK_OBJC_EXCEPTIONS; - filter = [CIFilter filterWithName:@"WKNormalMap"]; - [filter setDefaults]; - - [filter setValue:bumpMap forKey:@"inputImage"]; - [filter setValue:[NSNumber numberWithFloat:scale] forKey:@"inputSurfaceScale"]; - return filter; - END_BLOCK_OBJC_EXCEPTIONS; - return nil; -} - -} - -#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS) diff --git a/WebCore/svg/graphics/filters/cg/SVGFilterEffectCg.mm b/WebCore/svg/graphics/filters/cg/SVGFilterEffectCg.mm deleted file mode 100644 index 4b0a233..0000000 --- a/WebCore/svg/graphics/filters/cg/SVGFilterEffectCg.mm +++ /dev/null @@ -1,37 +0,0 @@ -/* - Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org> - - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - aint with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#include "config.h" - -#if ENABLE(SVG) && ENABLE(SVG_FILTERS) - -#include "SVGFilterEffect.h" - -namespace WebCore { - -CIFilter* SVGFilterEffect::getCIFilter(const FloatRect& bbox) const -{ - return nil; -} - -} - -#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS) diff --git a/WebCore/svg/graphics/filters/cg/WKArithmeticFilter.cikernel b/WebCore/svg/graphics/filters/cg/WKArithmeticFilter.cikernel deleted file mode 100644 index 3c32c3a..0000000 --- a/WebCore/svg/graphics/filters/cg/WKArithmeticFilter.cikernel +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (C) 2005 Oliver Hunt <ojh16@student.canterbury.ac.nz>. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -kernel vec4 arithmeticComposite(sampler in1, sampler in2, float k1, float k2, float k3, float k4) -{ - vec4 vin1 = sample(in1, samplerCoord(in1)); - vec4 vin2 = sample(in2, samplerCoord(in2)); - vec4 res = k1*vin1*vin2 + k2*vin1 + k3*vin2 + vec4(k4); - return res; -} diff --git a/WebCore/svg/graphics/filters/cg/WKArithmeticFilter.h b/WebCore/svg/graphics/filters/cg/WKArithmeticFilter.h deleted file mode 100644 index 4693853..0000000 --- a/WebCore/svg/graphics/filters/cg/WKArithmeticFilter.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (C) 2005 Oliver Hunt <ojh16@student.canterbury.ac.nz>. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#import <QuartzCore/CoreImage.h> - -#if ENABLE(SVG) && ENABLE(SVG_FILTERS) - -@interface WKArithmeticFilter : CIFilter { - CIImage *inputImage; - CIImage *inputBackgroundImage; - NSNumber *inputK1; - NSNumber *inputK2; - NSNumber *inputK3; - NSNumber *inputK4; -} - -@end - -#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS) diff --git a/WebCore/svg/graphics/filters/cg/WKArithmeticFilter.m b/WebCore/svg/graphics/filters/cg/WKArithmeticFilter.m deleted file mode 100644 index 389f25d..0000000 --- a/WebCore/svg/graphics/filters/cg/WKArithmeticFilter.m +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright (C) 2005 Oliver Hunt <ojh16@student.canterbury.ac.nz>. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#import "config.h" -#import "WKArithmeticFilter.h" - -#if ENABLE(SVG) && ENABLE(SVG_FILTERS) - -static CIKernel *arithmeticFilter = nil; - -@implementation WKArithmeticFilter -+ (void)initialize -{ - [CIFilter registerFilterName:@"WKArithmeticFilter" - constructor:self - classAttributes:[NSDictionary dictionaryWithObjectsAndKeys: - @"WebKit Arithmetic Filter", kCIAttributeFilterDisplayName, - [NSArray arrayWithObjects:kCICategoryStylize, kCICategoryVideo, - kCICategoryStillImage, kCICategoryNonSquarePixels,nil], kCIAttributeFilterCategories, - [NSDictionary dictionaryWithObjectsAndKeys: - [NSNumber numberWithDouble:0.0], kCIAttributeMin, - [NSNumber numberWithDouble:0.0], kCIAttributeDefault, - [NSNumber numberWithDouble:1.0], kCIAttributeIdentity, - kCIAttributeTypeScalar, kCIAttributeType, - nil], @"inputK1", - [NSDictionary dictionaryWithObjectsAndKeys: - [NSNumber numberWithDouble:0.0], kCIAttributeMin, - [NSNumber numberWithDouble:0.0], kCIAttributeDefault, - [NSNumber numberWithDouble:1.0], kCIAttributeIdentity, - kCIAttributeTypeScalar, kCIAttributeType, - nil], @"inputK2", - [NSDictionary dictionaryWithObjectsAndKeys: - [NSNumber numberWithDouble:0.0], kCIAttributeMin, - [NSNumber numberWithDouble:0.0], kCIAttributeDefault, - [NSNumber numberWithDouble:1.0], kCIAttributeIdentity, - kCIAttributeTypeScalar, kCIAttributeType, - nil], @"inputK3", - [NSDictionary dictionaryWithObjectsAndKeys: - [NSNumber numberWithDouble:0.0], kCIAttributeMin, - [NSNumber numberWithDouble:0.0], kCIAttributeDefault, - [NSNumber numberWithDouble:1.0], kCIAttributeIdentity, - kCIAttributeTypeScalar, kCIAttributeType, - nil], @"inputK4", - nil]]; -} - -+ (CIFilter *)filterWithName:(NSString *)name -{ - return [[[self alloc] init] autorelease]; -} - -- (id)init -{ - if (!arithmeticFilter) { - NSBundle *bundle = [NSBundle bundleForClass:[self class]]; - NSString *kernelFile = [bundle pathForResource:@"WKArithmeticFilter" ofType:@"cikernel"]; - NSString *code = [NSString stringWithContentsOfFile:kernelFile encoding:NSUTF8StringEncoding error:0]; - NSArray *kernels = [CIKernel kernelsWithString:code]; - arithmeticFilter = [[kernels objectAtIndex:0] retain]; - } - return [super init]; -} - -- (CIImage *)outputImage -{ - return [self apply:arithmeticFilter, inputImage, inputBackgroundImage, inputK1, inputK2, inputK3, - inputK4, nil]; -} - -@end - -#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS) diff --git a/WebCore/svg/graphics/filters/cg/WKComponentMergeFilter.cikernel b/WebCore/svg/graphics/filters/cg/WKComponentMergeFilter.cikernel deleted file mode 100644 index f33f20c..0000000 --- a/WebCore/svg/graphics/filters/cg/WKComponentMergeFilter.cikernel +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (C) 2006 Oliver Hunt <ojh16@student.canterbury.ac.nz>. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -kernel vec4 mergeComponents(sampler funcR, sampler funcG, sampler funcB, sampler funcA) -{ - float r = sample(funcR, samplerCoord(funcR)).r; - float g = sample(funcG, samplerCoord(funcG)).g; - float b = sample(funcB, samplerCoord(funcB)).b; - float a = sample(funcA, samplerCoord(funcA)).a; - return vec4(r, g, b, a); -} diff --git a/WebCore/svg/graphics/filters/cg/WKComponentMergeFilter.h b/WebCore/svg/graphics/filters/cg/WKComponentMergeFilter.h deleted file mode 100644 index 778e326..0000000 --- a/WebCore/svg/graphics/filters/cg/WKComponentMergeFilter.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (C) 2006 Oliver Hunt <ojh16@student.canterbury.ac.nz>. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#import <QuartzCore/CoreImage.h> - -#if ENABLE(SVG) && ENABLE(SVG_FILTERS) - -@interface WKComponentMergeFilter : CIFilter { - CIImage *inputFuncR; - CIImage *inputFuncG; - CIImage *inputFuncB; - CIImage *inputFuncA; -} - -@end - -#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS) diff --git a/WebCore/svg/graphics/filters/cg/WKComponentMergeFilter.m b/WebCore/svg/graphics/filters/cg/WKComponentMergeFilter.m deleted file mode 100644 index 4f2045a..0000000 --- a/WebCore/svg/graphics/filters/cg/WKComponentMergeFilter.m +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (C) 2006 Oliver Hunt <ojh16@student.canterbury.ac.nz>. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#import "config.h" -#import "WKComponentMergeFilter.h" - -#if ENABLE(SVG) && ENABLE(SVG_FILTERS) - -static CIKernel *componentMergeFilter = nil; - -@implementation WKComponentMergeFilter -+ (void)initialize -{ - [CIFilter registerFilterName:@"WKComponentMerge" - constructor:self - classAttributes:[NSDictionary dictionaryWithObjectsAndKeys: - @"WebKit Component Merge", kCIAttributeFilterDisplayName, - [NSArray arrayWithObjects:kCICategoryStylize, kCICategoryVideo, - kCICategoryStillImage, kCICategoryNonSquarePixels,nil], kCIAttributeFilterCategories, - nil]]; -} - -+ (CIFilter *)filterWithName:(NSString *)name -{ - return [[[self alloc] init] autorelease]; -} - -- (id)init -{ - if (!componentMergeFilter) { - NSBundle *bundle = [NSBundle bundleForClass:[self class]]; - NSString *kernelFile = [bundle pathForResource:@"WKComponentMergeFilter" ofType:@"cikernel"]; - NSString *code = [NSString stringWithContentsOfFile:kernelFile encoding:NSUTF8StringEncoding error:0]; - NSArray *kernels = [CIKernel kernelsWithString:code]; - componentMergeFilter = [[kernels objectAtIndex:0] retain]; - } - return [super init]; -} - -- (CIImage *)outputImage -{ - return [self apply:componentMergeFilter, [CISampler samplerWithImage: inputFuncR], - [CISampler samplerWithImage: inputFuncG], [CISampler samplerWithImage: inputFuncB], [CISampler samplerWithImage: inputFuncA], @"definition", [inputFuncR definition], nil]; -} - -@end - -#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS) diff --git a/WebCore/svg/graphics/filters/cg/WKDiffuseLightingFilter.cikernel b/WebCore/svg/graphics/filters/cg/WKDiffuseLightingFilter.cikernel deleted file mode 100644 index 870956a..0000000 --- a/WebCore/svg/graphics/filters/cg/WKDiffuseLightingFilter.cikernel +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (C) 2005 Oliver Hunt <ojh16@student.canterbury.ac.nz>. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -kernel vec4 diffuseLighting(sampler normalVectors, sampler lightVectors, __color lightingColor, - float surfaceScale, float diffuseConstant, float kernelLengthX, float kernelLengthY) -{ - vec2 pos = samplerCoord(lightVectors); - vec2 posn = samplerCoord(normalVectors); - vec4 l4 = sample(lightVectors, pos); - vec3 l = l4.xyz; - l = normalize(l); - vec3 n = sample(normalVectors, posn).xyz; - float nl = dot(l, n) * diffuseConstant; - vec4 res = vec4(lightingColor.r * nl, lightingColor.g * nl, lightingColor.b * nl, 1.0); - res.xyz *= l4.w; - return res; -} diff --git a/WebCore/svg/graphics/filters/cg/WKDiffuseLightingFilter.h b/WebCore/svg/graphics/filters/cg/WKDiffuseLightingFilter.h deleted file mode 100644 index 2731986..0000000 --- a/WebCore/svg/graphics/filters/cg/WKDiffuseLightingFilter.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (C) 2005 Apple Computer, Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#import <QuartzCore/CoreImage.h> - -#if ENABLE(SVG) && ENABLE(SVG_FILTERS) - -@interface WKDiffuseLightingFilter : CIFilter { - CISampler *inputNormalMap; - CISampler *inputLightVectors; - CIColor *inputLightingColor; - NSNumber *inputSurfaceScale; - NSNumber *inputDiffuseConstant; - NSNumber *inputKernelUnitLengthX; - NSNumber *inputKernelUnitLengthY; -} -@end - -#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS) diff --git a/WebCore/svg/graphics/filters/cg/WKDiffuseLightingFilter.m b/WebCore/svg/graphics/filters/cg/WKDiffuseLightingFilter.m deleted file mode 100644 index 3675af8..0000000 --- a/WebCore/svg/graphics/filters/cg/WKDiffuseLightingFilter.m +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright (C) 2005 Apple Computer, Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#import "config.h" -#import "WKDiffuseLightingFilter.h" - -#if ENABLE(SVG) && ENABLE(SVG_FILTERS) - -static CIKernel *diffuseLightingFilter = nil; -@implementation WKDiffuseLightingFilter - -+ (void)initialize -{ - [CIFilter registerFilterName:@"WKDiffuseLighting" - constructor:self - classAttributes:[NSDictionary dictionaryWithObjectsAndKeys: - @"WebKit Diffuse Lighting", kCIAttributeFilterDisplayName, - [NSArray arrayWithObjects:kCICategoryStylize, kCICategoryVideo, - kCICategoryStillImage, kCICategoryNonSquarePixels,nil], kCIAttributeFilterCategories, - [NSDictionary dictionaryWithObjectsAndKeys: - [CIColor colorWithRed:1.0f green:1.0f blue:1.0f alpha:1.0f], - kCIAttributeDefault, nil], @"inputLightingColor", - [NSDictionary dictionaryWithObjectsAndKeys: - [NSNumber numberWithDouble:0.0], kCIAttributeMin, - [NSNumber numberWithDouble:1.0], kCIAttributeDefault, - [NSNumber numberWithDouble:1.0], kCIAttributeIdentity, - kCIAttributeTypeScalar, kCIAttributeType, - nil], @"inputSurfaceScale", - [NSDictionary dictionaryWithObjectsAndKeys: - [NSNumber numberWithDouble:0.0], kCIAttributeMin, - [NSNumber numberWithDouble:1.0], kCIAttributeDefault, - [NSNumber numberWithDouble:1.0], kCIAttributeIdentity, - kCIAttributeTypeScalar, kCIAttributeType, - nil], @"inputDiffuseConstant", - [NSDictionary dictionaryWithObjectsAndKeys: - [NSNumber numberWithDouble:0.0], kCIAttributeMin, - [NSNumber numberWithDouble:1.0], kCIAttributeDefault, - [NSNumber numberWithDouble:1.0], kCIAttributeIdentity, - kCIAttributeTypeScalar, kCIAttributeType, - nil], @"inputKernelUnitLengthX", - [NSDictionary dictionaryWithObjectsAndKeys: - [NSNumber numberWithDouble:0.0], kCIAttributeMin, - [NSNumber numberWithDouble:1.0], kCIAttributeDefault, - [NSNumber numberWithDouble:1.0], kCIAttributeIdentity, - kCIAttributeTypeScalar, kCIAttributeType, - nil], @"inputKernelUnitLengthY", - nil]]; -} - -+ (CIFilter *)filterWithName:(NSString *)name -{ - return [[[self alloc] init] autorelease]; -} - -- (id)init -{ - if (!diffuseLightingFilter) { - NSBundle *bundle = [NSBundle bundleForClass:[self class]]; - NSString *kernelFile = [bundle pathForResource:@"WKDiffuseLightingFilter" ofType:@"cikernel"]; - NSString *code = [NSString stringWithContentsOfFile:kernelFile encoding:NSUTF8StringEncoding error:0]; - NSArray *kernels = [CIKernel kernelsWithString:code]; - diffuseLightingFilter = [[kernels objectAtIndex:0] retain]; - } - return [super init]; -} - -- (CIImage *)outputImage -{ - return [self apply:diffuseLightingFilter, inputNormalMap, inputLightVectors, inputLightingColor, inputSurfaceScale, inputDiffuseConstant, - inputKernelUnitLengthX, inputKernelUnitLengthY, nil]; -} - -@end - -#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS) diff --git a/WebCore/svg/graphics/filters/cg/WKDiscreteTransferFilter.cikernel b/WebCore/svg/graphics/filters/cg/WKDiscreteTransferFilter.cikernel deleted file mode 100644 index db3cefd..0000000 --- a/WebCore/svg/graphics/filters/cg/WKDiscreteTransferFilter.cikernel +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (C) 2006 Oliver Hunt <ojh16@student.canterbury.ac.nz>. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -kernel vec4 discreteTransfer(sampler image, sampler table, vec4 rgbaSelector, float maxIndex) -{ - vec4 C = sample(image, samplerCoord(image)); - float k = floor(dot(rgbaSelector, C) * maxIndex); - vec4 res = sample(table, vec2(k+0.0, 0.0)); - return res; -} diff --git a/WebCore/svg/graphics/filters/cg/WKDiscreteTransferFilter.h b/WebCore/svg/graphics/filters/cg/WKDiscreteTransferFilter.h deleted file mode 100644 index d444c75..0000000 --- a/WebCore/svg/graphics/filters/cg/WKDiscreteTransferFilter.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (C) 2006 Oliver Hunt <ojh16@student.canterbury.ac.nz>. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#import <QuartzCore/CoreImage.h> - -#if ENABLE(SVG) && ENABLE(SVG_FILTERS) - -@interface WKDiscreteTransferFilter : CIFilter { - CIImage *inputImage; - CIImage *inputTable; - CIVector *inputSelector; -} - -@end - -#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS) diff --git a/WebCore/svg/graphics/filters/cg/WKDiscreteTransferFilter.m b/WebCore/svg/graphics/filters/cg/WKDiscreteTransferFilter.m deleted file mode 100644 index dc6ca76..0000000 --- a/WebCore/svg/graphics/filters/cg/WKDiscreteTransferFilter.m +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (C) 2006 Oliver Hunt <ojh16@student.canterbury.ac.nz>. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#import "config.h" -#import "WKDiscreteTransferFilter.h" - -#if ENABLE(SVG) && ENABLE(SVG_FILTERS) - -static CIKernel *discreteTransferFilter = nil; - -@implementation WKDiscreteTransferFilter -+ (void)initialize -{ - [CIFilter registerFilterName:@"WKDiscreteTransfer" - constructor:self - classAttributes:[NSDictionary dictionaryWithObjectsAndKeys: - @"WebKit Discrete Transfer", kCIAttributeFilterDisplayName, - [NSArray arrayWithObjects:kCICategoryStylize, kCICategoryVideo, - kCICategoryStillImage, kCICategoryNonSquarePixels,nil], kCIAttributeFilterCategories, - nil]]; -} - -+ (CIFilter *)filterWithName:(NSString *)name -{ - return [[[self alloc] init] autorelease]; -} - -- (id)init -{ - if (!discreteTransferFilter) { - NSBundle *bundle = [NSBundle bundleForClass:[self class]]; - NSString *kernelFile = [bundle pathForResource:@"WKDiscreteTransferFilter" ofType:@"cikernel"]; - NSString *code = [NSString stringWithContentsOfFile:kernelFile encoding:NSUTF8StringEncoding error:0]; - NSArray *kernels = [CIKernel kernelsWithString:code]; - discreteTransferFilter = [[kernels objectAtIndex:0] retain]; - } - return [super init]; -} - -- (CIImage *)outputImage -{ - CISampler *inputSampler = [CISampler samplerWithImage: inputImage]; - CISampler *tableSampler = [CISampler samplerWithImage: inputTable keysAndValues:kCISamplerFilterMode, kCISamplerFilterNearest, kCISamplerWrapMode, kCISamplerWrapClamp, nil]; - NSArray *args = [NSArray arrayWithObjects:inputSampler, tableSampler, inputSelector, - [NSNumber numberWithDouble:[inputTable extent].size.width - 1.0f], @"definition", [inputSampler definition], nil]; - return [self apply:discreteTransferFilter arguments:args options:nil]; -} - -@end - -#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS) diff --git a/WebCore/svg/graphics/filters/cg/WKDisplacementMapFilter.cikernel b/WebCore/svg/graphics/filters/cg/WKDisplacementMapFilter.cikernel deleted file mode 100644 index 95b19c6..0000000 --- a/WebCore/svg/graphics/filters/cg/WKDisplacementMapFilter.cikernel +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (C) 2006 Oliver Hunt <ojh16@student.canterbury.ac.nz>. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * Performs the transformation: - * P'(x,y) <- P( x + scale * (XC(x,y) - .5), y + scale * (YC(x,y) - .5)) - * - * x/ychannel arguments are used to select the appropriate channel for x and - * y displacement. Hence each vector should have only one non-zero element, - * which should have the value 1.0. - * - */ - -kernel vec4 displacementMap(sampler image, sampler map, vec4 xchannel, vec4 ychannel, float scale) -{ - vec2 samplePos = samplerCoord(image); - vec4 XCYC = sample(map, samplerCoord(map)); - float xc = dot(XCYC, xchannel); - float yc = dot(XCYC, ychannel); - samplePos.x += scale*(xc-0.5); - samplePos.y += scale*(yc-0.5); - return sample(image, samplePos); -} diff --git a/WebCore/svg/graphics/filters/cg/WKDisplacementMapFilter.h b/WebCore/svg/graphics/filters/cg/WKDisplacementMapFilter.h deleted file mode 100644 index e594495..0000000 --- a/WebCore/svg/graphics/filters/cg/WKDisplacementMapFilter.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (C) 2006 Oliver Hunt <ojh16@student.canterbury.ac.nz>. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#import <QuartzCore/CoreImage.h> - -#if ENABLE(SVG) && ENABLE(SVG_FILTERS) - -@interface WKDisplacementMapFilter : CIFilter { - CIImage *inputImage; - CIImage *inputDisplacementMap; - CIVector *inputXChannelSelector; - CIVector *inputYChannelSelector; - NSNumber *inputScale; -} - -@end - -#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS) diff --git a/WebCore/svg/graphics/filters/cg/WKDisplacementMapFilter.m b/WebCore/svg/graphics/filters/cg/WKDisplacementMapFilter.m deleted file mode 100644 index 8ccd52c..0000000 --- a/WebCore/svg/graphics/filters/cg/WKDisplacementMapFilter.m +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (C) 2006 Oliver Hunt <ojh16@student.canterbury.ac.nz>. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#import "config.h" -#import "WKDisplacementMapFilter.h" - -#if ENABLE(SVG) && ENABLE(SVG_FILTERS) - -static CIKernel *displacementMapFilter = nil; - -@implementation WKDisplacementMapFilter - -+ (void)initialize -{ - [CIFilter registerFilterName:@"WKDisplacementMapFilter" - constructor:self - classAttributes:[NSDictionary dictionaryWithObjectsAndKeys: - @"WebKit Displacement Map Filter", kCIAttributeFilterDisplayName, - [NSArray arrayWithObjects:kCICategoryStylize, kCICategoryVideo, - kCICategoryStillImage, kCICategoryNonSquarePixels,nil], kCIAttributeFilterCategories, - [NSDictionary dictionaryWithObjectsAndKeys: - [CIVector vectorWithX:1.0f Y:0.0f Z:0.0f W:0.0f], - kCIAttributeDefault, nil], @"inputXChannelSelector", - [NSDictionary dictionaryWithObjectsAndKeys: - [CIVector vectorWithX:0.0f Y:1.0f Z:0.0f W:0.0f], - kCIAttributeDefault, nil], @"inputYChannelSelector", - [NSDictionary dictionaryWithObjectsAndKeys: - [NSNumber numberWithDouble:0.0], kCIAttributeDefault, - [NSNumber numberWithDouble:0.0], kCIAttributeIdentity, - kCIAttributeTypeScalar, kCIAttributeType, - nil], @"inputScale", - nil]]; -} - -+ (CIFilter *)filterWithName:(NSString *)name -{ - return [[[self alloc] init] autorelease]; -} - -- (id)init -{ - if (!displacementMapFilter) { - NSBundle *bundle = [NSBundle bundleForClass:[self class]]; - NSString *kernelFile = [bundle pathForResource:@"WKDisplacementMapFilter" ofType:@"cikernel"]; - NSString *code = [NSString stringWithContentsOfFile:kernelFile encoding:NSUTF8StringEncoding error:0]; - NSArray *kernels = [CIKernel kernelsWithString:code]; - displacementMapFilter = [[kernels objectAtIndex:0] retain]; - } - return [super init]; -} - -- (CIImage *)outputImage -{ - return [self apply:displacementMapFilter, inputImage, inputDisplacementMap, inputXChannelSelector, inputYChannelSelector, inputScale, nil]; -} - -@end - -#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS) diff --git a/WebCore/svg/graphics/filters/cg/WKDistantLightFilter.cikernel b/WebCore/svg/graphics/filters/cg/WKDistantLightFilter.cikernel deleted file mode 100644 index c14677c..0000000 --- a/WebCore/svg/graphics/filters/cg/WKDistantLightFilter.cikernel +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (C) 2005 Oliver Hunt <ojh16@student.canterbury.ac.nz>. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -kernel vec4 distantLightGenerator(sampler image, vec3 direction) -{ - return vec4(direction.x, direction.y, direction.z, 1.0); -} diff --git a/WebCore/svg/graphics/filters/cg/WKDistantLightFilter.h b/WebCore/svg/graphics/filters/cg/WKDistantLightFilter.h deleted file mode 100644 index e5fe15a..0000000 --- a/WebCore/svg/graphics/filters/cg/WKDistantLightFilter.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (C) 2005 Apple Computer, Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#import <QuartzCore/CoreImage.h> - -#if ENABLE(SVG) && ENABLE(SVG_FILTERS) - -@interface WKDistantLightFilter : CIFilter { - CIImage * inputNormalMap; - CIVector * inputLightDirection; -} -@end - -#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS) diff --git a/WebCore/svg/graphics/filters/cg/WKDistantLightFilter.m b/WebCore/svg/graphics/filters/cg/WKDistantLightFilter.m deleted file mode 100644 index 29e3caf..0000000 --- a/WebCore/svg/graphics/filters/cg/WKDistantLightFilter.m +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (C) 2005 Apple Computer, Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#import "config.h" -#import "WKDistantLightFilter.h" - -#if ENABLE(SVG) && ENABLE(SVG_FILTERS) - -static CIKernel *distantLightFilter = nil; - -@implementation WKDistantLightFilter - -+ (void)initialize -{ - [CIFilter registerFilterName:@"WKDistantLight" - constructor:self - classAttributes:[NSDictionary dictionaryWithObjectsAndKeys: - @"WebKit Distant Light", kCIAttributeFilterDisplayName, - [NSArray arrayWithObjects:kCICategoryStylize, kCICategoryVideo, - kCICategoryStillImage, kCICategoryNonSquarePixels,nil], kCIAttributeFilterCategories, - [NSDictionary dictionaryWithObjectsAndKeys: - kCIAttributeTypePosition3, kCIAttributeType, - nil], @"inputLightDirection", - nil]]; -} - -+ (CIFilter *)filterWithName:(NSString *)name -{ - return [[[self alloc] init] autorelease]; -} - -- (id)init -{ - if (!distantLightFilter) { - NSBundle *bundle = [NSBundle bundleForClass:[self class]]; - NSString *kernelFile = [bundle pathForResource:@"WKDistantLightFilter" ofType:@"cikernel"]; - NSString *code = [NSString stringWithContentsOfFile:kernelFile encoding:NSUTF8StringEncoding error:0]; - NSArray *kernels = [CIKernel kernelsWithString:code]; - distantLightFilter = [[kernels objectAtIndex:0] retain]; - } - return [super init]; -} - -- (CIImage *)outputImage -{ - return [self apply:distantLightFilter, [CISampler samplerWithImage:inputNormalMap], inputLightDirection, nil]; -} - -@end - -#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS) diff --git a/WebCore/svg/graphics/filters/cg/WKGammaTransferFilter.cikernel b/WebCore/svg/graphics/filters/cg/WKGammaTransferFilter.cikernel deleted file mode 100644 index 810edb6..0000000 --- a/WebCore/svg/graphics/filters/cg/WKGammaTransferFilter.cikernel +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (C) 2006 Oliver Hunt <ojh16@student.canterbury.ac.nz>. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -kernel vec4 gammaTransfer(sampler image, float amplitude, float exponent, float offset) -{ - vec4 C = sample(image, samplerCoord(image)); - return amplitude * pow(C, vec4(exponent)) + offset; -} diff --git a/WebCore/svg/graphics/filters/cg/WKGammaTransferFilter.h b/WebCore/svg/graphics/filters/cg/WKGammaTransferFilter.h deleted file mode 100644 index 7e0c1e4..0000000 --- a/WebCore/svg/graphics/filters/cg/WKGammaTransferFilter.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (C) 2006 Oliver Hunt <ojh16@student.canterbury.ac.nz>. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#import <QuartzCore/CoreImage.h> - -#if ENABLE(SVG) && ENABLE(SVG_FILTERS) - -@interface WKGammaTransferFilter : CIFilter { - CIImage *inputImage; - NSNumber *inputAmplitude; - NSNumber *inputExponent; - NSNumber *inputOffset; -} - -@end - -#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS) diff --git a/WebCore/svg/graphics/filters/cg/WKGammaTransferFilter.m b/WebCore/svg/graphics/filters/cg/WKGammaTransferFilter.m deleted file mode 100644 index 8642931..0000000 --- a/WebCore/svg/graphics/filters/cg/WKGammaTransferFilter.m +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright (C) 2006 Oliver Hunt <ojh16@student.canterbury.ac.nz>. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#import "config.h" -#import "WKGammaTransferFilter.h" - -#if ENABLE(SVG) && ENABLE(SVG_FILTERS) - -static CIKernel *gammaTransferFilter = nil; - -@implementation WKGammaTransferFilter -+ (void)initialize -{ - [CIFilter registerFilterName:@"WKGammaTransfer" - constructor:self - classAttributes:[NSDictionary dictionaryWithObjectsAndKeys: - @"WebKit Gamma Transfer", kCIAttributeFilterDisplayName, - [NSArray arrayWithObjects:kCICategoryStylize, kCICategoryVideo, - kCICategoryStillImage, kCICategoryNonSquarePixels,nil], kCIAttributeFilterCategories, - [NSDictionary dictionaryWithObjectsAndKeys: - [NSNumber numberWithDouble:1.0], kCIAttributeDefault, - [NSNumber numberWithDouble:1.0], kCIAttributeIdentity, - kCIAttributeTypeScalar, kCIAttributeType, - nil], @"inputAmplitude", - [NSDictionary dictionaryWithObjectsAndKeys: - [NSNumber numberWithDouble:1.0], kCIAttributeDefault, - [NSNumber numberWithDouble:1.0], kCIAttributeIdentity, - kCIAttributeTypeScalar, kCIAttributeType, - nil], @"inputExponent", - [NSDictionary dictionaryWithObjectsAndKeys: - [NSNumber numberWithDouble:0.0], kCIAttributeDefault, - [NSNumber numberWithDouble:0.0], kCIAttributeIdentity, - kCIAttributeTypeScalar, kCIAttributeType, - nil], @"inputOffset", - nil]]; -} - -+ (CIFilter *)filterWithName:(NSString *)name -{ - return [[[self alloc] init] autorelease]; -} - -- (id)init -{ - if (!gammaTransferFilter) { - NSBundle *bundle = [NSBundle bundleForClass:[self class]]; - NSString *kernelFile = [bundle pathForResource:@"WKGammaTransferFilter" ofType:@"cikernel"]; - NSString *code = [NSString stringWithContentsOfFile:kernelFile encoding:NSUTF8StringEncoding error:0]; - NSArray *kernels = [CIKernel kernelsWithString:code]; - gammaTransferFilter = [[kernels objectAtIndex:0] retain]; - } - return [super init]; -} - -- (CIImage *)outputImage -{ - CISampler *inputSampler = [CISampler samplerWithImage: inputImage]; - return [self apply:gammaTransferFilter, inputSampler, inputAmplitude, inputExponent, inputOffset, @"definition", [inputSampler definition], nil]; -} - -@end - -#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS) diff --git a/WebCore/svg/graphics/filters/cg/WKIdentityTransferFilter.h b/WebCore/svg/graphics/filters/cg/WKIdentityTransferFilter.h deleted file mode 100644 index 0c36daa..0000000 --- a/WebCore/svg/graphics/filters/cg/WKIdentityTransferFilter.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (C) 2006 Oliver Hunt <ojh16@student.canterbury.ac.nz>. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#import <QuartzCore/CoreImage.h> - -#if ENABLE(SVG) && ENABLE(SVG_FILTERS) - -@interface WKIdentityTransferFilter : CIFilter { - CIImage *inputImage; -} - -@end - -#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS) diff --git a/WebCore/svg/graphics/filters/cg/WKIdentityTransferFilter.m b/WebCore/svg/graphics/filters/cg/WKIdentityTransferFilter.m deleted file mode 100644 index 935c305..0000000 --- a/WebCore/svg/graphics/filters/cg/WKIdentityTransferFilter.m +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (C) 2006 Oliver Hunt <ojh16@student.canterbury.ac.nz>. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#import "config.h" -#import "WKIdentityTransferFilter.h" - -#if ENABLE(SVG) && ENABLE(SVG_FILTERS) - -@implementation WKIdentityTransferFilter -+ (void)initialize -{ - [CIFilter registerFilterName:@"WKIdentityTransfer" - constructor:self - classAttributes:[NSDictionary dictionaryWithObjectsAndKeys: - @"WebKit Identity Transfer", kCIAttributeFilterDisplayName, - [NSArray arrayWithObjects:kCICategoryStylize, kCICategoryVideo, - kCICategoryStillImage, kCICategoryNonSquarePixels,nil], kCIAttributeFilterCategories, - nil]]; -} - -+ (CIFilter *)filterWithName:(NSString *)name -{ - return [[[self alloc] init] autorelease]; -} - -- (id)init -{ - return [super init]; -} - -- (CIImage *)outputImage -{ - return inputImage; -} - -@end - -#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS) diff --git a/WebCore/svg/graphics/filters/cg/WKLinearTransferFilter.cikernel b/WebCore/svg/graphics/filters/cg/WKLinearTransferFilter.cikernel deleted file mode 100644 index 17d57e4..0000000 --- a/WebCore/svg/graphics/filters/cg/WKLinearTransferFilter.cikernel +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (C) 2006 Oliver Hunt <ojh16@student.canterbury.ac.nz>. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -kernel vec4 linearTransfer(sampler image, float slope, float intercept) -{ - vec4 C = sample(image, samplerCoord(image)); - return slope * C + intercept; -} diff --git a/WebCore/svg/graphics/filters/cg/WKLinearTransferFilter.h b/WebCore/svg/graphics/filters/cg/WKLinearTransferFilter.h deleted file mode 100644 index 91a99f5..0000000 --- a/WebCore/svg/graphics/filters/cg/WKLinearTransferFilter.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (C) 2006 Oliver Hunt <ojh16@student.canterbury.ac.nz>. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#import <QuartzCore/CoreImage.h> - -#if ENABLE(SVG) && ENABLE(SVG_FILTERS) - -@interface WKLinearTransferFilter : CIFilter { - CIImage *inputImage; - NSNumber *inputSlope; - NSNumber *inputIntercept; -} - -@end - -#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS) diff --git a/WebCore/svg/graphics/filters/cg/WKLinearTransferFilter.m b/WebCore/svg/graphics/filters/cg/WKLinearTransferFilter.m deleted file mode 100644 index 6582f9f..0000000 --- a/WebCore/svg/graphics/filters/cg/WKLinearTransferFilter.m +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright (C) 2006 Oliver Hunt <ojh16@student.canterbury.ac.nz>. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#import "config.h" -#import "WKLinearTransferFilter.h" - -#if ENABLE(SVG) && ENABLE(SVG_FILTERS) - -static CIKernel *linearTransferFilter = nil; - -@implementation WKLinearTransferFilter -+ (void)initialize -{ - [CIFilter registerFilterName:@"WKLinearTransfer" - constructor:self - classAttributes:[NSDictionary dictionaryWithObjectsAndKeys: - @"WebKit Linear Transfer", kCIAttributeFilterDisplayName, - [NSArray arrayWithObjects:kCICategoryStylize, kCICategoryVideo, - kCICategoryStillImage, kCICategoryNonSquarePixels,nil], kCIAttributeFilterCategories, - [NSDictionary dictionaryWithObjectsAndKeys: - [NSNumber numberWithDouble:1.0], kCIAttributeDefault, - [NSNumber numberWithDouble:1.0], kCIAttributeIdentity, - kCIAttributeTypeScalar, kCIAttributeType, - nil], @"inputSlope", - [NSDictionary dictionaryWithObjectsAndKeys: - [NSNumber numberWithDouble:0.0], kCIAttributeDefault, - [NSNumber numberWithDouble:0.0], kCIAttributeIdentity, - kCIAttributeTypeScalar, kCIAttributeType, - nil], @"inputIntersection", - nil]]; -} - -+ (CIFilter *)filterWithName:(NSString *)name -{ - return [[[self alloc] init] autorelease]; -} - -- (id)init -{ - if (!linearTransferFilter) { - NSBundle *bundle = [NSBundle bundleForClass:[self class]]; - NSString *kernelFile = [bundle pathForResource:@"WKLinearTransferFilter" ofType:@"cikernel"]; - NSString *code = [NSString stringWithContentsOfFile:kernelFile encoding:NSUTF8StringEncoding error:0]; - NSArray *kernels = [CIKernel kernelsWithString:code]; - linearTransferFilter = [[kernels objectAtIndex:0] retain]; - } - return [super init]; -} - -- (CIImage *)outputImage -{ - CISampler *inputSampler = [CISampler samplerWithImage: inputImage]; - return [self apply:linearTransferFilter, inputSampler, inputSlope, inputIntercept, @"definition", [inputSampler definition], nil]; -} - -@end - -#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS) diff --git a/WebCore/svg/graphics/filters/cg/WKNormalMapFilter.cikernel b/WebCore/svg/graphics/filters/cg/WKNormalMapFilter.cikernel deleted file mode 100644 index 589f475..0000000 --- a/WebCore/svg/graphics/filters/cg/WKNormalMapFilter.cikernel +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (C) 2005 Oliver Hunt <ojh16@student.canterbury.ac.nz>. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -//TODO: We currently ignore the input kernel lengths -kernel vec4 convolve3x3(sampler image, float divisor, float bias, - vec3 m0, vec3 m1, vec3 m2) -{ - vec4 colour = vec4(0.0, 0.0, 0.0, 0.0); - vec2 pos= samplerCoord(image); - colour = sample(image, pos + vec2(-1.0, -1.0)) *m0.x; - colour += sample(image, pos + vec2(-1.0, 0.0)) *m0.y; - colour += sample(image, pos + vec2(-1.0, 1.0)) *m0.z; - colour += sample(image, pos + vec2( 0.0, -1.0)) *m1.x; - colour += sample(image, pos) * m1.y; - colour += sample(image, pos + vec2( 0.0, 1.0))*m1.z; - colour += sample(image, pos + vec2( 1.0, -1.0))*m2.x; - colour += sample(image, pos + vec2( 1.0, 0.0))*m2.y; - colour += sample(image, pos + vec2( 1.0, 1.0))*m2.z; - return colour / divisor + bias; -} - -kernel vec4 mergeNormals(sampler Nx, sampler Ny, sampler src, float surfaceScale) -{ - vec3 N = vec3(surfaceScale * sample(Nx, samplerCoord(Nx)).a, -surfaceScale * sample(Ny, samplerCoord(Ny)).a, 1.0); - N = normalize(N); - return vec4(N.x, N.y, N.z, sample(src, samplerCoord(src)).a); -} diff --git a/WebCore/svg/graphics/filters/cg/WKNormalMapFilter.h b/WebCore/svg/graphics/filters/cg/WKNormalMapFilter.h deleted file mode 100644 index fb27447..0000000 --- a/WebCore/svg/graphics/filters/cg/WKNormalMapFilter.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (C) 2005 Apple Computer, Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#import <QuartzCore/CoreImage.h> - -#if ENABLE(SVG) && ENABLE(SVG_FILTERS) - -@interface WKNormalMapFilter : CIFilter { - CIImage *inputImage; - NSNumber *inputSurfaceScale; -} -@end - -#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS) diff --git a/WebCore/svg/graphics/filters/cg/WKNormalMapFilter.m b/WebCore/svg/graphics/filters/cg/WKNormalMapFilter.m deleted file mode 100644 index b462008..0000000 --- a/WebCore/svg/graphics/filters/cg/WKNormalMapFilter.m +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Copyright (C) 2005 Apple Computer, Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#import "config.h" -#import "WKNormalMapFilter.h" - -#if ENABLE(SVG) && ENABLE(SVG_FILTERS) - -static CIKernel *convolveKernel = nil; -static CIKernel *normalMapKernel = nil; - -@implementation WKNormalMapFilter - -+ (void)initialize -{ - [CIFilter registerFilterName:@"WKNormalMap" - constructor:self - classAttributes:[NSDictionary dictionaryWithObjectsAndKeys: - @"WebKit Normal Map", kCIAttributeFilterDisplayName, - [NSArray arrayWithObjects: kCICategoryBlur, kCICategoryVideo, - kCICategoryStillImage, kCICategoryNonSquarePixels, nil], kCIAttributeFilterCategories, - [NSDictionary dictionaryWithObjectsAndKeys: - [NSNumber numberWithDouble:0.0], kCIAttributeMin, - [NSNumber numberWithDouble:1.0], kCIAttributeDefault, - [NSNumber numberWithDouble:1.0], kCIAttributeIdentity, - kCIAttributeTypeScalar, kCIAttributeType, - nil], @"inputSurfaceScale", - nil]]; -} - -+ (CIFilter *)filterWithName:(NSString *)name -{ - return [[[self alloc] init] autorelease]; -} - -- (id)init -{ - if (!normalMapKernel) { - NSBundle *bundle = [NSBundle bundleForClass:[self class]]; - NSString *kernelFile = [bundle pathForResource:@"WKNormalMapFilter" ofType:@"cikernel"]; - NSString *code = [NSString stringWithContentsOfFile:kernelFile encoding:NSUTF8StringEncoding error:0]; - NSArray *kernels = [CIKernel kernelsWithString:code]; - convolveKernel = [[kernels objectAtIndex:0] retain]; - normalMapKernel = [[kernels objectAtIndex:1] retain]; - } - return [super init]; -} - -- (NSArray *)xConvolveArgsWithBumpMap:(CISampler *)bumpMap { - return [NSArray arrayWithObjects: - bumpMap, - [NSNumber numberWithFloat:4], - [NSNumber numberWithFloat:0], - [CIVector vectorWithX:1 Y:2 Z:1], - [CIVector vectorWithX:0 Y:0 Z:0], - [CIVector vectorWithX:-1 Y:-2 Z:-1], - nil]; -} - -- (NSArray *)yConvolveArgsWithBumpMap:(CISampler *)bumpMap { - return [NSArray arrayWithObjects: - bumpMap, - [NSNumber numberWithFloat:4], - [NSNumber numberWithFloat:0], - [CIVector vectorWithX:1 Y:0 Z:-1], - [CIVector vectorWithX:2 Y:0 Z:-2], - [CIVector vectorWithX:1 Y:0 Z:-1], - nil]; -} - -- (CIImage *)outputImage -{ - CISampler *image = [CISampler samplerWithImage:inputImage]; - NSDictionary *applyOptions = [NSDictionary dictionaryWithObjectsAndKeys:[image definition], kCIApplyOptionDefinition, nil]; - - CIImage *convolveX = [self apply:convolveKernel arguments:[self xConvolveArgsWithBumpMap:image] options:applyOptions]; - CIImage *convolveY = [self apply:convolveKernel arguments:[self yConvolveArgsWithBumpMap:image] options:applyOptions]; - CISampler *samplerX = [CISampler samplerWithImage:convolveX]; - CISampler *samplerY = [CISampler samplerWithImage:convolveY]; - - NSArray *normalMapArgs = [NSArray arrayWithObjects:samplerX, samplerY, image, inputSurfaceScale, nil]; - return [self apply:normalMapKernel arguments:normalMapArgs options:applyOptions]; -} - -@end - -#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS) diff --git a/WebCore/svg/graphics/filters/cg/WKPointLightFilter.cikernel b/WebCore/svg/graphics/filters/cg/WKPointLightFilter.cikernel deleted file mode 100644 index fd0a851..0000000 --- a/WebCore/svg/graphics/filters/cg/WKPointLightFilter.cikernel +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (C) 2005 Oliver Hunt <ojh16@student.canterbury.ac.nz>. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -kernel vec4 genPointLight(sampler normalMap, vec3 lightPos, float surfaceScale) -{ - vec2 pos = samplerCoord(normalMap); - vec3 P = vec3(pos.x, pos.y, surfaceScale * sample(normalMap, pos).a); - vec3 L = lightPos - P; - L = normalize(L); - return vec4(L.x, L.y, L.z, 1.0); -} diff --git a/WebCore/svg/graphics/filters/cg/WKPointLightFilter.h b/WebCore/svg/graphics/filters/cg/WKPointLightFilter.h deleted file mode 100644 index 58ec689..0000000 --- a/WebCore/svg/graphics/filters/cg/WKPointLightFilter.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (C) 2005 Apple Computer, Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#import <QuartzCore/CoreImage.h> - -#if ENABLE(SVG) && ENABLE(SVG_FILTERS) - -@interface WKPointLightFilter : CIFilter { - CIImage *inputNormalMap; - CIVector *inputLightPosition; - NSNumber *inputSurfaceScale; -} - -@end - -#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS) diff --git a/WebCore/svg/graphics/filters/cg/WKPointLightFilter.m b/WebCore/svg/graphics/filters/cg/WKPointLightFilter.m deleted file mode 100644 index 331207e..0000000 --- a/WebCore/svg/graphics/filters/cg/WKPointLightFilter.m +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (C) 2005 Apple Computer, Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#import "config.h" -#import "WKPointLightFilter.h" - -#if ENABLE(SVG) && ENABLE(SVG_FILTERS) - -static CIKernel *pointLightFilter = nil; - -@implementation WKPointLightFilter - -+ (void)initialize -{ - [CIFilter registerFilterName:@"WKPointLight" - constructor:self - classAttributes:[NSDictionary dictionaryWithObjectsAndKeys: - @"WebKit Point Light", kCIAttributeFilterDisplayName, - [NSArray arrayWithObjects:kCICategoryStylize, kCICategoryVideo, - kCICategoryStillImage, kCICategoryNonSquarePixels,nil], kCIAttributeFilterCategories, - [NSDictionary dictionaryWithObjectsAndKeys: - kCIAttributeTypePosition3, kCIAttributeType, - nil], @"inputLightPosition", - nil]]; -} - -+ (CIFilter *)filterWithName:(NSString *)name -{ - return [[[self alloc] init] autorelease]; -} - -- (id)init -{ - if (!pointLightFilter) { - NSBundle *bundle = [NSBundle bundleForClass:[self class]]; - NSString *kernelFile = [bundle pathForResource:@"WKPointLightFilter" ofType:@"cikernel"]; - NSString *code = [NSString stringWithContentsOfFile:kernelFile encoding:NSUTF8StringEncoding error:0]; - NSArray *kernels = [CIKernel kernelsWithString:code]; - pointLightFilter = [[kernels objectAtIndex:0] retain]; - } - return [super init]; -} - -- (CIImage *)outputImage -{ - return [self apply:pointLightFilter, inputNormalMap, inputLightPosition, inputSurfaceScale, nil]; -} - -@end - -#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS) diff --git a/WebCore/svg/graphics/filters/cg/WKSpecularLightingFilter.cikernel b/WebCore/svg/graphics/filters/cg/WKSpecularLightingFilter.cikernel deleted file mode 100644 index 64228f0..0000000 --- a/WebCore/svg/graphics/filters/cg/WKSpecularLightingFilter.cikernel +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (C) 2005 Oliver Hunt <ojh16@student.canterbury.ac.nz>. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -kernel vec4 basic(sampler inputNormalVectors, sampler inputLightVectors, __color inputLightingColor, float inputSurfaceScale, float inputSpecularConstant, - float inputSpecularExponent, float inputKernelUnitLengthX, float inputKernelUnitLengthY) -{ - vec2 pos = samplerCoord(inputLightVectors); - vec2 posn = samplerCoord(inputNormalVectors); - vec3 l = sample(inputLightVectors, pos).xyz; - vec3 n = sample(inputNormalVectors, posn).xyz; - vec3 h = l+vec3(0.0, 0.0, 1.0); - h = normalize(h); - float nh = inputSpecularConstant*pow((dot(n, h)), inputSpecularExponent); - vec4 res = inputLightingColor * nh; - res.a = max(res.r, res.g); - res.a = max(res.a, res.b); - return res; -} diff --git a/WebCore/svg/graphics/filters/cg/WKSpecularLightingFilter.h b/WebCore/svg/graphics/filters/cg/WKSpecularLightingFilter.h deleted file mode 100644 index cce9e06..0000000 --- a/WebCore/svg/graphics/filters/cg/WKSpecularLightingFilter.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (C) 2005 Apple Computer, Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#import <QuartzCore/CoreImage.h> - -#if ENABLE(SVG) && ENABLE(SVG_FILTERS) - -@interface WKSpecularLightingFilter : CIFilter { - CISampler *inputNormalMap; - CISampler *inputLightVectors; - CIColor *inputLightingColor; - NSNumber *inputSurfaceScale; - NSNumber *inputSpecularConstant; - NSNumber *inputSpecularExponent; - NSNumber *inputKernelUnitLengthX; - NSNumber *inputKernelUnitLengthY; -} -@end - -#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS) diff --git a/WebCore/svg/graphics/filters/cg/WKSpecularLightingFilter.m b/WebCore/svg/graphics/filters/cg/WKSpecularLightingFilter.m deleted file mode 100644 index 22495ae..0000000 --- a/WebCore/svg/graphics/filters/cg/WKSpecularLightingFilter.m +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright (C) 2005 Apple Computer, Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#import "config.h" -#import "WKSpecularLightingFilter.h" - -#if ENABLE(SVG) && ENABLE(SVG_FILTERS) - -static CIKernel *specularLightingFilter = nil; - -@implementation WKSpecularLightingFilter - -+ (void)initialize -{ - [CIFilter registerFilterName:@"WKSpecularLighting" - constructor:self - classAttributes:[NSDictionary dictionaryWithObjectsAndKeys: - @"WebKit Specular Lighting", kCIAttributeFilterDisplayName, - [NSArray arrayWithObjects:kCICategoryStylize, kCICategoryVideo, - kCICategoryStillImage, kCICategoryNonSquarePixels,nil], kCIAttributeFilterCategories, - [NSDictionary dictionaryWithObjectsAndKeys: - [CIColor colorWithRed:1.0f green:1.0f blue:1.0f alpha:1.0f], - kCIAttributeDefault, nil], @"inputLightingColor", - [NSDictionary dictionaryWithObjectsAndKeys: - [NSNumber numberWithDouble:0.0], kCIAttributeMin, - [NSNumber numberWithDouble:1.0], kCIAttributeDefault, - [NSNumber numberWithDouble:1.0], kCIAttributeIdentity, - kCIAttributeTypeScalar, kCIAttributeType, - nil], @"inputSurfaceScale", - [NSDictionary dictionaryWithObjectsAndKeys: - [NSNumber numberWithDouble:0.0], kCIAttributeMin, - [NSNumber numberWithDouble:1.0], kCIAttributeDefault, - [NSNumber numberWithDouble:1.0], kCIAttributeIdentity, - kCIAttributeTypeScalar, kCIAttributeType, - nil], @"inputSpecularConstant", - [NSDictionary dictionaryWithObjectsAndKeys: - [NSNumber numberWithDouble:0.0], kCIAttributeMin, - [NSNumber numberWithDouble:128.0], kCIAttributeMin, - [NSNumber numberWithDouble:1.0], kCIAttributeDefault, - [NSNumber numberWithDouble:1.0], kCIAttributeIdentity, - kCIAttributeTypeScalar, kCIAttributeType, - nil], @"inputSpecularExponent", - [NSDictionary dictionaryWithObjectsAndKeys: - kCIAttributeTypeOffset, kCIAttributeType, - nil], @"inputKernelUnitLength", - nil]]; -} - -+ (CIFilter *)filterWithName:(NSString *)name -{ - return [[[self alloc] init] autorelease]; -} - -- (id)init -{ - if (!specularLightingFilter) { - NSBundle *bundle = [NSBundle bundleForClass:[self class]]; - NSString *kernelFile = [bundle pathForResource:@"WKSpecularLightingFilter" ofType:@"cikernel"]; - NSString *code = [NSString stringWithContentsOfFile:kernelFile encoding:NSUTF8StringEncoding error:0]; - NSArray *kernels = [CIKernel kernelsWithString:code]; - specularLightingFilter = [[kernels objectAtIndex:0] retain]; - } - return [super init]; -} - -- (CIImage *)outputImage -{ - return [self apply:specularLightingFilter, inputNormalMap, inputLightVectors, inputLightingColor, inputSurfaceScale, inputSpecularConstant, - inputSpecularExponent, inputKernelUnitLengthX, inputKernelUnitLengthY, nil]; -} - -@end - -#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS) diff --git a/WebCore/svg/graphics/filters/cg/WKSpotLightFilter.cikernel b/WebCore/svg/graphics/filters/cg/WKSpotLightFilter.cikernel deleted file mode 100644 index 0fa83a8..0000000 --- a/WebCore/svg/graphics/filters/cg/WKSpotLightFilter.cikernel +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (C) 2005 Oliver Hunt <ojh16@student.canterbury.ac.nz>. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -kernel vec4 spotLightFilter(sampler lightVectors, vec3 lightDirection, float specularExponent, float cosCutoffAngle) -{ - vec2 pos = samplerCoord(lightVectors); - vec3 l = sample(lightVectors, pos).xyz; - float sl = -dot(lightDirection, l); - sl = max(sl, 0.0); - sl = pow(sl, specularExponent) * sign(sl - cosCutoffAngle); - return vec4(l.x, l.y, l.z, sl); -} diff --git a/WebCore/svg/graphics/filters/cg/WKSpotLightFilter.h b/WebCore/svg/graphics/filters/cg/WKSpotLightFilter.h deleted file mode 100644 index d87beca..0000000 --- a/WebCore/svg/graphics/filters/cg/WKSpotLightFilter.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (C) 2005 Apple Computer, Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#import <QuartzCore/CoreImage.h> - -#if ENABLE(SVG) && ENABLE(SVG_FILTERS) - -@interface WKSpotLightFilter : CIFilter { - CIImage *inputLightVectors; - CIVector *inputLightDirection; - NSNumber *inputSpecularExponent; - NSNumber *inputLimitingConeAngle; -} -@end - -#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS) diff --git a/WebCore/svg/graphics/filters/cg/WKSpotLightFilter.m b/WebCore/svg/graphics/filters/cg/WKSpotLightFilter.m deleted file mode 100644 index 62973ef..0000000 --- a/WebCore/svg/graphics/filters/cg/WKSpotLightFilter.m +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright (C) 2005 Apple Computer, Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#import "config.h" -#import "WKSpotLightFilter.h" - -#if ENABLE(SVG) && ENABLE(SVG_FILTERS) - -static CIKernel *spotLightFilter = nil; - -@implementation WKSpotLightFilter - -+ (void)initialize -{ - [CIFilter registerFilterName:@"WKSpotLight" - constructor:self - classAttributes:[NSDictionary dictionaryWithObjectsAndKeys: - @"WebKit Spot Light", kCIAttributeFilterDisplayName, - [NSArray arrayWithObjects:kCICategoryStylize, kCICategoryVideo, - kCICategoryStillImage, kCICategoryNonSquarePixels,nil], kCIAttributeFilterCategories, - [NSDictionary dictionaryWithObjectsAndKeys: - kCIAttributeTypePosition3, kCIAttributeType, - nil], @"inputLightDirection", - [NSDictionary dictionaryWithObjectsAndKeys: - [NSNumber numberWithDouble:1.0], kCIAttributeDefault, - [NSNumber numberWithDouble:1.0], kCIAttributeIdentity, - kCIAttributeTypeScalar, kCIAttributeType, - nil], @"inputSpecularExponent", - [NSDictionary dictionaryWithObjectsAndKeys: - kCIAttributeTypeAngle, kCIAttributeType, - nil], @"inputLimitingConeAngle", - nil]]; -} - -+ (CIFilter *)filterWithName:(NSString *)name -{ - return [[[self alloc] init] autorelease]; -} - -- (id)init -{ - if (!spotLightFilter) { - NSBundle *bundle = [NSBundle bundleForClass:[self class]]; - NSString *kernelFile = [bundle pathForResource:@"WKSpotLightFilter" ofType:@"cikernel"]; - NSString *code = [NSString stringWithContentsOfFile:kernelFile encoding:NSUTF8StringEncoding error:0]; - NSArray *kernels = [CIKernel kernelsWithString:code]; - spotLightFilter = [[kernels objectAtIndex:0] retain]; - } - return [super init]; -} - -- (CIImage *)outputImage -{ - float coscutoff = cosf([inputLimitingConeAngle floatValue]); - if (coscutoff < 0) - coscutoff = -coscutoff; - return [self apply:spotLightFilter, inputLightVectors, inputLightDirection, inputSpecularExponent, [NSNumber numberWithFloat:coscutoff], nil]; -} - -@end - -#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS) diff --git a/WebCore/svg/graphics/filters/cg/WKTableTransferFilter.cikernel b/WebCore/svg/graphics/filters/cg/WKTableTransferFilter.cikernel deleted file mode 100644 index 19dfcdf..0000000 --- a/WebCore/svg/graphics/filters/cg/WKTableTransferFilter.cikernel +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (C) 2006 Oliver Hunt <ojh16@student.canterbury.ac.nz>. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* For some reason CI is ignoring the request to interpolate the colour returned - * when we sample the lookup table. Therefore it is necessary to implement the - * blend operation ourselves. - */ -kernel vec4 tableTransfer(sampler image, sampler table, vec4 rgbaSelector, float maxIndex) -{ - vec4 C = sample(image, samplerCoord(image)); - float k = dot(rgbaSelector, C) * maxIndex; - float t = fract(k); - k = floor(k); - vec4 res = sample(table, vec2(k, 0.0))*(1.0-t)+sample(table, vec2(k+1.0, 0.0))*(t); - return res; -} diff --git a/WebCore/svg/graphics/filters/cg/WKTableTransferFilter.h b/WebCore/svg/graphics/filters/cg/WKTableTransferFilter.h deleted file mode 100644 index 34adf00..0000000 --- a/WebCore/svg/graphics/filters/cg/WKTableTransferFilter.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (C) 2006 Oliver Hunt <ojh16@student.canterbury.ac.nz>. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#import <QuartzCore/CoreImage.h> - -#if ENABLE(SVG) && ENABLE(SVG_FILTERS) - -@interface WKTableTransferFilter : CIFilter { - CIImage *inputImage; - CIImage *inputTable; - CIVector *inputSelector; -} - -@end - -#endif diff --git a/WebCore/svg/graphics/filters/cg/WKTableTransferFilter.m b/WebCore/svg/graphics/filters/cg/WKTableTransferFilter.m deleted file mode 100644 index 55d7c9d..0000000 --- a/WebCore/svg/graphics/filters/cg/WKTableTransferFilter.m +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (C) 2006 Oliver Hunt <ojh16@student.canterbury.ac.nz>. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#import "config.h" -#import "WKTableTransferFilter.h" - -#if ENABLE(SVG) && ENABLE(SVG_FILTERS) - -static CIKernel *tableTransferFilter = nil; - -@implementation WKTableTransferFilter -+ (void)initialize -{ - [CIFilter registerFilterName:@"WKTableTransfer" - constructor:self - classAttributes:[NSDictionary dictionaryWithObjectsAndKeys: - @"WebKit Table Transfer", kCIAttributeFilterDisplayName, - [NSArray arrayWithObjects:kCICategoryStylize, kCICategoryVideo, - kCICategoryStillImage, kCICategoryNonSquarePixels,nil], kCIAttributeFilterCategories, - [NSDictionary dictionaryWithObjectsAndKeys: - kCIAttributeTypeGradient, kCIAttributeType, - nil], @"inputTable", - nil]]; -} - -+ (CIFilter *)filterWithName:(NSString *)name -{ - return [[[self alloc] init] autorelease]; -} - -- (id)init -{ - if (!tableTransferFilter) { - NSBundle *bundle = [NSBundle bundleForClass:[self class]]; - NSString *kernelFile = [bundle pathForResource:@"WKTableTransferFilter" ofType:@"cikernel"]; - NSString *code = [NSString stringWithContentsOfFile:kernelFile encoding:NSUTF8StringEncoding error:0]; - NSArray *kernels = [CIKernel kernelsWithString:code]; - tableTransferFilter = [[kernels objectAtIndex:0] retain]; - } - return [super init]; -} - -- (CIImage *)outputImage -{ - CISampler *inputSampler = [CISampler samplerWithImage: inputImage]; - CISampler *tableSampler = [CISampler samplerWithImage: inputTable keysAndValues:kCISamplerFilterMode, kCISamplerFilterLinear, kCISamplerWrapMode, kCISamplerWrapClamp, nil]; - NSArray *args = [NSArray arrayWithObjects:inputSampler, tableSampler, inputSelector, - [NSNumber numberWithDouble:[inputTable extent].size.width - 1.0f], @"definition", [inputSampler definition], nil]; - return [self apply:tableTransferFilter arguments:args options:nil]; -} - -@end - -#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS) diff --git a/WebCore/svg/graphics/mac/SVGResourceFilterPlatformDataMac.h b/WebCore/svg/graphics/mac/SVGResourceFilterPlatformDataMac.h deleted file mode 100644 index 54f8237..0000000 --- a/WebCore/svg/graphics/mac/SVGResourceFilterPlatformDataMac.h +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (C) 2007 Eric Seidel <eric@webkit.org> - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef SVGResourceFilterPlatformDataMac_h -#define SVGResourceFilterPlatformDataMac_h - -#if ENABLE(SVG) && ENABLE(SVG_FILTERS) - -#include "SVGResourceFilter.h" - -#include <ApplicationServices/ApplicationServices.h> -#include <wtf/RetainPtr.h> - -@class CIImage; -@class CIFilter; -@class CIContext; -@class NSArray; -@class NSMutableDictionary; - -namespace WebCore { - class SVGResourceFilterPlatformDataMac : public SVGResourceFilterPlatformData { - public: - SVGResourceFilterPlatformDataMac(SVGResourceFilter*); - virtual ~SVGResourceFilterPlatformDataMac(); - - CIImage* imageForName(const String&) const; - void setImageForName(CIImage*, const String&); - - void setOutputImage(const SVGFilterEffect*, CIImage*); - CIImage* inputImage(const SVGFilterEffect*); - - NSArray* getCIFilterStack(CIImage* inputImage, const FloatRect& bbox); - - RetainPtr<CIContext> m_filterCIContext; - CGLayerRef m_filterCGLayer; - RetainPtr<NSMutableDictionary> m_imagesByName; - SVGResourceFilter* m_filter; - }; -} - -#endif // #if ENABLE(SVG) && ENABLE(SVG_FILTERS) - -#endif // SVGResourceFilterPlatformDataMac_h diff --git a/WebCore/svg/graphics/mac/SVGResourceFilterPlatformDataMac.mm b/WebCore/svg/graphics/mac/SVGResourceFilterPlatformDataMac.mm deleted file mode 100644 index 225c649..0000000 --- a/WebCore/svg/graphics/mac/SVGResourceFilterPlatformDataMac.mm +++ /dev/null @@ -1,128 +0,0 @@ -/* - * Copyright (C) 2007 Eric Seidel <eric@webkit.org> - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "config.h" -#if ENABLE(SVG) && ENABLE(SVG_FILTERS) - -#include "SVGResourceFilterPlatformDataMac.h" -#include <QuartzCore/CoreImage.h> - -namespace WebCore { - -static const char* const SVGPreviousFilterOutputName = "__previousOutput__"; - -SVGResourceFilterPlatformDataMac::SVGResourceFilterPlatformDataMac(SVGResourceFilter* filter) - : m_filterCGLayer(0) - , m_imagesByName(AdoptNS, [[NSMutableDictionary alloc] init]) - , m_filter(filter) -{ -} - -SVGResourceFilterPlatformDataMac::~SVGResourceFilterPlatformDataMac() -{ - ASSERT(!m_filterCGLayer); - ASSERT(!m_filterCIContext); -} - - -NSArray* SVGResourceFilterPlatformDataMac::getCIFilterStack(CIImage* inputImage, const FloatRect& bbox) -{ - NSMutableArray* filterEffects = [NSMutableArray array]; - - setImageForName(inputImage, "SourceGraphic"); // input - - for (unsigned int i = 0; i < m_filter->effects().size(); i++) { - CIFilter* filter = m_filter->effects()[i]->getCIFilter(bbox); - if (filter) - [filterEffects addObject:filter]; - } - - [m_imagesByName.get() removeAllObjects]; // clean up before next time. - - return filterEffects; -} - -static inline CIImage* alphaImageForImage(CIImage* image) -{ - CIFilter* onlyAlpha = [CIFilter filterWithName:@"CIColorMatrix"]; - CGFloat zero[4] = {0, 0, 0, 0}; - [onlyAlpha setDefaults]; - [onlyAlpha setValue:image forKey:@"inputImage"]; - [onlyAlpha setValue:[CIVector vectorWithValues:zero count:4] forKey:@"inputRVector"]; - [onlyAlpha setValue:[CIVector vectorWithValues:zero count:4] forKey:@"inputGVector"]; - [onlyAlpha setValue:[CIVector vectorWithValues:zero count:4] forKey:@"inputBVector"]; - return [onlyAlpha valueForKey:@"outputImage"]; -} - -CIImage* SVGResourceFilterPlatformDataMac::imageForName(const String& name) const -{ - return [m_imagesByName.get() objectForKey:name]; -} - -void SVGResourceFilterPlatformDataMac::setImageForName(CIImage* image, const String& name) -{ - [m_imagesByName.get() setValue:image forKey:name]; -} - -void SVGResourceFilterPlatformDataMac::setOutputImage(const SVGFilterEffect* filterEffect, CIImage* output) -{ - if (!filterEffect->result().isEmpty()) - setImageForName(output, filterEffect->result()); - - setImageForName(output, SVGPreviousFilterOutputName); -} - -CIImage* SVGResourceFilterPlatformDataMac::inputImage(const SVGFilterEffect* filterEffect) -{ - if (filterEffect->in().isEmpty()) { - CIImage* inImage = imageForName(SVGPreviousFilterOutputName); - - if (!inImage) - inImage = imageForName("SourceGraphic"); - - return inImage; - } else if (filterEffect->in() == "SourceAlpha") { - CIImage* sourceAlpha = imageForName(filterEffect->in()); - - if (!sourceAlpha) { - CIImage* sourceGraphic = imageForName("SourceGraphic"); - - if (!sourceGraphic) - return nil; - - sourceAlpha = alphaImageForImage(sourceGraphic); - setImageForName(sourceAlpha, "SourceAlpha"); - } - - return sourceAlpha; - } - - return imageForName(filterEffect->in()); -} - - -} - -#endif // #if ENABLE(SVG) && ENABLE(SVG_FILTERS) diff --git a/WebCore/svg/graphics/qt/SVGResourceFilterQt.cpp b/WebCore/svg/graphics/qt/SVGResourceFilterQt.cpp deleted file mode 100644 index cbf90cd..0000000 --- a/WebCore/svg/graphics/qt/SVGResourceFilterQt.cpp +++ /dev/null @@ -1,50 +0,0 @@ -/* - Copyright (C) 2006 Nikolas Zimmermann <wildfox@kde.org> - - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - aint with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#include "config.h" - -#if ENABLE(SVG) && ENABLE(SVG_FILTERS) -#include "SVGResourceFilter.h" -#include "NotImplemented.h" - -namespace WebCore { - -SVGResourceFilterPlatformData* SVGResourceFilter::createPlatformData() -{ - notImplemented(); - return 0; -} - -void SVGResourceFilter::prepareFilter(GraphicsContext*&, const FloatRect&) -{ - notImplemented(); -} - -void SVGResourceFilter::applyFilter(GraphicsContext*&, const FloatRect&) -{ - notImplemented(); -} - -} // namespace WebCore - -#endif - -// vim:ts=4:noet diff --git a/WebCore/svg/graphics/skia/SVGResourceFilterSkia.cpp b/WebCore/svg/graphics/skia/SVGResourceFilterSkia.cpp deleted file mode 100644 index b54eb4b..0000000 --- a/WebCore/svg/graphics/skia/SVGResourceFilterSkia.cpp +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) 2008, Google Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "config.h" -#if ENABLE(SVG) && ENABLE(SVG_FILTERS) -#include "NotImplemented.h" -#include "SVGResourceFilter.h" - -namespace WebCore { - -SVGResourceFilterPlatformData* SVGResourceFilter::createPlatformData() -{ - return 0; -} - -void SVGResourceFilter::prepareFilter(GraphicsContext*&, const FloatRect&) -{ - notImplemented(); -} - -void SVGResourceFilter::applyFilter(GraphicsContext*&, const FloatRect&) -{ - notImplemented(); -} - -} - -#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS) diff --git a/WebCore/svg/svgtags.in b/WebCore/svg/svgtags.in index 6ac430d..ca1ea89 100644 --- a/WebCore/svg/svgtags.in +++ b/WebCore/svg/svgtags.in @@ -2,115 +2,110 @@ namespace="SVG" namespaceURI="http://www.w3.org/2000/svg" guardFactoryWith="ENABLE(SVG)" exportStrings - -a + +a createWithNew #if ENABLE_SVG_FONTS -altGlyph +altGlyph createWithNew #endif #if 0 -altGlyphDef -altGlyphItem +altGlyphDef createWithNew +altGlyphItem createWithNew #endif #if ENABLE_SVG_ANIMATION -animate -animateColor -animateMotion JSInterfaceName=SVGElement -animateTransform -set +animate createWithNew +animateColor createWithNew +animateMotion JSInterfaceName=SVGElement, createWithNew +animateTransform createWithNew +set createWithNew #endif -circle -clipPath +circle createWithNew +clipPath createWithNew #if 0 -color_profile +color_profile createWithNew #endif -cursor -#if ENABLE_SVG_FONTS -definition_src -#endif -defs -desc -ellipse +cursor createWithNew +defs createWithNew +desc createWithNew +ellipse createWithNew #if ENABLE_FILTERS -feBlend -feColorMatrix -feComponentTransfer -feComposite -#if 0 -feConvolveMatrix -#endif -feDiffuseLighting -feDisplacementMap -feDistantLight -feFlood -feFuncA -feFuncB -feFuncG -feFuncR -feGaussianBlur -feImage -feMerge -feMergeNode +feBlend createWithNew +feColorMatrix createWithNew +feComponentTransfer createWithNew +feComposite createWithNew #if 0 -feMorphology +feConvolveMatrix createWithNew #endif -feOffset -fePointLight -feSpecularLighting -feSpotLight -feTile -feTurbulence -filter +feDiffuseLighting createWithNew +feDisplacementMap createWithNew +feDistantLight createWithNew +feFlood createWithNew +feFuncA createWithNew +feFuncB createWithNew +feFuncG createWithNew +feFuncR createWithNew +feGaussianBlur createWithNew +feImage createWithNew +feMerge createWithNew +feMergeNode createWithNew +feMorphology createWithNew +feOffset createWithNew +fePointLight createWithNew +feSpecularLighting createWithNew +feSpotLight createWithNew +feTile createWithNew +feTurbulence createWithNew +filter createWithNew #endif #if ENABLE_SVG_FONTS -font -font_face -font_face_format -font_face_name -font_face_src -font_face_uri +font createWithNew +font_face createWithNew +font_face_format createWithNew +font_face_name createWithNew +font_face_src createWithNew +font_face_uri createWithNew #endif #if ENABLE_SVG_FOREIGN_OBJECT -foreignObject +foreignObject createWithNew #endif -g +g createWithNew #if ENABLE_SVG_FONTS -glyph +glyph createWithNew #endif #if 0 -glyphRef +glyphRef createWithNew #endif #if ENABLE_SVG_FONTS -hkern interfaceName=SVGHKernElement, JSInterfaceName=SVGElement +hkern interfaceName=SVGHKernElement, JSInterfaceName=SVGElement, createWithNew #endif -image -line -linearGradient -marker -mask -metadata +image createWithNew +line createWithNew +linearGradient createWithNew +marker createWithNew +mask createWithNew +metadata createWithNew #if ENABLE_SVG_FONTS -missing_glyph +missing_glyph createWithNew #endif -mpath interfaceName=SVGMPathElement, JSInterfaceName=SVGElement -path -pattern -polygon -polyline -radialGradient -rect -script constructorNeedsCreatedByParser -stop -style constructorNeedsCreatedByParser -svg interfaceName=SVGSVGElement -switch -symbol -text -textPath -title -tref interfaceName=SVGTRefElement -tspan interfaceName=SVGTSpanElement -use -view +mpath interfaceName=SVGMPathElement, JSInterfaceName=SVGElement, createWithNew +path createWithNew +pattern createWithNew +polygon createWithNew +polyline createWithNew +radialGradient createWithNew +rect createWithNew +script constructorNeedsCreatedByParser, createWithNew +stop createWithNew +style constructorNeedsCreatedByParser, createWithNew +svg interfaceName=SVGSVGElement, createWithNew +switch createWithNew +symbol createWithNew +text createWithNew +textPath createWithNew +title createWithNew +tref interfaceName=SVGTRefElement, createWithNew +tspan interfaceName=SVGTSpanElement, createWithNew +use createWithNew +view createWithNew #if 0 -vkern interfaceName=SVGVKernElement +vkern interfaceName=SVGVKernElement, createWithNew #endif |
