diff options
Diffstat (limited to 'Source/WebCore/svg')
-rw-r--r-- | Source/WebCore/svg/SVGFEDiffuseLightingElement.cpp | 11 | ||||
-rw-r--r-- | Source/WebCore/svg/SVGFEFloodElement.cpp | 19 | ||||
-rw-r--r-- | Source/WebCore/svg/SVGFEFloodElement.h | 1 | ||||
-rw-r--r-- | Source/WebCore/svg/SVGFESpecularLightingElement.cpp | 7 | ||||
-rw-r--r-- | Source/WebCore/svg/SVGFilterPrimitiveStandardAttributes.cpp | 8 | ||||
-rw-r--r-- | Source/WebCore/svg/SVGFilterPrimitiveStandardAttributes.h | 1 | ||||
-rw-r--r-- | Source/WebCore/svg/SVGFontFaceUriElement.cpp | 1 | ||||
-rw-r--r-- | Source/WebCore/svg/SVGImageLoader.cpp | 3 | ||||
-rw-r--r-- | Source/WebCore/svg/SVGStyledElement.cpp | 4 | ||||
-rw-r--r-- | Source/WebCore/svg/SVGTextContentElement.cpp | 48 | ||||
-rw-r--r-- | Source/WebCore/svg/SVGTextContentElement.h | 11 | ||||
-rw-r--r-- | Source/WebCore/svg/SVGTextPathElement.cpp | 1 | ||||
-rw-r--r-- | Source/WebCore/svg/SVGTextPositioningElement.cpp | 3 | ||||
-rw-r--r-- | Source/WebCore/svg/SVGTitleElement.cpp | 6 | ||||
-rw-r--r-- | Source/WebCore/svg/SVGUseElement.cpp | 1 | ||||
-rw-r--r-- | Source/WebCore/svg/properties/SVGAnimatedPropertyDescription.h | 14 |
16 files changed, 97 insertions, 42 deletions
diff --git a/Source/WebCore/svg/SVGFEDiffuseLightingElement.cpp b/Source/WebCore/svg/SVGFEDiffuseLightingElement.cpp index a4c2a6b..f58be8f 100644 --- a/Source/WebCore/svg/SVGFEDiffuseLightingElement.cpp +++ b/Source/WebCore/svg/SVGFEDiffuseLightingElement.cpp @@ -87,14 +87,17 @@ void SVGFEDiffuseLightingElement::parseMappedAttribute(Attribute* attr) bool SVGFEDiffuseLightingElement::setFilterEffectAttribute(FilterEffect* effect, const QualifiedName& attrName) { FEDiffuseLighting* diffuseLighting = static_cast<FEDiffuseLighting*>(effect); + + if (attrName == SVGNames::lighting_colorAttr) { + RenderObject* renderer = this->renderer(); + ASSERT(renderer); + ASSERT(renderer->style()); + return diffuseLighting->setLightingColor(renderer->style()->svgStyle()->lightingColor()); + } if (attrName == SVGNames::surfaceScaleAttr) return diffuseLighting->setSurfaceScale(surfaceScale()); if (attrName == SVGNames::diffuseConstantAttr) return diffuseLighting->setDiffuseConstant(diffuseConstant()); - if (attrName == SVGNames::lighting_colorAttr) { - RefPtr<RenderStyle> filterStyle = styleForRenderer(); - return diffuseLighting->setLightingColor(filterStyle->svgStyle()->lightingColor()); - } LightSource* lightSource = const_cast<LightSource*>(diffuseLighting->lightSource()); const SVGFELightElement* lightElement = SVGFELightElement::findLightElement(this); diff --git a/Source/WebCore/svg/SVGFEFloodElement.cpp b/Source/WebCore/svg/SVGFEFloodElement.cpp index eb20927..bb676a9 100644 --- a/Source/WebCore/svg/SVGFEFloodElement.cpp +++ b/Source/WebCore/svg/SVGFEFloodElement.cpp @@ -25,6 +25,7 @@ #include "Attribute.h" #include "RenderStyle.h" +#include "SVGNames.h" #include "SVGRenderStyle.h" namespace WebCore { @@ -39,6 +40,24 @@ PassRefPtr<SVGFEFloodElement> SVGFEFloodElement::create(const QualifiedName& tag return adoptRef(new SVGFEFloodElement(tagName, document)); } + +bool SVGFEFloodElement::setFilterEffectAttribute(FilterEffect* effect, const QualifiedName& attrName) +{ + RenderObject* renderer = this->renderer(); + ASSERT(renderer); + RenderStyle* style = renderer->style(); + ASSERT(style); + FEFlood* flood = static_cast<FEFlood*>(effect); + + if (attrName == SVGNames::flood_colorAttr) + return flood->setFloodColor(style->svgStyle()->floodColor()); + if (attrName == SVGNames::flood_opacityAttr) + return flood->setFloodOpacity(style->svgStyle()->floodOpacity()); + + ASSERT_NOT_REACHED(); + return false; +} + PassRefPtr<FilterEffect> SVGFEFloodElement::build(SVGFilterBuilder*, Filter* filter) { RefPtr<RenderStyle> filterStyle = styleForRenderer(); diff --git a/Source/WebCore/svg/SVGFEFloodElement.h b/Source/WebCore/svg/SVGFEFloodElement.h index f7c7987..e98e7b3 100644 --- a/Source/WebCore/svg/SVGFEFloodElement.h +++ b/Source/WebCore/svg/SVGFEFloodElement.h @@ -36,6 +36,7 @@ private: virtual void fillAttributeToPropertyTypeMap(); virtual AttributeToPropertyTypeMap& attributeToPropertyTypeMap(); + virtual bool setFilterEffectAttribute(FilterEffect*, const QualifiedName& attrName); virtual PassRefPtr<FilterEffect> build(SVGFilterBuilder*, Filter*); }; diff --git a/Source/WebCore/svg/SVGFESpecularLightingElement.cpp b/Source/WebCore/svg/SVGFESpecularLightingElement.cpp index 60684ed..bdc75b1 100644 --- a/Source/WebCore/svg/SVGFESpecularLightingElement.cpp +++ b/Source/WebCore/svg/SVGFESpecularLightingElement.cpp @@ -92,6 +92,13 @@ void SVGFESpecularLightingElement::parseMappedAttribute(Attribute* attr) bool SVGFESpecularLightingElement::setFilterEffectAttribute(FilterEffect* effect, const QualifiedName& attrName) { FESpecularLighting* specularLighting = static_cast<FESpecularLighting*>(effect); + + if (attrName == SVGNames::lighting_colorAttr) { + RenderObject* renderer = this->renderer(); + ASSERT(renderer); + ASSERT(renderer->style()); + return specularLighting->setLightingColor(renderer->style()->svgStyle()->lightingColor()); + } if (attrName == SVGNames::surfaceScaleAttr) return specularLighting->setSurfaceScale(surfaceScale()); if (attrName == SVGNames::specularConstantAttr) diff --git a/Source/WebCore/svg/SVGFilterPrimitiveStandardAttributes.cpp b/Source/WebCore/svg/SVGFilterPrimitiveStandardAttributes.cpp index d34a130..fe5d09c 100644 --- a/Source/WebCore/svg/SVGFilterPrimitiveStandardAttributes.cpp +++ b/Source/WebCore/svg/SVGFilterPrimitiveStandardAttributes.cpp @@ -168,6 +168,14 @@ RenderObject* SVGFilterPrimitiveStandardAttributes::createRenderer(RenderArena* return new (arena) RenderSVGResourceFilterPrimitive(this); } +bool SVGFilterPrimitiveStandardAttributes::rendererIsNeeded(RenderStyle* style) +{ + if (parentNode() && (parentNode()->hasTagName(SVGNames::filterTag))) + return SVGStyledElement::rendererIsNeeded(style); + + return false; +} + } #endif // ENABLE(SVG) diff --git a/Source/WebCore/svg/SVGFilterPrimitiveStandardAttributes.h b/Source/WebCore/svg/SVGFilterPrimitiveStandardAttributes.h index 526592a..795bc11 100644 --- a/Source/WebCore/svg/SVGFilterPrimitiveStandardAttributes.h +++ b/Source/WebCore/svg/SVGFilterPrimitiveStandardAttributes.h @@ -70,6 +70,7 @@ private: virtual bool isFilterEffect() const { return true; } virtual RenderObject* createRenderer(RenderArena*, RenderStyle*); + virtual bool rendererIsNeeded(RenderStyle*); // Animated property declarations DECLARE_ANIMATED_LENGTH(X, x) diff --git a/Source/WebCore/svg/SVGFontFaceUriElement.cpp b/Source/WebCore/svg/SVGFontFaceUriElement.cpp index 58a22c7..b017143 100644 --- a/Source/WebCore/svg/SVGFontFaceUriElement.cpp +++ b/Source/WebCore/svg/SVGFontFaceUriElement.cpp @@ -97,7 +97,6 @@ void SVGFontFaceUriElement::loadFont() CachedResourceLoader* cachedResourceLoader = document()->cachedResourceLoader(); m_cachedFont = cachedResourceLoader->requestFont(href); if (m_cachedFont) { - m_cachedFont->setSVGFont(true); m_cachedFont->addClient(this); m_cachedFont->beginLoadIfNeeded(cachedResourceLoader); } diff --git a/Source/WebCore/svg/SVGImageLoader.cpp b/Source/WebCore/svg/SVGImageLoader.cpp index 7c60191..944da1a 100644 --- a/Source/WebCore/svg/SVGImageLoader.cpp +++ b/Source/WebCore/svg/SVGImageLoader.cpp @@ -49,6 +49,9 @@ void SVGImageLoader::dispatchLoadEvent() String SVGImageLoader::sourceURI(const AtomicString& attr) const { + KURL base = element()->baseURI(); + if (base.isValid()) + return KURL(base, stripLeadingAndTrailingHTMLSpaces(attr)).string(); return element()->document()->completeURL(stripLeadingAndTrailingHTMLSpaces(attr)); } diff --git a/Source/WebCore/svg/SVGStyledElement.cpp b/Source/WebCore/svg/SVGStyledElement.cpp index 5740b05..79e1633 100644 --- a/Source/WebCore/svg/SVGStyledElement.cpp +++ b/Source/WebCore/svg/SVGStyledElement.cpp @@ -81,13 +81,13 @@ String SVGStyledElement::title() const // Walk up the tree, to find out whether we're inside a <use> shadow tree, to find the right title. Node* parent = const_cast<SVGStyledElement*>(this); while (parent) { - if (!parent->isShadowRoot()) { + if (!parent->isSVGShadowRoot()) { parent = parent->parentNodeGuaranteedHostFree(); continue; } // Get the <use> element. - Element* shadowParent = parent->shadowHost(); + Element* shadowParent = parent->svgShadowHost(); if (shadowParent && shadowParent->isSVGElement() && shadowParent->hasTagName(SVGNames::useTag)) { SVGUseElement* useElement = static_cast<SVGUseElement*>(shadowParent); // If the <use> title is not empty we found the title to use. diff --git a/Source/WebCore/svg/SVGTextContentElement.cpp b/Source/WebCore/svg/SVGTextContentElement.cpp index a719c28..4021b4f 100644 --- a/Source/WebCore/svg/SVGTextContentElement.cpp +++ b/Source/WebCore/svg/SVGTextContentElement.cpp @@ -27,6 +27,7 @@ #include "CSSValueKeywords.h" #include "Frame.h" #include "RenderObject.h" +#include "RenderSVGResource.h" #include "SVGDocumentExtensions.h" #include "SVGNames.h" #include "SVGTextQuery.h" @@ -36,17 +37,38 @@ namespace WebCore { // Animated property definitions -DEFINE_ANIMATED_LENGTH(SVGTextContentElement, SVGNames::textLengthAttr, TextLength, textLength) DEFINE_ANIMATED_ENUMERATION(SVGTextContentElement, SVGNames::lengthAdjustAttr, LengthAdjust, lengthAdjust) DEFINE_ANIMATED_BOOLEAN(SVGTextContentElement, SVGNames::externalResourcesRequiredAttr, ExternalResourcesRequired, externalResourcesRequired) SVGTextContentElement::SVGTextContentElement(const QualifiedName& tagName, Document* document) : SVGStyledElement(tagName, document) + , m_specifiedTextLength(LengthModeOther) , m_textLength(LengthModeOther) , m_lengthAdjust(LENGTHADJUST_SPACING) { } +void SVGTextContentElement::synchronizeTextLength() +{ + if (!m_textLength.shouldSynchronize) + return; + AtomicString value(SVGPropertyTraits<SVGLength>::toString(m_specifiedTextLength)); + SVGAnimatedPropertySynchronizer<true>::synchronize(this, SVGNames::textLengthAttr, value); +} + +PassRefPtr<SVGAnimatedLength> SVGTextContentElement::textLengthAnimated() +{ + DEFINE_STATIC_LOCAL(SVGLength, defaultTextLength, (LengthModeOther)); + if (m_specifiedTextLength == defaultTextLength) { + ExceptionCode ec = 0; + m_textLength.value.newValueSpecifiedUnits(LengthTypeNumber, getComputedTextLength(), ec); + ASSERT(!ec); + } + + m_textLength.shouldSynchronize = true; + return SVGAnimatedProperty::lookupOrCreateWrapper<SVGAnimatedLength, SVGLength>(this, SVGNames::textLengthAttr, SVGNames::textLengthAttr.localName(), m_textLength.value); +} + unsigned SVGTextContentElement::getNumberOfChars() const { document()->updateLayoutIgnorePendingStylesheets(); @@ -165,8 +187,8 @@ void SVGTextContentElement::parseMappedAttribute(Attribute* attr) else if (attr->value() == "spacingAndGlyphs") setLengthAdjustBaseValue(LENGTHADJUST_SPACINGANDGLYPHS); } else if (attr->name() == SVGNames::textLengthAttr) { - setTextLengthBaseValue(SVGLength(LengthModeOther, attr->value())); - if (textLengthBaseValue().value(this) < 0.0) + m_textLength.value = SVGLength(LengthModeOther, attr->value()); + if (m_textLength.value.value(this) < 0) document()->accessSVGExtensions()->reportError("A negative value for text attribute <textLength> is not allowed"); } else { if (SVGTests::parseMappedAttribute(attr)) @@ -218,7 +240,16 @@ void SVGTextContentElement::svgAttributeChanged(const QualifiedName& attrName) if (SVGTests::handleAttributeChange(this, attrName)) return; - // FIXME: also handle attribute changes for lengthAdjust and textLength + if (attrName == SVGNames::textLengthAttr) + m_specifiedTextLength = m_textLength.value; + + RenderObject* renderer = this->renderer(); + if (!renderer) + return; + + if (attrName == SVGNames::textLengthAttr + || attrName == SVGNames::lengthAdjustAttr) + RenderSVGResource::markForLayoutAndParentResourceInvalidation(renderer); } void SVGTextContentElement::fillPassedAttributeToPropertyTypeMap(AttributeToPropertyTypeMap& attributeToPropertyTypeMap) @@ -229,15 +260,6 @@ void SVGTextContentElement::fillPassedAttributeToPropertyTypeMap(AttributeToProp attributeToPropertyTypeMap.set(SVGNames::lengthAdjustAttr, AnimatedEnumeration); } -bool SVGTextContentElement::isKnownAttribute(const QualifiedName& attrName) -{ - return attrName.matches(SVGNames::lengthAdjustAttr) - || attrName.matches(SVGNames::textLengthAttr) - || SVGLangSpace::isKnownAttribute(attrName) - || SVGExternalResourcesRequired::isKnownAttribute(attrName) - || SVGStyledElement::isKnownAttribute(attrName); -} - bool SVGTextContentElement::selfHasRelativeLengths() const { // Any element of the <text> subtree is advertized as using relative lengths. diff --git a/Source/WebCore/svg/SVGTextContentElement.h b/Source/WebCore/svg/SVGTextContentElement.h index 7abffd8..94bba70 100644 --- a/Source/WebCore/svg/SVGTextContentElement.h +++ b/Source/WebCore/svg/SVGTextContentElement.h @@ -53,10 +53,13 @@ public: int getCharNumAtPosition(const FloatPoint&) const; void selectSubString(unsigned charnum, unsigned nchars, ExceptionCode&) const; - bool isKnownAttribute(const QualifiedName&); - static SVGTextContentElement* elementFromRenderer(RenderObject*); + // textLength is not declared using the standard DECLARE_ANIMATED_LENGTH macro + // as its getter needs special handling (return getComputedTextLength(), instead of m_textLength). + SVGLength& specifiedTextLength() { return m_specifiedTextLength; } + PassRefPtr<SVGAnimatedLength> textLengthAnimated(); + protected: SVGTextContentElement(const QualifiedName&, Document*); @@ -73,7 +76,9 @@ private: virtual bool isTextContent() const { return true; } // Animated property declarations - DECLARE_ANIMATED_LENGTH(TextLength, textLength) + void synchronizeTextLength(); + SVGLength m_specifiedTextLength; + mutable SVGSynchronizableAnimatedProperty<SVGLength> m_textLength; DECLARE_ANIMATED_ENUMERATION(LengthAdjust, lengthAdjust) // SVGExternalResourcesRequired diff --git a/Source/WebCore/svg/SVGTextPathElement.cpp b/Source/WebCore/svg/SVGTextPathElement.cpp index 1bfc12c..3f232e5 100644 --- a/Source/WebCore/svg/SVGTextPathElement.cpp +++ b/Source/WebCore/svg/SVGTextPathElement.cpp @@ -83,7 +83,6 @@ void SVGTextPathElement::svgAttributeChanged(const QualifiedName& attrName) return; if (attrName == SVGNames::startOffsetAttr - || SVGTextContentElement::isKnownAttribute(attrName) || SVGURIReference::isKnownAttribute(attrName)) RenderSVGResource::markForLayoutAndParentResourceInvalidation(renderer()); } diff --git a/Source/WebCore/svg/SVGTextPositioningElement.cpp b/Source/WebCore/svg/SVGTextPositioningElement.cpp index a96f0cb..cd714c3 100644 --- a/Source/WebCore/svg/SVGTextPositioningElement.cpp +++ b/Source/WebCore/svg/SVGTextPositioningElement.cpp @@ -120,9 +120,6 @@ void SVGTextPositioningElement::svgAttributeChanged(const QualifiedName& attrNam RenderSVGResource::markForLayoutAndParentResourceInvalidation(renderer); return; } - - if (SVGTextContentElement::isKnownAttribute(attrName)) - RenderSVGResource::markForLayoutAndParentResourceInvalidation(renderer); } void SVGTextPositioningElement::childrenChanged(bool changedByParser, Node* beforeChange, Node* afterChange, int childCountDelta) diff --git a/Source/WebCore/svg/SVGTitleElement.cpp b/Source/WebCore/svg/SVGTitleElement.cpp index ebcddb4..d925603 100644 --- a/Source/WebCore/svg/SVGTitleElement.cpp +++ b/Source/WebCore/svg/SVGTitleElement.cpp @@ -40,7 +40,8 @@ void SVGTitleElement::insertedIntoDocument() { SVGStyledElement::insertedIntoDocument(); if (firstChild()) - document()->setTitleElement(textContent(), this); + // FIXME: does SVG have a title text direction? + document()->setTitleElement(StringWithDirection(textContent(), LTR), this); } void SVGTitleElement::removedFromDocument() @@ -53,7 +54,8 @@ void SVGTitleElement::childrenChanged(bool changedByParser, Node* beforeChange, { SVGElement::childrenChanged(changedByParser, beforeChange, afterChange, childCountDelta); if (inDocument()) - document()->setTitleElement(textContent(), this); + // FIXME: does SVG have title text direction? + document()->setTitleElement(StringWithDirection(textContent(), LTR), this); } AttributeToPropertyTypeMap& SVGTitleElement::attributeToPropertyTypeMap() diff --git a/Source/WebCore/svg/SVGUseElement.cpp b/Source/WebCore/svg/SVGUseElement.cpp index 21f0954..981bc9c 100644 --- a/Source/WebCore/svg/SVGUseElement.cpp +++ b/Source/WebCore/svg/SVGUseElement.cpp @@ -475,6 +475,7 @@ void SVGUseElement::buildPendingResource() if (m_isPendingResource) { ASSERT(!m_targetElementInstance); m_isPendingResource = false; + m_resourceId = String(); invalidateShadowTree(); } } diff --git a/Source/WebCore/svg/properties/SVGAnimatedPropertyDescription.h b/Source/WebCore/svg/properties/SVGAnimatedPropertyDescription.h index 5fbaf9e..610fb14 100644 --- a/Source/WebCore/svg/properties/SVGAnimatedPropertyDescription.h +++ b/Source/WebCore/svg/properties/SVGAnimatedPropertyDescription.h @@ -80,19 +80,7 @@ struct SVGAnimatedPropertyDescriptionHash { static const bool safeToCompareToEmptyOrDeleted = true; }; -struct SVGAnimatedPropertyDescriptionHashTraits : WTF::GenericHashTraits<SVGAnimatedPropertyDescription> { - static const bool emptyValueIsZero = true; - - static void constructDeletedValue(SVGAnimatedPropertyDescription& slot) - { - new (&slot) SVGAnimatedPropertyDescription(WTF::HashTableDeletedValue); - } - - static bool isDeletedValue(const SVGAnimatedPropertyDescription& value) - { - return value.isHashTableDeletedValue(); - } -}; +struct SVGAnimatedPropertyDescriptionHashTraits : WTF::SimpleClassHashTraits<SVGAnimatedPropertyDescription> { }; } |