diff options
Diffstat (limited to 'WebCore/svg')
97 files changed, 338 insertions, 220 deletions
diff --git a/WebCore/svg/GradientAttributes.h b/WebCore/svg/GradientAttributes.h index 2d7c32a..6b3408e 100644 --- a/WebCore/svg/GradientAttributes.h +++ b/WebCore/svg/GradientAttributes.h @@ -24,8 +24,7 @@ #if ENABLE(SVG) -namespace WebCore -{ +namespace WebCore { struct GradientAttributes { GradientAttributes() : m_spreadMethod(SpreadMethodPad) diff --git a/WebCore/svg/LinearGradientAttributes.h b/WebCore/svg/LinearGradientAttributes.h index e640c03..fc59465 100644 --- a/WebCore/svg/LinearGradientAttributes.h +++ b/WebCore/svg/LinearGradientAttributes.h @@ -26,8 +26,7 @@ #if ENABLE(SVG) -namespace WebCore -{ +namespace WebCore { struct LinearGradientAttributes : GradientAttributes { LinearGradientAttributes() : m_x1(0.0) diff --git a/WebCore/svg/PatternAttributes.h b/WebCore/svg/PatternAttributes.h index 2940baf..b43d87e 100644 --- a/WebCore/svg/PatternAttributes.h +++ b/WebCore/svg/PatternAttributes.h @@ -24,8 +24,7 @@ #if ENABLE(SVG) -namespace WebCore -{ +namespace WebCore { struct PatternAttributes { PatternAttributes() : m_x() diff --git a/WebCore/svg/RadialGradientAttributes.h b/WebCore/svg/RadialGradientAttributes.h index 782ab49..273cd29 100644 --- a/WebCore/svg/RadialGradientAttributes.h +++ b/WebCore/svg/RadialGradientAttributes.h @@ -26,8 +26,7 @@ #if ENABLE(SVG) -namespace WebCore -{ +namespace WebCore { struct RadialGradientAttributes : GradientAttributes { RadialGradientAttributes() : m_cx(0.5) diff --git a/WebCore/svg/SVGAElement.cpp b/WebCore/svg/SVGAElement.cpp index 6fd0274..9919702 100644 --- a/WebCore/svg/SVGAElement.cpp +++ b/WebCore/svg/SVGAElement.cpp @@ -138,7 +138,7 @@ void SVGAElement::defaultEventHandler(Event* evt) target = (getAttribute(XLinkNames::showAttr) == "new") ? "_blank" : "_self"; if (!evt->defaultPrevented()) { - String url = parseURL(href()); + String url = deprecatedParseURL(href()); #if ENABLE(SVG_ANIMATION) if (url.startsWith("#")) { Element* targetElement = document()->getElementById(url.substring(1)); diff --git a/WebCore/svg/SVGAnimatedPathData.h b/WebCore/svg/SVGAnimatedPathData.h index 6b3faf6..88b994b 100644 --- a/WebCore/svg/SVGAnimatedPathData.h +++ b/WebCore/svg/SVGAnimatedPathData.h @@ -25,12 +25,10 @@ #if ENABLE(SVG) -namespace WebCore -{ +namespace WebCore { class SVGPathSegList; - class SVGAnimatedPathData - { + class SVGAnimatedPathData { public: SVGAnimatedPathData(); virtual ~SVGAnimatedPathData(); diff --git a/WebCore/svg/SVGAnimatedPoints.h b/WebCore/svg/SVGAnimatedPoints.h index 58323c0..1e61057 100644 --- a/WebCore/svg/SVGAnimatedPoints.h +++ b/WebCore/svg/SVGAnimatedPoints.h @@ -25,12 +25,10 @@ #if ENABLE(SVG) -namespace WebCore -{ +namespace WebCore { class SVGPointList; - class SVGAnimatedPoints - { + class SVGAnimatedPoints { public: SVGAnimatedPoints(); virtual ~SVGAnimatedPoints(); diff --git a/WebCore/svg/SVGAnimatedProperty.h b/WebCore/svg/SVGAnimatedProperty.h index 725711d..6803055 100644 --- a/WebCore/svg/SVGAnimatedProperty.h +++ b/WebCore/svg/SVGAnimatedProperty.h @@ -66,7 +66,7 @@ namespace WebCore { void synchronizeProperty(const OwnerElement* ownerElement, const QualifiedName& attributeName, DecoratedType baseValue); // Abstract base class - class SVGAnimatedPropertyBase : Noncopyable { + class SVGAnimatedPropertyBase : public Noncopyable { public: virtual ~SVGAnimatedPropertyBase() { } virtual void synchronize() const = 0; @@ -435,7 +435,7 @@ namespace WebCore { if (old && value.isNull()) namedAttrMap->removeAttribute(old->name()); else if (!old && !value.isNull()) - namedAttrMap->addAttribute(const_cast<OwnerElement*>(ownerElement)->createAttribute(QualifiedName(nullAtom, attributeName.localName(), nullAtom), value)); + namedAttrMap->addAttribute(const_cast<OwnerElement*>(ownerElement)->createAttribute(attributeName, value)); else if (old && !value.isNull()) old->setValue(value); } diff --git a/WebCore/svg/SVGAnimationElement.h b/WebCore/svg/SVGAnimationElement.h index 120beb4..d43ed57 100644 --- a/WebCore/svg/SVGAnimationElement.h +++ b/WebCore/svg/SVGAnimationElement.h @@ -43,8 +43,7 @@ namespace WebCore { class SVGAnimationElement : public SVGSMILElement, public SVGTests, public SVGExternalResourcesRequired, - public ElementTimeControl - { + public ElementTimeControl { public: SVGAnimationElement(const QualifiedName&, Document*); virtual ~SVGAnimationElement(); diff --git a/WebCore/svg/SVGClipPathElement.h b/WebCore/svg/SVGClipPathElement.h index ab7ea68..4043554 100644 --- a/WebCore/svg/SVGClipPathElement.h +++ b/WebCore/svg/SVGClipPathElement.h @@ -35,8 +35,7 @@ namespace WebCore { class SVGClipPathElement : public SVGStyledTransformableElement, public SVGTests, public SVGLangSpace, - public SVGExternalResourcesRequired - { + public SVGExternalResourcesRequired { public: SVGClipPathElement(const QualifiedName&, Document*); virtual ~SVGClipPathElement(); diff --git a/WebCore/svg/SVGColor.cpp b/WebCore/svg/SVGColor.cpp index 5939b48..f939ef0 100644 --- a/WebCore/svg/SVGColor.cpp +++ b/WebCore/svg/SVGColor.cpp @@ -25,6 +25,7 @@ #include "SVGColor.h" #include "CSSParser.h" +#include "RGBColor.h" #include "SVGException.h" namespace WebCore { @@ -61,9 +62,9 @@ unsigned short SVGColor::colorType() const return m_colorType; } -unsigned SVGColor::rgbColor() const +RGBColor* SVGColor::rgbColor() const { - return m_color.rgb(); + return RGBColor::create(m_color.rgb()).releaseRef(); } void SVGColor::setRGBColor(const String& rgbColor, ExceptionCode& ec) diff --git a/WebCore/svg/SVGColor.h b/WebCore/svg/SVGColor.h index e3a4b19..5dfb694 100644 --- a/WebCore/svg/SVGColor.h +++ b/WebCore/svg/SVGColor.h @@ -28,6 +28,8 @@ namespace WebCore { + class RGBColor; + class SVGColor : public CSSValue { public: static PassRefPtr<SVGColor> create(const String& color) @@ -55,7 +57,7 @@ namespace WebCore { // 'SVGColor' functions unsigned short colorType() const; - unsigned rgbColor() const; + RGBColor* rgbColor() const; static Color colorFromRGBColorString(const String&); diff --git a/WebCore/svg/SVGDocument.cpp b/WebCore/svg/SVGDocument.cpp index 9244873..fe8ab80 100644 --- a/WebCore/svg/SVGDocument.cpp +++ b/WebCore/svg/SVGDocument.cpp @@ -99,6 +99,13 @@ void SVGDocument::updatePan(const FloatPoint& pos) const } } +bool SVGDocument::childShouldCreateRenderer(Node* node) const +{ + if (node->hasTagName(SVGNames::svgTag)) + return static_cast<SVGSVGElement*>(node)->isValid(); + return true; +} + } // vim:ts=4:noet diff --git a/WebCore/svg/SVGDocument.h b/WebCore/svg/SVGDocument.h index 1411017..02e3649 100644 --- a/WebCore/svg/SVGDocument.h +++ b/WebCore/svg/SVGDocument.h @@ -52,6 +52,8 @@ namespace WebCore { void startPan(const FloatPoint& start); void updatePan(const FloatPoint& pos) const; + virtual bool childShouldCreateRenderer(Node*) const; + private: SVGDocument(Frame*); diff --git a/WebCore/svg/SVGDocumentExtensions.cpp b/WebCore/svg/SVGDocumentExtensions.cpp index d7169e1..61645f4 100644 --- a/WebCore/svg/SVGDocumentExtensions.cpp +++ b/WebCore/svg/SVGDocumentExtensions.cpp @@ -89,13 +89,13 @@ void SVGDocumentExtensions::unpauseAnimations() void SVGDocumentExtensions::reportWarning(const String& message) { if (Frame* frame = m_doc->frame()) - frame->domWindow()->console()->addMessage(JSMessageSource, ErrorMessageLevel, "Warning: " + message, m_doc->tokenizer() ? m_doc->tokenizer()->lineNumber() : 1, String()); + frame->domWindow()->console()->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "Warning: " + message, m_doc->tokenizer() ? m_doc->tokenizer()->lineNumber() : 1, String()); } void SVGDocumentExtensions::reportError(const String& message) { if (Frame* frame = m_doc->frame()) - frame->domWindow()->console()->addMessage(JSMessageSource, ErrorMessageLevel, "Error: " + message, m_doc->tokenizer() ? m_doc->tokenizer()->lineNumber() : 1, String()); + frame->domWindow()->console()->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "Error: " + message, m_doc->tokenizer() ? m_doc->tokenizer()->lineNumber() : 1, String()); } void SVGDocumentExtensions::addPendingResource(const AtomicString& id, SVGStyledElement* obj) diff --git a/WebCore/svg/SVGElementInstance.cpp b/WebCore/svg/SVGElementInstance.cpp index 7cc1798..01555fc 100644 --- a/WebCore/svg/SVGElementInstance.cpp +++ b/WebCore/svg/SVGElementInstance.cpp @@ -136,7 +136,7 @@ void SVGElementInstance::setNeedsUpdate(bool value) ScriptExecutionContext* SVGElementInstance::scriptExecutionContext() const { if (SVGElement* element = correspondingElement()) - return element->scriptExecutionContext(); + return element->document(); return 0; } diff --git a/WebCore/svg/SVGElementInstance.h b/WebCore/svg/SVGElementInstance.h index 7c56792..c477718 100644 --- a/WebCore/svg/SVGElementInstance.h +++ b/WebCore/svg/SVGElementInstance.h @@ -44,8 +44,7 @@ namespace WebCore { // SVGElementInstance mimics Node, but without providing all its functionality class SVGElementInstance : public TreeShared<SVGElementInstance>, - public EventTarget - { + public EventTarget { public: SVGElementInstance(SVGUseElement*, SVGElement* originalElement); virtual ~SVGElementInstance(); diff --git a/WebCore/svg/SVGElementInstance.idl b/WebCore/svg/SVGElementInstance.idl index 3d88178..cd4213c 100644 --- a/WebCore/svg/SVGElementInstance.idl +++ b/WebCore/svg/SVGElementInstance.idl @@ -31,7 +31,7 @@ module svg { CustomListeners, CustomMarkFunction, CustomPushEventHandlerScope, - GenerateToJS, + CustomToJS, GenerateNativeConverter ] SVGElementInstance #if defined(LANGUAGE_OBJECTIVE_C) && LANGUAGE_OBJECTIVE_C diff --git a/WebCore/svg/SVGFEBlendElement.cpp b/WebCore/svg/SVGFEBlendElement.cpp index f78412c..0497ea9 100644 --- a/WebCore/svg/SVGFEBlendElement.cpp +++ b/WebCore/svg/SVGFEBlendElement.cpp @@ -69,7 +69,7 @@ bool SVGFEBlendElement::build(SVGResourceFilter* filterResource) FilterEffect* input1 = filterResource->builder()->getEffectById(in1()); FilterEffect* input2 = filterResource->builder()->getEffectById(in2()); - if(!input1 || !input2) + if (!input1 || !input2) return false; RefPtr<FilterEffect> effect = FEBlend::create(input1, input2, static_cast<BlendModeType>(mode())); diff --git a/WebCore/svg/SVGFEBlendElement.h b/WebCore/svg/SVGFEBlendElement.h index 70e5e06..bed649f 100644 --- a/WebCore/svg/SVGFEBlendElement.h +++ b/WebCore/svg/SVGFEBlendElement.h @@ -27,10 +27,8 @@ #include "FEBlend.h" #include "SVGFilterPrimitiveStandardAttributes.h" -namespace WebCore -{ - class SVGFEBlendElement : public SVGFilterPrimitiveStandardAttributes - { +namespace WebCore { + class SVGFEBlendElement : public SVGFilterPrimitiveStandardAttributes { public: SVGFEBlendElement(const QualifiedName&, Document*); virtual ~SVGFEBlendElement(); diff --git a/WebCore/svg/SVGFEColorMatrixElement.cpp b/WebCore/svg/SVGFEColorMatrixElement.cpp index 660f000..c2d605b 100644 --- a/WebCore/svg/SVGFEColorMatrixElement.cpp +++ b/WebCore/svg/SVGFEColorMatrixElement.cpp @@ -69,7 +69,7 @@ bool SVGFEColorMatrixElement::build(SVGResourceFilter* filterResource) { FilterEffect* input1 = filterResource->builder()->getEffectById(in1()); - if(!input1) + if (!input1) return false; Vector<float> _values; diff --git a/WebCore/svg/SVGFEComponentTransferElement.cpp b/WebCore/svg/SVGFEComponentTransferElement.cpp index cad60dc..691d5cd 100644 --- a/WebCore/svg/SVGFEComponentTransferElement.cpp +++ b/WebCore/svg/SVGFEComponentTransferElement.cpp @@ -60,7 +60,7 @@ bool SVGFEComponentTransferElement::build(SVGResourceFilter* filterResource) { FilterEffect* input1 = filterResource->builder()->getEffectById(in1()); - if(!input1) + if (!input1) return false; ComponentTransferFunction red; diff --git a/WebCore/svg/SVGFECompositeElement.cpp b/WebCore/svg/SVGFECompositeElement.cpp index 2205243..6eec6ea 100644 --- a/WebCore/svg/SVGFECompositeElement.cpp +++ b/WebCore/svg/SVGFECompositeElement.cpp @@ -85,7 +85,7 @@ bool SVGFECompositeElement::build(SVGResourceFilter* filterResource) FilterEffect* input1 = filterResource->builder()->getEffectById(in1()); FilterEffect* input2 = filterResource->builder()->getEffectById(in2()); - if(!input1 || !input2) + if (!input1 || !input2) return false; RefPtr<FilterEffect> effect = FEComposite::create(input1, input2, static_cast<CompositeOperationType>(_operator()), diff --git a/WebCore/svg/SVGFEDiffuseLightingElement.cpp b/WebCore/svg/SVGFEDiffuseLightingElement.cpp index 00ff55a..edbd852 100644 --- a/WebCore/svg/SVGFEDiffuseLightingElement.cpp +++ b/WebCore/svg/SVGFEDiffuseLightingElement.cpp @@ -75,7 +75,7 @@ bool SVGFEDiffuseLightingElement::build(SVGResourceFilter* filterResource) { FilterEffect* input1 = filterResource->builder()->getEffectById(in1()); - if(!input1) + if (!input1) return false; RefPtr<RenderStyle> filterStyle = styleForRenderer(); diff --git a/WebCore/svg/SVGFEDisplacementMapElement.cpp b/WebCore/svg/SVGFEDisplacementMapElement.cpp index 8ac668c..adf02fe 100644 --- a/WebCore/svg/SVGFEDisplacementMapElement.cpp +++ b/WebCore/svg/SVGFEDisplacementMapElement.cpp @@ -77,7 +77,7 @@ bool SVGFEDisplacementMapElement::build(SVGResourceFilter* filterResource) FilterEffect* input1 = filterResource->builder()->getEffectById(in1()); FilterEffect* input2 = filterResource->builder()->getEffectById(in2()); - if(!input1 || !input2) + if (!input1 || !input2) return false; diff --git a/WebCore/svg/SVGFEDistantLightElement.h b/WebCore/svg/SVGFEDistantLightElement.h index e340549..95f45c8 100644 --- a/WebCore/svg/SVGFEDistantLightElement.h +++ b/WebCore/svg/SVGFEDistantLightElement.h @@ -23,10 +23,8 @@ #if ENABLE(SVG) && ENABLE(FILTERS) #include "SVGFELightElement.h" -namespace WebCore -{ - class SVGFEDistantLightElement : public SVGFELightElement - { +namespace WebCore { + class SVGFEDistantLightElement : public SVGFELightElement { public: SVGFEDistantLightElement(const QualifiedName&, Document*); virtual ~SVGFEDistantLightElement(); diff --git a/WebCore/svg/SVGFEFloodElement.cpp b/WebCore/svg/SVGFEFloodElement.cpp index e12b4e1..ae5ce94 100644 --- a/WebCore/svg/SVGFEFloodElement.cpp +++ b/WebCore/svg/SVGFEFloodElement.cpp @@ -55,7 +55,7 @@ bool SVGFEFloodElement::build(SVGResourceFilter* filterResource) { FilterEffect* input = filterResource->builder()->getEffectById(in1()); - if(!input) + if (!input) return false; RefPtr<RenderStyle> filterStyle = styleForRenderer(); diff --git a/WebCore/svg/SVGFEFloodElement.h b/WebCore/svg/SVGFEFloodElement.h index 4a4cffc..ca4e18b 100644 --- a/WebCore/svg/SVGFEFloodElement.h +++ b/WebCore/svg/SVGFEFloodElement.h @@ -27,10 +27,8 @@ #include "SVGFEFlood.h" #include "SVGFilterPrimitiveStandardAttributes.h" -namespace WebCore -{ - class SVGFEFloodElement : public SVGFilterPrimitiveStandardAttributes - { +namespace WebCore { + class SVGFEFloodElement : public SVGFilterPrimitiveStandardAttributes { public: SVGFEFloodElement(const QualifiedName&, Document*); virtual ~SVGFEFloodElement(); diff --git a/WebCore/svg/SVGFEFuncAElement.h b/WebCore/svg/SVGFEFuncAElement.h index 2c24039..8ec6b1c 100644 --- a/WebCore/svg/SVGFEFuncAElement.h +++ b/WebCore/svg/SVGFEFuncAElement.h @@ -26,10 +26,8 @@ #if ENABLE(SVG) && ENABLE(FILTERS) #include "SVGComponentTransferFunctionElement.h" -namespace WebCore -{ - class SVGFEFuncAElement : public SVGComponentTransferFunctionElement - { +namespace WebCore { + class SVGFEFuncAElement : public SVGComponentTransferFunctionElement { public: SVGFEFuncAElement(const QualifiedName&, Document*); virtual ~SVGFEFuncAElement(); diff --git a/WebCore/svg/SVGFEFuncBElement.h b/WebCore/svg/SVGFEFuncBElement.h index 1eb0889..5d86f87 100644 --- a/WebCore/svg/SVGFEFuncBElement.h +++ b/WebCore/svg/SVGFEFuncBElement.h @@ -26,10 +26,8 @@ #if ENABLE(SVG) && ENABLE(FILTERS) #include "SVGComponentTransferFunctionElement.h" -namespace WebCore -{ - class SVGFEFuncBElement : public SVGComponentTransferFunctionElement - { +namespace WebCore { + class SVGFEFuncBElement : public SVGComponentTransferFunctionElement { public: SVGFEFuncBElement(const QualifiedName&, Document*); virtual ~SVGFEFuncBElement(); diff --git a/WebCore/svg/SVGFEFuncGElement.h b/WebCore/svg/SVGFEFuncGElement.h index 973360e..9f5d3d7 100644 --- a/WebCore/svg/SVGFEFuncGElement.h +++ b/WebCore/svg/SVGFEFuncGElement.h @@ -26,10 +26,8 @@ #if ENABLE(SVG) && ENABLE(FILTERS) #include "SVGComponentTransferFunctionElement.h" -namespace WebCore -{ - class SVGFEFuncGElement : public SVGComponentTransferFunctionElement - { +namespace WebCore { + class SVGFEFuncGElement : public SVGComponentTransferFunctionElement { public: SVGFEFuncGElement(const QualifiedName&, Document*); virtual ~SVGFEFuncGElement(); diff --git a/WebCore/svg/SVGFEFuncRElement.h b/WebCore/svg/SVGFEFuncRElement.h index 3553954..0a0d115 100644 --- a/WebCore/svg/SVGFEFuncRElement.h +++ b/WebCore/svg/SVGFEFuncRElement.h @@ -26,10 +26,8 @@ #if ENABLE(SVG) && ENABLE(FILTERS) #include "SVGComponentTransferFunctionElement.h" -namespace WebCore -{ - class SVGFEFuncRElement : public SVGComponentTransferFunctionElement - { +namespace WebCore { + class SVGFEFuncRElement : public SVGComponentTransferFunctionElement { public: SVGFEFuncRElement(const QualifiedName&, Document*); virtual ~SVGFEFuncRElement(); diff --git a/WebCore/svg/SVGFEGaussianBlurElement.cpp b/WebCore/svg/SVGFEGaussianBlurElement.cpp index be3554f..4cddb5a 100644 --- a/WebCore/svg/SVGFEGaussianBlurElement.cpp +++ b/WebCore/svg/SVGFEGaussianBlurElement.cpp @@ -71,7 +71,7 @@ bool SVGFEGaussianBlurElement::build(SVGResourceFilter* filterResource) { FilterEffect* input1 = filterResource->builder()->getEffectById(in1()); - if(!input1) + if (!input1) return false; RefPtr<FilterEffect> effect = FEGaussianBlur::create(input1, stdDeviationX(), stdDeviationY()); diff --git a/WebCore/svg/SVGFEImageElement.cpp b/WebCore/svg/SVGFEImageElement.cpp index ae69e0d..8122960 100644 --- a/WebCore/svg/SVGFEImageElement.cpp +++ b/WebCore/svg/SVGFEImageElement.cpp @@ -86,7 +86,7 @@ void SVGFEImageElement::notifyFinished(CachedResource*) bool SVGFEImageElement::build(SVGResourceFilter* filterResource) { - if(!m_cachedImage) + if (!m_cachedImage) return false; RefPtr<FilterEffect> effect = FEImage::create(m_cachedImage.get()); diff --git a/WebCore/svg/SVGFEMergeElement.cpp b/WebCore/svg/SVGFEMergeElement.cpp index 0640066..cb3a781 100644 --- a/WebCore/svg/SVGFEMergeElement.cpp +++ b/WebCore/svg/SVGFEMergeElement.cpp @@ -49,7 +49,7 @@ bool SVGFEMergeElement::build(SVGResourceFilter* filterResource) } } - if(mergeInputs.isEmpty()) + if (mergeInputs.isEmpty()) return false; RefPtr<FilterEffect> effect = FEMerge::create(mergeInputs); diff --git a/WebCore/svg/SVGFEOffsetElement.cpp b/WebCore/svg/SVGFEOffsetElement.cpp index c7e4e77..945a9da 100644 --- a/WebCore/svg/SVGFEOffsetElement.cpp +++ b/WebCore/svg/SVGFEOffsetElement.cpp @@ -60,7 +60,7 @@ bool SVGFEOffsetElement::build(SVGResourceFilter* filterResource) { FilterEffect* input1 = filterResource->builder()->getEffectById(in1()); - if(!input1) + if (!input1) return false; RefPtr<FilterEffect> effect = FEOffset::create(input1, dx(), dy()); diff --git a/WebCore/svg/SVGFEPointLightElement.h b/WebCore/svg/SVGFEPointLightElement.h index edb9f9d..b39fffa 100644 --- a/WebCore/svg/SVGFEPointLightElement.h +++ b/WebCore/svg/SVGFEPointLightElement.h @@ -23,10 +23,8 @@ #if ENABLE(SVG) && ENABLE(FILTERS) #include "SVGFELightElement.h" -namespace WebCore -{ - class SVGFEPointLightElement : public SVGFELightElement - { +namespace WebCore { + class SVGFEPointLightElement : public SVGFELightElement { public: SVGFEPointLightElement(const QualifiedName&, Document*); virtual ~SVGFEPointLightElement(); diff --git a/WebCore/svg/SVGFESpecularLightingElement.cpp b/WebCore/svg/SVGFESpecularLightingElement.cpp index 36dd453..7afa4cc 100644 --- a/WebCore/svg/SVGFESpecularLightingElement.cpp +++ b/WebCore/svg/SVGFESpecularLightingElement.cpp @@ -90,7 +90,7 @@ bool SVGFESpecularLightingElement::build(SVGResourceFilter* filterResource) { FilterEffect* input1 = filterResource->builder()->getEffectById(in1()); - if(!input1) + if (!input1) return false; RefPtr<RenderStyle> filterStyle = styleForRenderer(); diff --git a/WebCore/svg/SVGFESpotLightElement.h b/WebCore/svg/SVGFESpotLightElement.h index 629e51a..440c664 100644 --- a/WebCore/svg/SVGFESpotLightElement.h +++ b/WebCore/svg/SVGFESpotLightElement.h @@ -23,10 +23,8 @@ #if ENABLE(SVG) && ENABLE(FILTERS) #include "SVGFELightElement.h" -namespace WebCore -{ - class SVGFESpotLightElement : public SVGFELightElement - { +namespace WebCore { + class SVGFESpotLightElement : public SVGFELightElement { public: SVGFESpotLightElement(const QualifiedName&, Document*); virtual ~SVGFESpotLightElement(); diff --git a/WebCore/svg/SVGFETileElement.cpp b/WebCore/svg/SVGFETileElement.cpp index d5828eb..14af25f 100644 --- a/WebCore/svg/SVGFETileElement.cpp +++ b/WebCore/svg/SVGFETileElement.cpp @@ -55,7 +55,7 @@ bool SVGFETileElement::build(SVGResourceFilter* filterResource) { FilterEffect* input1 = filterResource->builder()->getEffectById(in1()); - if(!input1) + if (!input1) return false; RefPtr<FilterEffect> effect = FETile::create(input1); diff --git a/WebCore/svg/SVGFilterPrimitiveStandardAttributes.cpp b/WebCore/svg/SVGFilterPrimitiveStandardAttributes.cpp index 13116a5..3eeb625 100644 --- a/WebCore/svg/SVGFilterPrimitiveStandardAttributes.cpp +++ b/WebCore/svg/SVGFilterPrimitiveStandardAttributes.cpp @@ -79,6 +79,15 @@ void SVGFilterPrimitiveStandardAttributes::setStandardAttributes(SVGResourceFilt float _x, _y, _width, _height; + if (this->hasAttribute(SVGNames::xAttr)) + filterEffect->setHasX(true); + if (this->hasAttribute(SVGNames::yAttr)) + filterEffect->setHasY(true); + if (this->hasAttribute(SVGNames::widthAttr)) + filterEffect->setHasWidth(true); + if (this->hasAttribute(SVGNames::heightAttr)) + filterEffect->setHasHeight(true); + if (resourceFilter->effectBoundingBoxMode()) { _x = x().valueAsPercentage(); _y = y().valueAsPercentage(); diff --git a/WebCore/svg/SVGImageElement.cpp b/WebCore/svg/SVGImageElement.cpp index 9aff93d..299828f 100644 --- a/WebCore/svg/SVGImageElement.cpp +++ b/WebCore/svg/SVGImageElement.cpp @@ -1,10 +1,8 @@ /* Copyright (C) 2004, 2005, 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org> - 2004, 2005, 2006, 2007, 2008 Rob Buis <buis@kde.org> + 2004, 2005, 2006, 2007, 2008, 2009 Rob Buis <buis@kde.org> 2006 Alexander Kellett <lypanov@kde.org> - This file is part of the KDE project - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either @@ -93,23 +91,20 @@ void SVGImageElement::svgAttributeChanged(const QualifiedName& attrName) { SVGStyledTransformableElement::svgAttributeChanged(attrName); + if (SVGURIReference::isKnownAttribute(attrName)) + m_imageLoader.updateFromElementIgnoringPreviousError(); + if (!renderer()) return; - bool isURIAttribute = SVGURIReference::isKnownAttribute(attrName); - if (attrName == SVGNames::xAttr || attrName == SVGNames::yAttr || attrName == SVGNames::widthAttr || attrName == SVGNames::heightAttr || attrName == SVGNames::preserveAspectRatioAttr || SVGTests::isKnownAttribute(attrName) || SVGLangSpace::isKnownAttribute(attrName) || SVGExternalResourcesRequired::isKnownAttribute(attrName) || - isURIAttribute || SVGStyledTransformableElement::isKnownAttribute(attrName)) { renderer()->setNeedsLayout(true); - - if (isURIAttribute) - m_imageLoader.updateFromElementIgnoringPreviousError(); } } @@ -133,7 +128,7 @@ void SVGImageElement::attach() { SVGStyledTransformableElement::attach(); - if (RenderSVGImage* imageObj = static_cast<RenderSVGImage*>(renderer())) { + if (RenderImage* imageObj = toRenderImage(renderer())) { if (imageObj->hasImage()) return; diff --git a/WebCore/svg/SVGImageLoader.cpp b/WebCore/svg/SVGImageLoader.cpp index 9333f75..f8380f5 100644 --- a/WebCore/svg/SVGImageLoader.cpp +++ b/WebCore/svg/SVGImageLoader.cpp @@ -53,7 +53,7 @@ void SVGImageLoader::dispatchLoadEvent() String SVGImageLoader::sourceURI(const AtomicString& attr) const { - return parseURL(KURL(element()->baseURI(), attr).string()); + return deprecatedParseURL(KURL(element()->baseURI(), attr).string()); } } diff --git a/WebCore/svg/SVGLineElement.cpp b/WebCore/svg/SVGLineElement.cpp index 17c110c..cb31178 100644 --- a/WebCore/svg/SVGLineElement.cpp +++ b/WebCore/svg/SVGLineElement.cpp @@ -59,8 +59,7 @@ void SVGLineElement::parseMappedAttribute(MappedAttribute* attr) setX2BaseValue(SVGLength(LengthModeWidth, attr->value())); else if (attr->name() == SVGNames::y2Attr) setY2BaseValue(SVGLength(LengthModeHeight, attr->value())); - else - { + else { if (SVGTests::parseMappedAttribute(attr)) return; if (SVGLangSpace::parseMappedAttribute(attr)) diff --git a/WebCore/svg/SVGList.h b/WebCore/svg/SVGList.h index 5381598..c04c200 100644 --- a/WebCore/svg/SVGList.h +++ b/WebCore/svg/SVGList.h @@ -165,8 +165,7 @@ namespace WebCore { }; template<typename Item> - class SVGPODList : public SVGList<RefPtr<SVGPODListItem<Item> > > - { + class SVGPODList : public SVGList<RefPtr<SVGPODListItem<Item> > > { public: Item initialize(Item newItem, ExceptionCode& ec) { diff --git a/WebCore/svg/SVGListTraits.h b/WebCore/svg/SVGListTraits.h index b028ad5..d96bc67 100644 --- a/WebCore/svg/SVGListTraits.h +++ b/WebCore/svg/SVGListTraits.h @@ -34,14 +34,12 @@ namespace WebCore { struct SVGListTraits { }; template<typename Item> - struct SVGListTraits<true, Item> - { + struct SVGListTraits<true, Item> { static Item nullItem() { return Item(); } }; template<> - struct SVGListTraits<false, double> - { + struct SVGListTraits<false, double> { static double nullItem() { return 0.0; } }; diff --git a/WebCore/svg/SVGMPathElement.h b/WebCore/svg/SVGMPathElement.h index 1e84cc7..988cead 100644 --- a/WebCore/svg/SVGMPathElement.h +++ b/WebCore/svg/SVGMPathElement.h @@ -32,8 +32,7 @@ namespace WebCore { class SVGMPathElement : public SVGElement, SVGURIReference, - SVGExternalResourcesRequired - { + SVGExternalResourcesRequired { public: SVGMPathElement(const QualifiedName&, Document*); virtual ~SVGMPathElement(); diff --git a/WebCore/svg/SVGMarkerElement.cpp b/WebCore/svg/SVGMarkerElement.cpp index 5580993..b09e718 100644 --- a/WebCore/svg/SVGMarkerElement.cpp +++ b/WebCore/svg/SVGMarkerElement.cpp @@ -170,7 +170,7 @@ SVGResource* SVGMarkerElement::canvasResource() if (!m_marker) m_marker = SVGResourceMarker::create(); - m_marker->setMarker(static_cast<RenderSVGViewportContainer*>(renderer())); + m_marker->setMarker(toRenderSVGViewportContainer(renderer())); if (orientType() == SVG_MARKER_ORIENT_ANGLE) { if (orientAngle()) diff --git a/WebCore/svg/SVGMaskElement.cpp b/WebCore/svg/SVGMaskElement.cpp index 59a5e01..6b75527 100644 --- a/WebCore/svg/SVGMaskElement.cpp +++ b/WebCore/svg/SVGMaskElement.cpp @@ -154,7 +154,7 @@ PassOwnPtr<ImageBuffer> SVGMaskElement::drawMaskerContent(const FloatRect& targe if (imageSize.height() < static_cast<int>(heightValue)) heightValue = imageSize.height(); - OwnPtr<ImageBuffer> maskImage = ImageBuffer::create(imageSize, false); + OwnPtr<ImageBuffer> maskImage = ImageBuffer::create(imageSize); if (!maskImage) return 0; diff --git a/WebCore/svg/SVGMetadataElement.h b/WebCore/svg/SVGMetadataElement.h index 4bd87d6..63d0aae 100644 --- a/WebCore/svg/SVGMetadataElement.h +++ b/WebCore/svg/SVGMetadataElement.h @@ -26,10 +26,8 @@ #include "SVGElement.h" -namespace WebCore -{ - class SVGMetadataElement : public SVGElement - { +namespace WebCore { + class SVGMetadataElement : public SVGElement { public: SVGMetadataElement(const QualifiedName&, Document*); virtual ~SVGMetadataElement(); diff --git a/WebCore/svg/SVGParserUtilities.cpp b/WebCore/svg/SVGParserUtilities.cpp index 7d93f59..6f696e6 100644 --- a/WebCore/svg/SVGParserUtilities.cpp +++ b/WebCore/svg/SVGParserUtilities.cpp @@ -246,7 +246,7 @@ bool SVGPathParser::parseSVG(const String& s, bool process) bool relative = false; - switch(command) + switch (command) { case 'm': relative = true; @@ -625,7 +625,7 @@ void SVGPathParser::calculateArc(bool relative, double& curx, double& cury, doub n_segs = (int) (int) ceil(fabs(th_arc / (piDouble * 0.5 + 0.001))); - for(i = 0; i < n_segs; i++) { + for (i = 0; i < n_segs; i++) { double sin_th, cos_th; double a00, a01, a10, a11; double x1, y1, x2, y2, x3, y3; diff --git a/WebCore/svg/SVGPathElement.h b/WebCore/svg/SVGPathElement.h index a39e628..362a85b 100644 --- a/WebCore/svg/SVGPathElement.h +++ b/WebCore/svg/SVGPathElement.h @@ -56,8 +56,7 @@ namespace WebCore { public SVGTests, public SVGLangSpace, public SVGExternalResourcesRequired, - public SVGAnimatedPathData - { + public SVGAnimatedPathData { public: SVGPathElement(const QualifiedName&, Document*); virtual ~SVGPathElement(); diff --git a/WebCore/svg/SVGPathSeg.idl b/WebCore/svg/SVGPathSeg.idl index 597b01d..6754d2a 100644 --- a/WebCore/svg/SVGPathSeg.idl +++ b/WebCore/svg/SVGPathSeg.idl @@ -26,7 +26,7 @@ module svg { - interface [Conditional=SVG, GenerateConstructor, Polymorphic] SVGPathSeg { + interface [Conditional=SVG, CustomToJS, GenerateConstructor, Polymorphic] SVGPathSeg { // Path Segment Types const unsigned short PATHSEG_UNKNOWN = 0; const unsigned short PATHSEG_CLOSEPATH = 1; diff --git a/WebCore/svg/SVGPathSegClosePath.h b/WebCore/svg/SVGPathSegClosePath.h index eb74dea..190af9e 100644 --- a/WebCore/svg/SVGPathSegClosePath.h +++ b/WebCore/svg/SVGPathSegClosePath.h @@ -27,10 +27,8 @@ #include "SVGPathSeg.h" -namespace WebCore -{ - class SVGPathSegClosePath : public SVGPathSeg - { +namespace WebCore { + class SVGPathSegClosePath : public SVGPathSeg { public: static PassRefPtr<SVGPathSegClosePath> create() { return adoptRef(new SVGPathSegClosePath); } virtual ~SVGPathSegClosePath(); diff --git a/WebCore/svg/SVGPatternElement.cpp b/WebCore/svg/SVGPatternElement.cpp index cfae425..befca85 100644 --- a/WebCore/svg/SVGPatternElement.cpp +++ b/WebCore/svg/SVGPatternElement.cpp @@ -214,7 +214,7 @@ void SVGPatternElement::buildPattern(const FloatRect& targetRect) const IntSize imageSize(lroundf(patternBoundariesIncludingOverflow.width()), lroundf(patternBoundariesIncludingOverflow.height())); clampImageBufferSizeToViewport(document()->view(), imageSize); - OwnPtr<ImageBuffer> patternImage = ImageBuffer::create(imageSize, false); + OwnPtr<ImageBuffer> patternImage = ImageBuffer::create(imageSize); if (!patternImage) return; diff --git a/WebCore/svg/SVGPolyElement.h b/WebCore/svg/SVGPolyElement.h index 0de9f1b..8dd16cd 100644 --- a/WebCore/svg/SVGPolyElement.h +++ b/WebCore/svg/SVGPolyElement.h @@ -58,7 +58,6 @@ namespace WebCore { virtual const SVGElement* contextElement() const { return this; } private: - bool m_ignoreAttributeChanges : 1; mutable RefPtr<SVGPointList> m_points; }; diff --git a/WebCore/svg/SVGSVGElement.h b/WebCore/svg/SVGSVGElement.h index fe8575b..f92ed72 100644 --- a/WebCore/svg/SVGSVGElement.h +++ b/WebCore/svg/SVGSVGElement.h @@ -33,8 +33,7 @@ #include "SVGTests.h" #include "SVGZoomAndPan.h" -namespace WebCore -{ +namespace WebCore { class SVGAngle; class SVGLength; class SVGTransform; @@ -46,8 +45,7 @@ namespace WebCore public SVGLangSpace, public SVGExternalResourcesRequired, public SVGFitToViewBox, - public SVGZoomAndPan - { + public SVGZoomAndPan { public: SVGSVGElement(const QualifiedName&, Document*); virtual ~SVGSVGElement(); diff --git a/WebCore/svg/SVGSetElement.h b/WebCore/svg/SVGSetElement.h index d47e003..fda6919 100644 --- a/WebCore/svg/SVGSetElement.h +++ b/WebCore/svg/SVGSetElement.h @@ -26,11 +26,9 @@ #include "SVGAnimateElement.h" -namespace WebCore -{ +namespace WebCore { // SVGAnimateElement implements superset of the functionality. - class SVGSetElement : public SVGAnimateElement - { + class SVGSetElement : public SVGAnimateElement { public: SVGSetElement(const QualifiedName&, Document*); }; diff --git a/WebCore/svg/SVGSwitchElement.h b/WebCore/svg/SVGSwitchElement.h index 82153d9..a2be835 100644 --- a/WebCore/svg/SVGSwitchElement.h +++ b/WebCore/svg/SVGSwitchElement.h @@ -29,13 +29,11 @@ #include "SVGStyledTransformableElement.h" #include "SVGTests.h" -namespace WebCore -{ +namespace WebCore { class SVGSwitchElement : public SVGStyledTransformableElement, public SVGTests, public SVGLangSpace, - public SVGExternalResourcesRequired - { + public SVGExternalResourcesRequired { public: SVGSwitchElement(const QualifiedName&, Document*); virtual ~SVGSwitchElement(); diff --git a/WebCore/svg/SVGTextContentElement.cpp b/WebCore/svg/SVGTextContentElement.cpp index 067f35f..86009c1 100644 --- a/WebCore/svg/SVGTextContentElement.cpp +++ b/WebCore/svg/SVGTextContentElement.cpp @@ -328,7 +328,7 @@ static inline SVGRootInlineBox* rootInlineBoxForTextContentElement(const SVGText if (!object || !object->isSVGText() || object->isText()) return 0; - RenderSVGText* svgText = static_cast<RenderSVGText*>(object); + RenderBlock* svgText = toRenderBlock(object); // Find root inline box SVGRootInlineBox* rootBox = static_cast<SVGRootInlineBox*>(svgText->firstRootBox()); diff --git a/WebCore/svg/SVGTextPathElement.cpp b/WebCore/svg/SVGTextPathElement.cpp index 0d8560a..54a4aa2 100644 --- a/WebCore/svg/SVGTextPathElement.cpp +++ b/WebCore/svg/SVGTextPathElement.cpp @@ -57,7 +57,7 @@ void SVGTextPathElement::parseMappedAttribute(MappedAttribute* attr) else if (attr->name() == SVGNames::methodAttr) { if (value == "align") setSpacingBaseValue(SVG_TEXTPATH_METHODTYPE_ALIGN); - else if(value == "stretch") + else if (value == "stretch") setSpacingBaseValue(SVG_TEXTPATH_METHODTYPE_STRETCH); } else if (attr->name() == SVGNames::spacingAttr) { if (value == "auto") diff --git a/WebCore/svg/SVGTextPathElement.h b/WebCore/svg/SVGTextPathElement.h index e1dd938..4e8899a 100644 --- a/WebCore/svg/SVGTextPathElement.h +++ b/WebCore/svg/SVGTextPathElement.h @@ -27,8 +27,7 @@ #include "SVGURIReference.h" -namespace WebCore -{ +namespace WebCore { enum SVGTextPathMethodType { SVG_TEXTPATH_METHODTYPE_UNKNOWN = 0, SVG_TEXTPATH_METHODTYPE_ALIGN = 1, @@ -42,8 +41,7 @@ namespace WebCore }; class SVGTextPathElement : public SVGTextContentElement, - public SVGURIReference - { + public SVGURIReference { public: // Forward declare these enums in the w3c naming scheme, for IDL generation enum { diff --git a/WebCore/svg/SVGTitleElement.h b/WebCore/svg/SVGTitleElement.h index cd4768c..e053a42 100644 --- a/WebCore/svg/SVGTitleElement.h +++ b/WebCore/svg/SVGTitleElement.h @@ -27,11 +27,9 @@ #include "SVGLangSpace.h" #include "SVGStyledElement.h" -namespace WebCore -{ +namespace WebCore { class SVGTitleElement : public SVGStyledElement, - public SVGLangSpace - { + public SVGLangSpace { public: SVGTitleElement(const QualifiedName&, Document*); diff --git a/WebCore/svg/SVGTransformDistance.cpp b/WebCore/svg/SVGTransformDistance.cpp index 34adc63..00b5387 100644 --- a/WebCore/svg/SVGTransformDistance.cpp +++ b/WebCore/svg/SVGTransformDistance.cpp @@ -35,6 +35,8 @@ namespace WebCore { SVGTransformDistance::SVGTransformDistance() : m_type(SVGTransform::SVG_TRANSFORM_UNKNOWN) , m_angle(0) + , m_cx(0) + , m_cy(0) { } diff --git a/WebCore/svg/SVGTransformList.cpp b/WebCore/svg/SVGTransformList.cpp index ed457f4..648f1e9 100644 --- a/WebCore/svg/SVGTransformList.cpp +++ b/WebCore/svg/SVGTransformList.cpp @@ -26,7 +26,6 @@ #include "TransformationMatrix.h" #include "SVGTransform.h" #include "SVGSVGElement.h" -#include "SVGTransformDistance.h" #include "SVGTransformList.h" using namespace WebCore; @@ -65,23 +64,6 @@ SVGTransform SVGTransformList::concatenate() const return SVGTransform(matrix); } -SVGTransform SVGTransformList::concatenateForType(SVGTransform::SVGTransformType type) const -{ - unsigned int length = numberOfItems(); - if (!length) - return SVGTransform(); - - ExceptionCode ec = 0; - SVGTransformDistance totalTransform; - for (unsigned int i = 0; i < length; i++) { - const SVGTransform& transform = getItem(i, ec); - if (transform.type() == type) - totalTransform.addSVGTransform(transform); - } - - return totalTransform.addToSVGTransform(SVGTransform()); -} - String SVGTransformList::valueAsString() const { // TODO: We may want to build a real transform string, instead of concatting to a matrix(...). diff --git a/WebCore/svg/SVGTransformList.h b/WebCore/svg/SVGTransformList.h index 442016b..d095fe4 100644 --- a/WebCore/svg/SVGTransformList.h +++ b/WebCore/svg/SVGTransformList.h @@ -42,7 +42,6 @@ namespace WebCore { // Internal use only SVGTransform concatenate() const; - SVGTransform concatenateForType(SVGTransform::SVGTransformType) const; String valueAsString() const; diff --git a/WebCore/svg/SVGTransformable.cpp b/WebCore/svg/SVGTransformable.cpp index 6dbfc1a..17344ea 100644 --- a/WebCore/svg/SVGTransformable.cpp +++ b/WebCore/svg/SVGTransformable.cpp @@ -154,12 +154,12 @@ bool SVGTransformable::parseTransformValue(unsigned type, const UChar*& ptr, con return true; } -static const UChar skewXDesc[] = {'s','k','e','w', 'X'}; -static const UChar skewYDesc[] = {'s','k','e','w', 'Y'}; -static const UChar scaleDesc[] = {'s','c','a','l', 'e'}; -static const UChar translateDesc[] = {'t','r','a','n', 's', 'l', 'a', 't', 'e'}; -static const UChar rotateDesc[] = {'r','o','t','a', 't', 'e'}; -static const UChar matrixDesc[] = {'m','a','t','r', 'i', 'x'}; +static const UChar skewXDesc[] = {'s', 'k', 'e', 'w', 'X'}; +static const UChar skewYDesc[] = {'s', 'k', 'e', 'w', 'Y'}; +static const UChar scaleDesc[] = {'s', 'c', 'a', 'l', 'e'}; +static const UChar translateDesc[] = {'t', 'r', 'a', 'n', 's', 'l', 'a', 't', 'e'}; +static const UChar rotateDesc[] = {'r', 'o', 't', 'a', 't', 'e'}; +static const UChar matrixDesc[] = {'m', 'a', 't', 'r', 'i', 'x'}; static inline bool parseAndSkipType(const UChar*& currTransform, const UChar* end, unsigned short& type) { diff --git a/WebCore/svg/SVGViewSpec.cpp b/WebCore/svg/SVGViewSpec.cpp index 6aa3857..b12b1c2 100644 --- a/WebCore/svg/SVGViewSpec.cpp +++ b/WebCore/svg/SVGViewSpec.cpp @@ -82,7 +82,7 @@ const SVGElement* SVGViewSpec::contextElement() const return m_contextElement; } -static const UChar svgViewSpec[] = {'s','v','g','V', 'i', 'e', 'w'}; +static const UChar svgViewSpec[] = {'s', 'v', 'g', 'V', 'i', 'e', 'w'}; static const UChar viewBoxSpec[] = {'v', 'i', 'e', 'w', 'B', 'o', 'x'}; static const UChar preserveAspectRatioSpec[] = {'p', 'r', 'e', 's', 'e', 'r', 'v', 'e', 'A', 's', 'p', 'e', 'c', 't', 'R', 'a', 't', 'i', 'o'}; static const UChar transformSpec[] = {'t', 'r', 'a', 'n', 's', 'f', 'o', 'r', 'm'}; diff --git a/WebCore/svg/SynchronizableTypeWrapper.h b/WebCore/svg/SynchronizableTypeWrapper.h index 418c76d..12f8426 100644 --- a/WebCore/svg/SynchronizableTypeWrapper.h +++ b/WebCore/svg/SynchronizableTypeWrapper.h @@ -26,7 +26,7 @@ namespace WebCore { template<typename StoredType> - class SynchronizableTypeWrapperBase : Noncopyable { + class SynchronizableTypeWrapperBase : public Noncopyable { protected: SynchronizableTypeWrapperBase(); diff --git a/WebCore/svg/animation/SMILTime.cpp b/WebCore/svg/animation/SMILTime.cpp index 70f9487..44e96a2 100644 --- a/WebCore/svg/animation/SMILTime.cpp +++ b/WebCore/svg/animation/SMILTime.cpp @@ -35,7 +35,8 @@ const double SMILTime::unresolvedValue = DBL_MAX; // Just a big value smaller than DBL_MAX. Our times are relative to 0, we don't really need the full range. const double SMILTime::indefiniteValue = FLT_MAX; -SMILTime WebCore::operator+(const SMILTime& a, const SMILTime& b) { +SMILTime WebCore::operator+(const SMILTime& a, const SMILTime& b) +{ if (a.isUnresolved() || b.isUnresolved()) return SMILTime::unresolved(); if (a.isIndefinite() || b.isIndefinite()) @@ -43,7 +44,8 @@ SMILTime WebCore::operator+(const SMILTime& a, const SMILTime& b) { return a.value() + b.value(); } -SMILTime WebCore::operator-(const SMILTime& a, const SMILTime& b) { +SMILTime WebCore::operator-(const SMILTime& a, const SMILTime& b) +{ if (a.isUnresolved() || b.isUnresolved()) return SMILTime::unresolved(); if (a.isIndefinite() || b.isIndefinite()) @@ -51,7 +53,8 @@ SMILTime WebCore::operator-(const SMILTime& a, const SMILTime& b) { return a.value() - b.value(); } -SMILTime WebCore::operator*(const SMILTime& a, const SMILTime& b) { +SMILTime WebCore::operator*(const SMILTime& a, const SMILTime& b) +{ if (a.isUnresolved() || b.isUnresolved()) return SMILTime::unresolved(); if (a.value() == 0 || b.value() == 0) diff --git a/WebCore/svg/animation/SVGSMILElement.h b/WebCore/svg/animation/SVGSMILElement.h index fac102e..b61f20d 100644 --- a/WebCore/svg/animation/SVGSMILElement.h +++ b/WebCore/svg/animation/SVGSMILElement.h @@ -38,8 +38,7 @@ namespace WebCore { class SMILTimeContainer; // This class implements SMIL interval timing model as needed for SVG animation. - class SVGSMILElement : public SVGElement - { + class SVGSMILElement : public SVGElement { public: SVGSMILElement(const QualifiedName&, Document*); virtual ~SVGSMILElement(); diff --git a/WebCore/svg/graphics/SVGImage.cpp b/WebCore/svg/graphics/SVGImage.cpp index 2157144..64eb0e7 100644 --- a/WebCore/svg/graphics/SVGImage.cpp +++ b/WebCore/svg/graphics/SVGImage.cpp @@ -95,7 +95,7 @@ SVGImage::~SVGImage() } // Verify that page teardown destroyed the Chrome - ASSERT(!m_chromeClient->image()); + ASSERT(!m_chromeClient || !m_chromeClient->image()); } void SVGImage::setContainerSize(const IntSize& containerSize) @@ -211,7 +211,7 @@ NativeImagePtr SVGImage::nativeImageForCurrentFrame() if (!m_frameCache) { if (!m_page) return 0; - m_frameCache = ImageBuffer::create(size(), false); + m_frameCache = ImageBuffer::create(size()); if (!m_frameCache) // failed to allocate image return 0; renderSubtreeToImage(m_frameCache.get(), m_page->mainFrame()->contentRenderer()); @@ -222,7 +222,7 @@ NativeImagePtr SVGImage::nativeImageForCurrentFrame() bool SVGImage::dataChanged(bool allDataReceived) { // Don't do anything if is an empty image. - if (!m_data->size()) + if (!data()->size()) return true; if (allDataReceived) { @@ -251,7 +251,7 @@ bool SVGImage::dataChanged(bool allDataReceived) loader->commitProvisionalLoad(0); loader->setResponseMIMEType("image/svg+xml"); loader->begin(KURL()); // create the empty document - loader->write(m_data->data(), m_data->size()); + loader->write(data()->data(), data()->size()); loader->end(); frame->view()->setTransparent(true); // SVG Images are transparent. } diff --git a/WebCore/svg/graphics/SVGPaintServer.cpp b/WebCore/svg/graphics/SVGPaintServer.cpp index 0fcd722..728ff1b 100644 --- a/WebCore/svg/graphics/SVGPaintServer.cpp +++ b/WebCore/svg/graphics/SVGPaintServer.cpp @@ -31,6 +31,7 @@ #include "SVGPaintServer.h" #include "GraphicsContext.h" +#include "NodeRenderStyle.h" #include "RenderObject.h" #include "RenderStyle.h" #include "SVGPaintServerSolid.h" @@ -158,7 +159,7 @@ void applyStrokeStyleToContext(GraphicsContext* context, RenderStyle* style, con if (style->svgStyle()->joinStyle() == MiterJoin) context->setMiterLimit(style->svgStyle()->strokeMiterLimit()); - const DashArray& dashes = dashArrayFromRenderingStyle(object->style()); + const DashArray& dashes = dashArrayFromRenderingStyle(object->style(), object->document()->documentElement()->renderStyle()); float dashOffset = SVGRenderStyle::cssPrimitiveToLength(object, style->svgStyle()->strokeDashOffset(), 0.0f); context->setLineDash(dashes, dashOffset); } @@ -192,8 +193,8 @@ void SVGPaintServer::teardown(GraphicsContext*& context, const RenderObject*, SV // added back to the context after filling. This is because internally it // calls CGContextFillPath() which closes the path. context->beginPath(); - context->platformContext()->setGradient(0); - context->platformContext()->setPattern(0); + context->platformContext()->setFillShader(0); + context->platformContext()->setStrokeShader(0); } #else void SVGPaintServer::teardown(GraphicsContext*&, const RenderObject*, SVGPaintTargetType, bool) const @@ -201,7 +202,7 @@ void SVGPaintServer::teardown(GraphicsContext*&, const RenderObject*, SVGPaintTa } #endif -DashArray dashArrayFromRenderingStyle(const RenderStyle* style) +DashArray dashArrayFromRenderingStyle(const RenderStyle* style, RenderStyle* rootStyle) { DashArray array; @@ -214,7 +215,7 @@ DashArray dashArrayFromRenderingStyle(const RenderStyle* style) if (!dash) continue; - array.append((float) dash->computeLengthFloat(const_cast<RenderStyle*>(style))); + array.append((float) dash->computeLengthFloat(const_cast<RenderStyle*>(style), rootStyle)); } } diff --git a/WebCore/svg/graphics/SVGPaintServer.h b/WebCore/svg/graphics/SVGPaintServer.h index 9174f66..244243c 100644 --- a/WebCore/svg/graphics/SVGPaintServer.h +++ b/WebCore/svg/graphics/SVGPaintServer.h @@ -85,7 +85,7 @@ namespace WebCore { SVGPaintServer* getPaintServerById(Document*, const AtomicString&); void applyStrokeStyleToContext(GraphicsContext*, RenderStyle*, const RenderObject*); - DashArray dashArrayFromRenderingStyle(const RenderStyle* style); + DashArray dashArrayFromRenderingStyle(const RenderStyle* style, RenderStyle* rootStyle); } // namespace WebCore #endif diff --git a/WebCore/svg/graphics/SVGPaintServerGradient.cpp b/WebCore/svg/graphics/SVGPaintServerGradient.cpp index 9ba224e..4a8e9e0 100644 --- a/WebCore/svg/graphics/SVGPaintServerGradient.cpp +++ b/WebCore/svg/graphics/SVGPaintServerGradient.cpp @@ -137,7 +137,7 @@ static inline bool createMaskAndSwapContextForTextGradient( IntSize maskSize(maskRect.width(), maskRect.height()); clampImageBufferSizeToViewport(object->view()->frameView(), maskSize); - OwnPtr<ImageBuffer> maskImage = ImageBuffer::create(maskSize, false); + OwnPtr<ImageBuffer> maskImage = ImageBuffer::create(maskSize); if (!maskImage) return false; diff --git a/WebCore/svg/graphics/SVGPaintServerPattern.cpp b/WebCore/svg/graphics/SVGPaintServerPattern.cpp index 74ea27a..e825a0b 100644 --- a/WebCore/svg/graphics/SVGPaintServerPattern.cpp +++ b/WebCore/svg/graphics/SVGPaintServerPattern.cpp @@ -118,7 +118,7 @@ bool SVGPaintServerPattern::setup(GraphicsContext*& context, const RenderObject* // Draw the first cell of the pattern manually to support overflow="visible" on all platforms. int tileWidth = static_cast<int>(patternBoundaries().width() + 0.5f); int tileHeight = static_cast<int>(patternBoundaries().height() + 0.5f); - OwnPtr<ImageBuffer> tileImage = ImageBuffer::create(IntSize(tileWidth, tileHeight), false); + OwnPtr<ImageBuffer> tileImage = ImageBuffer::create(IntSize(tileWidth, tileHeight)); GraphicsContext* tileImageContext = tileImage->context(); diff --git a/WebCore/svg/graphics/SVGResource.cpp b/WebCore/svg/graphics/SVGResource.cpp index 82c10ba..049edc7 100644 --- a/WebCore/svg/graphics/SVGResource.cpp +++ b/WebCore/svg/graphics/SVGResource.cpp @@ -50,7 +50,8 @@ struct ResourceSet { typedef HashMap<SVGStyledElement*, ResourceSet*> ResourceClientMap; -static ResourceClientMap& clientMap() { +static ResourceClientMap& clientMap() +{ DEFINE_STATIC_LOCAL(ResourceClientMap, map, ()); return map; } diff --git a/WebCore/svg/graphics/SVGResourceFilter.cpp b/WebCore/svg/graphics/SVGResourceFilter.cpp index 6c1dccb..4a4bdd5 100644 --- a/WebCore/svg/graphics/SVGResourceFilter.cpp +++ b/WebCore/svg/graphics/SVGResourceFilter.cpp @@ -66,50 +66,63 @@ FloatRect SVGResourceFilter::filterBBoxForItemBBox(const FloatRect& itemBBox) co return filterBBox; } -void SVGResourceFilter::prepareFilter(GraphicsContext*& context, const FloatRect& itemRect) +void SVGResourceFilter::prepareFilter(GraphicsContext*& context, const RenderObject* object) { + m_itemBBox = object->objectBoundingBox(); + m_filterBBox = filterBBoxForItemBBox(m_itemBBox); + + // clip sourceImage to filterRegion + FloatRect clippedSourceRect = m_itemBBox; + clippedSourceRect.intersect(m_filterBBox); + + // prepare Filters + m_filter = SVGFilter::create(m_itemBBox, m_filterBBox, m_effectBBoxMode, m_filterBBoxMode); + + FilterEffect* lastEffect = m_filterBuilder->lastEffect(); + if (lastEffect) + lastEffect->calculateEffectRect(m_filter.get()); + // Draw the content of the current element and it's childs to a imageBuffer to get the SourceGraphic. - // The size of the SourceGraphic must match the size of the element, the filter is aplied to. - IntSize bufferSize = IntSize(itemRect.width(), itemRect.height()); - OwnPtr<ImageBuffer> sourceGraphic(ImageBuffer::create(bufferSize, false)); + // The size of the SourceGraphic is clipped to the size of the filterRegion. + IntRect bufferRect = enclosingIntRect(clippedSourceRect); + OwnPtr<ImageBuffer> sourceGraphic(ImageBuffer::create(bufferRect.size(), LinearRGB)); if (!sourceGraphic.get()) return; GraphicsContext* sourceGraphicContext = sourceGraphic->context(); - sourceGraphicContext->translate(-itemRect.x(), -itemRect.y()); - sourceGraphicContext->clearRect(FloatRect(0, 0, itemRect.width(), itemRect.height())); + sourceGraphicContext->translate(-m_itemBBox.x(), -m_itemBBox.y()); + sourceGraphicContext->clearRect(FloatRect(FloatPoint(), m_itemBBox.size())); m_sourceGraphicBuffer.set(sourceGraphic.release()); m_savedContext = context; context = sourceGraphicContext; } -void SVGResourceFilter::applyFilter(GraphicsContext*& context, const FloatRect& itemRect) +void SVGResourceFilter::applyFilter(GraphicsContext*& context, const RenderObject*) { if (!m_savedContext) return; - FloatRect filterRect = filterBBoxForItemBBox(itemRect); - - setFilterBoundingBox(filterRect); - setItemBoundingBox(itemRect); - context = m_savedContext; m_savedContext = 0; +#if !PLATFORM(CG) + m_sourceGraphicBuffer->transformColorSpace(DeviceRGB, LinearRGB); +#endif FilterEffect* lastEffect = m_filterBuilder->lastEffect(); - if (lastEffect && !filterRect.isEmpty()) { - RefPtr<Filter> filter = SVGFilter::create(m_itemBBox, m_filterBBox, m_effectBBoxMode, m_filterBBoxMode); - filter->setSourceImage(m_sourceGraphicBuffer->image()); - lastEffect->apply(filter.get()); - - context->clip(filterRect); - - if (lastEffect->resultImage()) - context->drawImage(lastEffect->resultImage()->image(), - lastEffect->subRegion()); + if (lastEffect && !m_filterBBox.isEmpty() && !lastEffect->subRegion().isEmpty()) { + m_filter->setSourceImage(m_sourceGraphicBuffer.release()); + lastEffect->apply(m_filter.get()); + + ImageBuffer* resultImage = lastEffect->resultImage(); + if (resultImage) { +#if !PLATFORM(CG) + resultImage->transformColorSpace(LinearRGB, DeviceRGB); +#endif + context->drawImage(resultImage->image(), lastEffect->subRegion()); + } } m_sourceGraphicBuffer.clear(); diff --git a/WebCore/svg/graphics/SVGResourceFilter.h b/WebCore/svg/graphics/SVGResourceFilter.h index d081b6b..ee1efca 100644 --- a/WebCore/svg/graphics/SVGResourceFilter.h +++ b/WebCore/svg/graphics/SVGResourceFilter.h @@ -29,11 +29,13 @@ #include "Image.h" #include "ImageBuffer.h" #include "FloatRect.h" +#include "RenderObject.h" #include "SVGFilterPrimitiveStandardAttributes.h" #include <wtf/OwnPtr.h> #include <wtf/PassOwnPtr.h> #include <wtf/PassRefPtr.h> +#include <wtf/RefPtr.h> namespace WebCore { @@ -74,8 +76,8 @@ public: virtual TextStream& externalRepresentation(TextStream&) const; - void prepareFilter(GraphicsContext*&, const FloatRect&); - void applyFilter(GraphicsContext*&, const FloatRect&); + void prepareFilter(GraphicsContext*&, const RenderObject*); + void applyFilter(GraphicsContext*&, const RenderObject*); void addFilterEffect(SVGFilterPrimitiveStandardAttributes*, PassRefPtr<FilterEffect>); @@ -97,6 +99,7 @@ private: OwnPtr<SVGFilterBuilder> m_filterBuilder; GraphicsContext* m_savedContext; OwnPtr<ImageBuffer> m_sourceGraphicBuffer; + RefPtr<Filter> m_filter; }; SVGResourceFilter* getFilterById(Document*, const AtomicString&); diff --git a/WebCore/svg/graphics/SVGResourceMasker.cpp b/WebCore/svg/graphics/SVGResourceMasker.cpp index 3c21350..d6c401b 100644 --- a/WebCore/svg/graphics/SVGResourceMasker.cpp +++ b/WebCore/svg/graphics/SVGResourceMasker.cpp @@ -72,7 +72,7 @@ void SVGResourceMasker::applyMask(GraphicsContext* context, const FloatRect& bou IntRect intImageRect(0, 0, imageSize.width(), imageSize.height()); // Create new ImageBuffer to apply luminance - OwnPtr<ImageBuffer> luminancedImage = ImageBuffer::create(imageSize, false); + OwnPtr<ImageBuffer> luminancedImage = ImageBuffer::create(imageSize); if (!luminancedImage) return; diff --git a/WebCore/svg/graphics/filters/SVGFEConvolveMatrix.h b/WebCore/svg/graphics/filters/SVGFEConvolveMatrix.h index 9b3b33f..f850412 100644 --- a/WebCore/svg/graphics/filters/SVGFEConvolveMatrix.h +++ b/WebCore/svg/graphics/filters/SVGFEConvolveMatrix.h @@ -68,6 +68,7 @@ namespace WebCore { bool preserveAlpha() const; void setPreserveAlpha(bool); + virtual FloatRect uniteChildEffectSubregions(Filter* filter) { return calculateUnionOfChildEffectSubregions(filter, m_in.get(), m_in2.get()); } void apply(Filter*); void dump(); TextStream& externalRepresentation(TextStream& ts) const; diff --git a/WebCore/svg/graphics/filters/SVGFEDiffuseLighting.h b/WebCore/svg/graphics/filters/SVGFEDiffuseLighting.h index f4b4dad..71f8e22 100644 --- a/WebCore/svg/graphics/filters/SVGFEDiffuseLighting.h +++ b/WebCore/svg/graphics/filters/SVGFEDiffuseLighting.h @@ -55,6 +55,7 @@ namespace WebCore { const LightSource* lightSource() const; void setLightSource(LightSource*); + virtual FloatRect uniteChildEffectSubregions(Filter* filter) { return calculateUnionOfChildEffectSubregions(filter, m_in.get()); } void apply(Filter*); void dump(); TextStream& externalRepresentation(TextStream& ts) const; diff --git a/WebCore/svg/graphics/filters/SVGFEDisplacementMap.h b/WebCore/svg/graphics/filters/SVGFEDisplacementMap.h index 1fd6db9..007f6ba 100644 --- a/WebCore/svg/graphics/filters/SVGFEDisplacementMap.h +++ b/WebCore/svg/graphics/filters/SVGFEDisplacementMap.h @@ -51,6 +51,7 @@ namespace WebCore { float scale() const; void setScale(float scale); + virtual FloatRect uniteChildEffectSubregions(Filter* filter) { return calculateUnionOfChildEffectSubregions(filter, m_in.get(), m_in2.get()); } void apply(Filter*); void dump(); TextStream& externalRepresentation(TextStream& ts) const; diff --git a/WebCore/svg/graphics/filters/SVGFEFlood.cpp b/WebCore/svg/graphics/filters/SVGFEFlood.cpp index 9bdb8ca..3f4a6d7 100644 --- a/WebCore/svg/graphics/filters/SVGFEFlood.cpp +++ b/WebCore/svg/graphics/filters/SVGFEFlood.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,7 +24,9 @@ #if ENABLE(SVG) && ENABLE(FILTERS) #include "SVGFEFlood.h" + #include "Filter.h" +#include "GraphicsContext.h" #include "SVGRenderTreeAsText.h" namespace WebCore { @@ -63,6 +66,12 @@ void FEFlood::setFloodOpacity(float floodOpacity) void FEFlood::apply(Filter*) { + GraphicsContext* filterContext = getEffectContext(); + if (!filterContext) + return; + + Color color = colorWithOverrideAlpha(floodColor().rgb(), floodOpacity()); + filterContext->fillRect(FloatRect(FloatPoint(), subRegion().size()), color); } void FEFlood::dump() diff --git a/WebCore/svg/graphics/filters/SVGFEGaussianBlur.h b/WebCore/svg/graphics/filters/SVGFEGaussianBlur.h index a377f89..69f1cc5 100644 --- a/WebCore/svg/graphics/filters/SVGFEGaussianBlur.h +++ b/WebCore/svg/graphics/filters/SVGFEGaussianBlur.h @@ -38,6 +38,7 @@ namespace WebCore { 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; diff --git a/WebCore/svg/graphics/filters/SVGFEImage.cpp b/WebCore/svg/graphics/filters/SVGFEImage.cpp index a01ad3b..e82328a 100644 --- a/WebCore/svg/graphics/filters/SVGFEImage.cpp +++ b/WebCore/svg/graphics/filters/SVGFEImage.cpp @@ -32,6 +32,7 @@ FEImage::FEImage(CachedImage* cachedImage) : FilterEffect() , m_cachedImage(cachedImage) { + m_cachedImage->addClient(this); } PassRefPtr<FEImage> FEImage::create(CachedImage* cachedImage) diff --git a/WebCore/svg/graphics/filters/SVGFEImage.h b/WebCore/svg/graphics/filters/SVGFEImage.h index 3fdc26a..f29d266 100644 --- a/WebCore/svg/graphics/filters/SVGFEImage.h +++ b/WebCore/svg/graphics/filters/SVGFEImage.h @@ -41,7 +41,7 @@ namespace WebCore { CachedImage* cachedImage() const; void setCachedImage(CachedImage*); - + void apply(Filter*); void dump(); TextStream& externalRepresentation(TextStream& ts) const; diff --git a/WebCore/svg/graphics/filters/SVGFEMerge.cpp b/WebCore/svg/graphics/filters/SVGFEMerge.cpp index 7f12c4c..acf3c45 100644 --- a/WebCore/svg/graphics/filters/SVGFEMerge.cpp +++ b/WebCore/svg/graphics/filters/SVGFEMerge.cpp @@ -23,8 +23,10 @@ #if ENABLE(SVG) && ENABLE(FILTERS) #include "SVGFEMerge.h" -#include "SVGRenderTreeAsText.h" + #include "Filter.h" +#include "GraphicsContext.h" +#include "SVGRenderTreeAsText.h" namespace WebCore { @@ -49,8 +51,36 @@ void FEMerge::setMergeInputs(const Vector<FilterEffect*>& mergeInputs) m_mergeInputs = mergeInputs; } -void FEMerge::apply(Filter*) +FloatRect FEMerge::uniteChildEffectSubregions(Filter* filter) +{ + ASSERT(!m_mergeInputs.isEmpty()); + + FloatRect uniteEffectRect = m_mergeInputs[0]->calculateEffectRect(filter); + + for (unsigned i = 1; i < m_mergeInputs.size(); i++) + uniteEffectRect.unite(m_mergeInputs[i]->calculateEffectRect(filter)); + + return uniteEffectRect; +} + +void FEMerge::apply(Filter* filter) { + ASSERT(!m_mergeInputs.isEmpty()); + + for (unsigned i = 0; i < m_mergeInputs.size(); i++) { + m_mergeInputs[i]->apply(filter); + if (!m_mergeInputs[i]->resultImage()) + return; + } + + GraphicsContext* filterContext = getEffectContext(); + if (!filterContext) + 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); + } } void FEMerge::dump() diff --git a/WebCore/svg/graphics/filters/SVGFEMerge.h b/WebCore/svg/graphics/filters/SVGFEMerge.h index e41e554..02fbfac 100644 --- a/WebCore/svg/graphics/filters/SVGFEMerge.h +++ b/WebCore/svg/graphics/filters/SVGFEMerge.h @@ -35,7 +35,8 @@ namespace WebCore { const Vector<FilterEffect*>& mergeInputs() const; void setMergeInputs(const Vector<FilterEffect*>& mergeInputs); - + + virtual FloatRect uniteChildEffectSubregions(Filter*); void apply(Filter*); void dump(); TextStream& externalRepresentation(TextStream& ts) const; diff --git a/WebCore/svg/graphics/filters/SVGFEMorphology.h b/WebCore/svg/graphics/filters/SVGFEMorphology.h index 1db8bc4..bdc2b9b 100644 --- a/WebCore/svg/graphics/filters/SVGFEMorphology.h +++ b/WebCore/svg/graphics/filters/SVGFEMorphology.h @@ -46,6 +46,7 @@ namespace WebCore { float radiusY() const; void setRadiusY(float); + virtual FloatRect uniteChildEffectSubregions(Filter* filter) { return calculateUnionOfChildEffectSubregions(filter, m_in.get()); } void apply(Filter*); void dump(); TextStream& externalRepresentation(TextStream& ts) const; diff --git a/WebCore/svg/graphics/filters/SVGFEOffset.cpp b/WebCore/svg/graphics/filters/SVGFEOffset.cpp index 63775fb..ce9ee3d 100644 --- a/WebCore/svg/graphics/filters/SVGFEOffset.cpp +++ b/WebCore/svg/graphics/filters/SVGFEOffset.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,10 @@ #if ENABLE(SVG) && ENABLE(FILTERS) #include "SVGFEOffset.h" -#include "SVGRenderTreeAsText.h" + #include "Filter.h" +#include "GraphicsContext.h" +#include "SVGRenderTreeAsText.h" namespace WebCore { @@ -61,8 +64,27 @@ void FEOffset::setDy(float dy) m_dy = dy; } -void FEOffset::apply(Filter*) +void FEOffset::apply(Filter* filter) { + m_in->apply(filter); + if (!m_in->resultImage()) + return; + + GraphicsContext* filterContext = getEffectContext(); + if (!filterContext) + return; + + if (filter->effectBoundingBoxMode()) { + setDx(dx() * filter->sourceImageRect().width()); + setDy(dy() * filter->sourceImageRect().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()); + + filterContext->drawImage(m_in->resultImage()->image(), dstRect); } void FEOffset::dump() diff --git a/WebCore/svg/graphics/filters/SVGFEOffset.h b/WebCore/svg/graphics/filters/SVGFEOffset.h index 93bdde9..8435db1 100644 --- a/WebCore/svg/graphics/filters/SVGFEOffset.h +++ b/WebCore/svg/graphics/filters/SVGFEOffset.h @@ -38,6 +38,7 @@ namespace WebCore { float dy() const; void setDy(float); + virtual FloatRect uniteChildEffectSubregions(Filter* filter) { return calculateUnionOfChildEffectSubregions(filter, m_in.get()); } void apply(Filter*); void dump(); TextStream& externalRepresentation(TextStream& ts) const; diff --git a/WebCore/svg/graphics/filters/SVGFESpecularLighting.h b/WebCore/svg/graphics/filters/SVGFESpecularLighting.h index 4efff93..dec5163 100644 --- a/WebCore/svg/graphics/filters/SVGFESpecularLighting.h +++ b/WebCore/svg/graphics/filters/SVGFESpecularLighting.h @@ -57,6 +57,7 @@ namespace WebCore { const LightSource* lightSource() const; void setLightSource(LightSource*); + virtual FloatRect uniteEffectRect(Filter* filter) { return calculateUnionOfChildEffectSubregions(filter, m_in.get()); } void apply(Filter*); void dump(); TextStream& externalRepresentation(TextStream& ts) const; diff --git a/WebCore/svg/graphics/filters/SVGFETile.cpp b/WebCore/svg/graphics/filters/SVGFETile.cpp index fecd105..3071501 100644 --- a/WebCore/svg/graphics/filters/SVGFETile.cpp +++ b/WebCore/svg/graphics/filters/SVGFETile.cpp @@ -1,5 +1,6 @@ /* Copyright (C) 2008 Alex Mathews <possessedpenguinbob@gmail.com> + 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 @@ -21,8 +22,12 @@ #if ENABLE(SVG) && ENABLE(FILTERS) #include "SVGFETile.h" -#include "SVGRenderTreeAsText.h" + #include "Filter.h" +#include "GraphicsContext.h" +#include "Pattern.h" +#include "TransformationMatrix.h" +#include "SVGRenderTreeAsText.h" namespace WebCore { @@ -37,8 +42,40 @@ PassRefPtr<FETile> FETile::create(FilterEffect* in) return adoptRef(new FETile(in)); } -void FETile::apply(Filter*) +FloatRect FETile::uniteChildEffectSubregions(Filter* filter) +{ + m_in->calculateEffectRect(filter); + return filter->filterRegion(); +} + +void FETile::apply(Filter* filter) { + m_in->apply(filter); + if (!m_in->resultImage()) + return; + + GraphicsContext* filterContext = getEffectContext(); + if (!filterContext) + return; + + IntRect tileRect = enclosingIntRect(m_in->subRegion()); + + // 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()); + + OwnPtr<ImageBuffer> tileImage = ImageBuffer::create(tileRect.size()); + GraphicsContext* tileImageContext = tileImage->context(); + tileImageContext->drawImage(m_in->resultImage()->image(), 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()); + pattern.get()->setPatternSpaceTransform(matrix); + + filterContext->setFillPattern(pattern); + filterContext->fillRect(FloatRect(FloatPoint(), subRegion().size())); } void FETile::dump() diff --git a/WebCore/svg/graphics/filters/SVGFETile.h b/WebCore/svg/graphics/filters/SVGFETile.h index f1e8d1a..c845085 100644 --- a/WebCore/svg/graphics/filters/SVGFETile.h +++ b/WebCore/svg/graphics/filters/SVGFETile.h @@ -32,6 +32,7 @@ namespace WebCore { public: static PassRefPtr<FETile> create(FilterEffect*); + virtual FloatRect uniteChildEffectSubregions(Filter*); void apply(Filter*); void dump(); TextStream& externalRepresentation(TextStream& ts) const; diff --git a/WebCore/svg/graphics/filters/SVGFilter.cpp b/WebCore/svg/graphics/filters/SVGFilter.cpp index 71c00eb..c892ee9 100644 --- a/WebCore/svg/graphics/filters/SVGFilter.cpp +++ b/WebCore/svg/graphics/filters/SVGFilter.cpp @@ -33,8 +33,45 @@ SVGFilter::SVGFilter(const FloatRect& itemBox, const FloatRect& filterRect, bool { } -void SVGFilter::calculateEffectSubRegion(FilterEffect*) +void SVGFilter::calculateEffectSubRegion(FilterEffect* effect) { + FloatRect subRegionBBox = effect->subRegion(); + FloatRect useBBox = effect->unionOfChildEffectSubregions(); + + FloatRect newSubRegion = subRegionBBox; + + if (m_effectBBoxMode) { + newSubRegion = useBBox; + + if (effect->hasX()) + newSubRegion.setX(m_itemBox.x() + subRegionBBox.x() * m_itemBox.width()); + + if (effect->hasY()) + newSubRegion.setY(m_itemBox.y() + subRegionBBox.y() * m_itemBox.height()); + + if (effect->hasWidth()) + newSubRegion.setWidth(subRegionBBox.width() * m_itemBox.width()); + + if (effect->hasHeight()) + newSubRegion.setHeight(subRegionBBox.height() * m_itemBox.height()); + } else { + if (effect->xBoundingBoxMode()) + newSubRegion.setX(useBBox.x() + subRegionBBox.x() * useBBox.width()); + + if (effect->yBoundingBoxMode()) + newSubRegion.setY(useBBox.y() + subRegionBBox.y() * useBBox.height()); + + if (effect->widthBoundingBoxMode()) + newSubRegion.setWidth(subRegionBBox.width() * useBBox.width()); + + if (effect->heightBoundingBoxMode()) + newSubRegion.setHeight(subRegionBBox.height() * useBBox.height()); + } + + // clip every filter effect to the filter region + newSubRegion.intersect(m_filterRect); + + effect->setSubRegion(newSubRegion); } PassRefPtr<SVGFilter> SVGFilter::create(const FloatRect& itemBox, const FloatRect& filterRect, bool effectBBoxMode, bool filterBBoxMode) diff --git a/WebCore/svg/graphics/filters/SVGFilter.h b/WebCore/svg/graphics/filters/SVGFilter.h index 95b3414..d6e5f77 100644 --- a/WebCore/svg/graphics/filters/SVGFilter.h +++ b/WebCore/svg/graphics/filters/SVGFilter.h @@ -35,6 +35,10 @@ namespace WebCore { public: static PassRefPtr<SVGFilter> create(const FloatRect&, const FloatRect&, bool, bool); + bool effectBoundingBoxMode() { return m_effectBBoxMode; } + + FloatRect filterRegion() { return m_filterRect; } + FloatRect sourceImageRect() { return m_itemBox; } void calculateEffectSubRegion(FilterEffect*); private: |
