diff options
Diffstat (limited to 'Source/WebCore/svg')
-rw-r--r-- | Source/WebCore/svg/SVGAElement.cpp | 2 | ||||
-rw-r--r-- | Source/WebCore/svg/SVGComponentTransferFunctionElement.cpp | 11 | ||||
-rw-r--r-- | Source/WebCore/svg/SVGComponentTransferFunctionElement.h | 1 | ||||
-rw-r--r-- | Source/WebCore/svg/SVGElement.cpp | 9 | ||||
-rw-r--r-- | Source/WebCore/svg/SVGElementInstance.cpp | 18 | ||||
-rw-r--r-- | Source/WebCore/svg/SVGElementInstance.h | 19 | ||||
-rw-r--r-- | Source/WebCore/svg/SVGFEDisplacementMapElement.cpp | 18 | ||||
-rw-r--r-- | Source/WebCore/svg/SVGTitleElement.cpp | 4 | ||||
-rw-r--r-- | Source/WebCore/svg/SVGUseElement.cpp | 79 | ||||
-rw-r--r-- | Source/WebCore/svg/SVGUseElement.h | 4 | ||||
-rw-r--r-- | Source/WebCore/svg/properties/SVGAnimatedPropertyDescription.h | 2 |
11 files changed, 101 insertions, 66 deletions
diff --git a/Source/WebCore/svg/SVGAElement.cpp b/Source/WebCore/svg/SVGAElement.cpp index 601b432..4d02c69 100644 --- a/Source/WebCore/svg/SVGAElement.cpp +++ b/Source/WebCore/svg/SVGAElement.cpp @@ -195,7 +195,7 @@ void SVGAElement::defaultEventHandler(Event* event) bool SVGAElement::supportsFocus() const { - if (isContentEditable()) + if (rendererIsEditable()) return SVGStyledTransformableElement::supportsFocus(); return true; } diff --git a/Source/WebCore/svg/SVGComponentTransferFunctionElement.cpp b/Source/WebCore/svg/SVGComponentTransferFunctionElement.cpp index c35a344..6ed5813 100644 --- a/Source/WebCore/svg/SVGComponentTransferFunctionElement.cpp +++ b/Source/WebCore/svg/SVGComponentTransferFunctionElement.cpp @@ -81,6 +81,17 @@ void SVGComponentTransferFunctionElement::parseMappedAttribute(Attribute* attr) SVGElement::parseMappedAttribute(attr); } +void SVGComponentTransferFunctionElement::svgAttributeChanged(const QualifiedName& attrName) +{ + SVGElement::svgAttributeChanged(attrName); + + if (attrName == SVGNames::typeAttr) { + ComponentTransferType componentType = static_cast<ComponentTransferType>(type()); + if (componentType < FECOMPONENTTRANSFER_TYPE_UNKNOWN || componentType > FECOMPONENTTRANSFER_TYPE_GAMMA) + setTypeBaseValue(FECOMPONENTTRANSFER_TYPE_UNKNOWN); + } +} + void SVGComponentTransferFunctionElement::synchronizeProperty(const QualifiedName& attrName) { SVGElement::synchronizeProperty(attrName); diff --git a/Source/WebCore/svg/SVGComponentTransferFunctionElement.h b/Source/WebCore/svg/SVGComponentTransferFunctionElement.h index 2be693b..931e52e 100644 --- a/Source/WebCore/svg/SVGComponentTransferFunctionElement.h +++ b/Source/WebCore/svg/SVGComponentTransferFunctionElement.h @@ -37,6 +37,7 @@ protected: SVGComponentTransferFunctionElement(const QualifiedName&, Document*); virtual void parseMappedAttribute(Attribute*); + virtual void svgAttributeChanged(const QualifiedName&); virtual void synchronizeProperty(const QualifiedName&); virtual void fillAttributeToPropertyTypeMap(); virtual AttributeToPropertyTypeMap& attributeToPropertyTypeMap(); diff --git a/Source/WebCore/svg/SVGElement.cpp b/Source/WebCore/svg/SVGElement.cpp index 4630ccb..044f439 100644 --- a/Source/WebCore/svg/SVGElement.cpp +++ b/Source/WebCore/svg/SVGElement.cpp @@ -316,12 +316,9 @@ void SVGElement::sendSVGLoadEventIfPossible(bool sendParentLoadEvents) RefPtr<Node> parent; if (sendParentLoadEvents) parent = currentTarget->parentNode(); // save the next parent to dispatch too incase dispatching the event changes the tree - if (hasLoadListener(currentTarget.get())) { - RefPtr<Event> event = Event::create(eventNames().loadEvent, false, false); - event->setTarget(currentTarget); - currentTarget->dispatchGenericEvent(event.release()); - } - currentTarget = (parent && parent->isSVGElement()) ? static_pointer_cast<SVGElement>(parent) : 0; + if (hasLoadListener(currentTarget.get())) + currentTarget->dispatchEvent(Event::create(eventNames().loadEvent, false, false)); + currentTarget = (parent && parent->isSVGElement()) ? static_pointer_cast<SVGElement>(parent) : RefPtr<SVGElement>(); } } diff --git a/Source/WebCore/svg/SVGElementInstance.cpp b/Source/WebCore/svg/SVGElementInstance.cpp index a873f0b..6b9c085 100644 --- a/Source/WebCore/svg/SVGElementInstance.cpp +++ b/Source/WebCore/svg/SVGElementInstance.cpp @@ -1,6 +1,7 @@ /* * Copyright (C) 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org> * Copyright (C) Research In Motion Limited 2010. All rights reserved. + * Copyright (C) 2011 Torch Mobile (Beijing) Co. Ltd. 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 @@ -40,15 +41,16 @@ namespace WebCore { static WTF::RefCountedLeakCounter instanceCounter("WebCoreSVGElementInstance"); #endif -SVGElementInstance::SVGElementInstance(SVGUseElement* useElement, PassRefPtr<SVGElement> originalElement) - : m_useElement(useElement) +SVGElementInstance::SVGElementInstance(SVGUseElement* correspondingUseElement, SVGUseElement* directUseElement, PassRefPtr<SVGElement> originalElement) + : m_correspondingUseElement(correspondingUseElement) + , m_directUseElement(directUseElement) , m_element(originalElement) , m_previousSibling(0) , m_nextSibling(0) , m_firstChild(0) , m_lastChild(0) { - ASSERT(m_useElement); + ASSERT(m_correspondingUseElement); ASSERT(m_element); // Register as instance for passed element. @@ -131,19 +133,13 @@ void SVGElementInstance::removeAllEventListeners() m_element->removeAllEventListeners(); } -bool SVGElementInstance::dispatchEvent(PassRefPtr<Event> prpEvent) +bool SVGElementInstance::dispatchEvent(PassRefPtr<Event> event) { - RefPtr<EventTarget> protect = this; - RefPtr<Event> event = prpEvent; - - event->setTarget(this); - SVGElement* element = shadowTreeElement(); if (!element) return false; - RefPtr<FrameView> view = element->document()->view(); - return element->dispatchGenericEvent(event.release()); + return element->dispatchEvent(event); } EventTargetData* SVGElementInstance::eventTargetData() diff --git a/Source/WebCore/svg/SVGElementInstance.h b/Source/WebCore/svg/SVGElementInstance.h index 6dbcff4..2a8c52f 100644 --- a/Source/WebCore/svg/SVGElementInstance.h +++ b/Source/WebCore/svg/SVGElementInstance.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org> + * Copyright (C) 2011 Torch Mobile (Beijing) Co. Ltd. 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 @@ -39,9 +40,9 @@ class SVGElementInstanceList; class SVGElementInstance : public TreeShared<SVGElementInstance>, public EventTarget { public: - static PassRefPtr<SVGElementInstance> create(SVGUseElement* useElement, PassRefPtr<SVGElement> originalElement) + static PassRefPtr<SVGElementInstance> create(SVGUseElement* correspondingUseElement, SVGUseElement* directUseElement, PassRefPtr<SVGElement> originalElement) { - return adoptRef(new SVGElementInstance(useElement, originalElement)); + return adoptRef(new SVGElementInstance(correspondingUseElement, directUseElement, originalElement)); } virtual ~SVGElementInstance(); @@ -55,9 +56,14 @@ public: virtual bool dispatchEvent(PassRefPtr<Event>); SVGElement* correspondingElement() const { return m_element.get(); } - SVGUseElement* correspondingUseElement() const { return m_useElement; } + SVGUseElement* correspondingUseElement() const { return m_correspondingUseElement; } + SVGUseElement* directUseElement() const { return m_directUseElement; } SVGElement* shadowTreeElement() const { return m_shadowTreeElement.get(); } - void clearUseElement() { m_useElement = 0; } + void clearUseElements() + { + m_directUseElement = 0; + m_correspondingUseElement = 0; + } SVGElementInstance* parentNode() const { return parent(); } PassRefPtr<SVGElementInstanceList> childNodes(); @@ -120,7 +126,7 @@ public: private: friend class SVGUseElement; - SVGElementInstance(SVGUseElement*, PassRefPtr<SVGElement> originalElement); + SVGElementInstance(SVGUseElement*, SVGUseElement*, PassRefPtr<SVGElement> originalElement); virtual Node* toNode() { return shadowTreeElement(); } virtual SVGElementInstance* toSVGElementInstance() { return this; } @@ -150,7 +156,8 @@ private: virtual EventTargetData* eventTargetData(); virtual EventTargetData* ensureEventTargetData(); - SVGUseElement* m_useElement; + SVGUseElement* m_correspondingUseElement; + SVGUseElement* m_directUseElement; RefPtr<SVGElement> m_element; RefPtr<SVGElement> m_shadowTreeElement; diff --git a/Source/WebCore/svg/SVGFEDisplacementMapElement.cpp b/Source/WebCore/svg/SVGFEDisplacementMapElement.cpp index 873f85a..1429b34 100644 --- a/Source/WebCore/svg/SVGFEDisplacementMapElement.cpp +++ b/Source/WebCore/svg/SVGFEDisplacementMapElement.cpp @@ -97,13 +97,19 @@ void SVGFEDisplacementMapElement::svgAttributeChanged(const QualifiedName& attrN { SVGFilterPrimitiveStandardAttributes::svgAttributeChanged(attrName); - if (attrName == SVGNames::xChannelSelectorAttr - || attrName == SVGNames::yChannelSelectorAttr - || attrName == SVGNames::scaleAttr) + if (attrName == SVGNames::xChannelSelectorAttr) { + ChannelSelectorType selector = static_cast<ChannelSelectorType>(xChannelSelector()); + if (CHANNEL_UNKNOWN > selector || selector > CHANNEL_A) + setXChannelSelectorBaseValue(CHANNEL_UNKNOWN); primitiveAttributeChanged(attrName); - - if (attrName == SVGNames::inAttr - || attrName == SVGNames::in2Attr) + } else if (attrName == SVGNames::yChannelSelectorAttr) { + ChannelSelectorType selector = static_cast<ChannelSelectorType>(yChannelSelector()); + if (CHANNEL_UNKNOWN > selector || selector > CHANNEL_A) + setYChannelSelectorBaseValue(CHANNEL_UNKNOWN); + primitiveAttributeChanged(attrName); + } else if (attrName == SVGNames::scaleAttr) + primitiveAttributeChanged(attrName); + else if (attrName == SVGNames::inAttr || attrName == SVGNames::in2Attr) invalidate(); } diff --git a/Source/WebCore/svg/SVGTitleElement.cpp b/Source/WebCore/svg/SVGTitleElement.cpp index 6281f10..ebcddb4 100644 --- a/Source/WebCore/svg/SVGTitleElement.cpp +++ b/Source/WebCore/svg/SVGTitleElement.cpp @@ -40,7 +40,7 @@ void SVGTitleElement::insertedIntoDocument() { SVGStyledElement::insertedIntoDocument(); if (firstChild()) - document()->setTitle(textContent(), this); + document()->setTitleElement(textContent(), this); } void SVGTitleElement::removedFromDocument() @@ -53,7 +53,7 @@ void SVGTitleElement::childrenChanged(bool changedByParser, Node* beforeChange, { SVGElement::childrenChanged(changedByParser, beforeChange, afterChange, childCountDelta); if (inDocument()) - document()->setTitle(textContent(), this); + document()->setTitleElement(textContent(), this); } AttributeToPropertyTypeMap& SVGTitleElement::attributeToPropertyTypeMap() diff --git a/Source/WebCore/svg/SVGUseElement.cpp b/Source/WebCore/svg/SVGUseElement.cpp index 4239f66..21f0954 100644 --- a/Source/WebCore/svg/SVGUseElement.cpp +++ b/Source/WebCore/svg/SVGUseElement.cpp @@ -239,11 +239,15 @@ void SVGUseElement::fillAttributeToPropertyTypeMap() attributeToPropertyTypeMap.set(XLinkNames::hrefAttr, AnimatedString); } -static void updateContainerSize(SVGUseElement* useElement, SVGElementInstance* targetInstance) +static void updateContainerSize(SVGElementInstance* targetInstance) { // Depth-first used to write the method in early exit style, no particular other reason. for (SVGElementInstance* instance = targetInstance->firstChild(); instance; instance = instance->nextSibling()) - updateContainerSize(useElement, instance); + updateContainerSize(instance); + + SVGUseElement* useElement = targetInstance->directUseElement(); + if (!useElement) + return; SVGElement* correspondingElement = targetInstance->correspondingElement(); ASSERT(correspondingElement); @@ -281,7 +285,8 @@ void SVGUseElement::updateContainerSizes() return; // Update whole subtree, scanning for shadow container elements, that correspond to <svg>/<symbol> tags - updateContainerSize(this, m_targetElementInstance.get()); + ASSERT(m_targetElementInstance->directUseElement() == this); + updateContainerSize(m_targetElementInstance.get()); if (RenderObject* object = renderer()) RenderSVGResource::markForLayoutAndParentResourceInvalidation(object); @@ -380,6 +385,9 @@ void dumpInstanceTree(unsigned int& depth, String& text, SVGElementInstance* tar SVGElement* shadowTreeElement = targetInstance->shadowTreeElement(); ASSERT(shadowTreeElement); + SVGUseElement* directUseElement = targetInstance->directUseElement(); + String directUseElementName = directUseElement ? directUseElement->nodeName() : "null"; + String elementId = element->getIdAttribute(); String elementNodeName = element->nodeName(); String shadowTreeElementNodeName = shadowTreeElement->nodeName(); @@ -389,9 +397,9 @@ void dumpInstanceTree(unsigned int& depth, String& text, SVGElementInstance* tar for (unsigned int i = 0; i < depth; ++i) text += " "; - text += String::format("SVGElementInstance this=%p, (parentNode=%s (%p), firstChild=%s (%p), correspondingElement=%s (%p), shadowTreeElement=%s (%p), id=%s)\n", + text += String::format("SVGElementInstance this=%p, (parentNode=%s (%p), firstChild=%s (%p), correspondingElement=%s (%p), directUseElement=%s (%p), shadowTreeElement=%s (%p), id=%s)\n", targetInstance, parentNodeName.latin1().data(), element->parentNode(), firstChildNodeName.latin1().data(), element->firstChild(), - elementNodeName.latin1().data(), element, shadowTreeElementNodeName.latin1().data(), shadowTreeElement, elementId.latin1().data()); + elementNodeName.latin1().data(), element, directUseElementName.latin1().data(), directUseElement, shadowTreeElementNodeName.latin1().data(), shadowTreeElement, elementId.latin1().data()); for (unsigned int i = 0; i < depth; ++i) text += " "; @@ -533,7 +541,7 @@ void SVGUseElement::buildShadowAndInstanceTree(SVGShadowTreeRootElement* shadowR // 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 = SVGElementInstance::create(this, target); + m_targetElementInstance = SVGElementInstance::create(this, this, target); // Eventually enter recursion to build SVGElementInstance objects for the sub-tree children bool foundProblem = false; @@ -550,6 +558,7 @@ void SVGUseElement::buildShadowAndInstanceTree(SVGShadowTreeRootElement* shadowR ASSERT(m_targetElementInstance); ASSERT(!m_targetElementInstance->shadowTreeElement()); ASSERT(m_targetElementInstance->correspondingUseElement() == this); + ASSERT(m_targetElementInstance->directUseElement() == this); ASSERT(m_targetElementInstance->correspondingElement() == target); // Build shadow tree from instance tree @@ -559,11 +568,11 @@ void SVGUseElement::buildShadowAndInstanceTree(SVGShadowTreeRootElement* shadowR #if ENABLE(SVG) && ENABLE(SVG_USE) // Expand all <use> elements in the shadow tree. // Expand means: replace the actual <use> element by what it references. - expandUseElementsInShadowTree(shadowRoot, shadowRoot); + expandUseElementsInShadowTree(shadowRoot); // Expand all <symbol> elements in the shadow tree. // Expand means: replace the actual <symbol> element by the <svg> element. - expandSymbolElementsInShadowTree(shadowRoot, shadowRoot); + expandSymbolElementsInShadowTree(shadowRoot); #endif // Now that the shadow tree is completly expanded, we can associate @@ -582,6 +591,16 @@ void SVGUseElement::buildShadowAndInstanceTree(SVGShadowTreeRootElement* shadowR // Consistency checks - this is assumed in updateContainerOffset(). ASSERT(m_targetElementInstance->shadowTreeElement()->parentNode() == shadowRoot); + // Transfer event listeners assigned to the referenced element to our shadow tree elements. + transferEventListenersToShadowTree(m_targetElementInstance.get()); + + // Update container offset/size + updateContainerOffsets(); + updateContainerSizes(); + + // Update relative length information + updateRelativeLengthsInformation(); + // Eventually dump instance tree #ifdef DUMP_INSTANCE_TREE String text; @@ -602,23 +621,13 @@ void SVGUseElement::buildShadowAndInstanceTree(SVGShadowTreeRootElement* shadowR fprintf(stderr, "Dumping <use> shadow tree markup:\n%s\n", markup.latin1().data()); #endif - - // Transfer event listeners assigned to the referenced element to our shadow tree elements. - transferEventListenersToShadowTree(m_targetElementInstance.get()); - - // Update container offset/size - updateContainerOffsets(); - updateContainerSizes(); - - // Update relative length information - updateRelativeLengthsInformation(); } void SVGUseElement::detachInstance() { if (!m_targetElementInstance) return; - m_targetElementInstance->clearUseElement(); + m_targetElementInstance->clearUseElements(); m_targetElementInstance = 0; } @@ -722,7 +731,7 @@ void SVGUseElement::buildInstanceTree(SVGElement* target, SVGElementInstance* ta continue; // Create SVGElementInstance object, for both container/non-container nodes. - RefPtr<SVGElementInstance> instance = SVGElementInstance::create(this, element); + RefPtr<SVGElementInstance> instance = SVGElementInstance::create(this, 0, element); SVGElementInstance* instancePtr = instance.get(); targetInstance->appendChild(instance.release()); @@ -735,7 +744,7 @@ void SVGUseElement::buildInstanceTree(SVGElement* target, SVGElementInstance* ta if (!targetHasUseTag || !newTarget) return; - RefPtr<SVGElementInstance> newInstance = SVGElementInstance::create(this, newTarget); + RefPtr<SVGElementInstance> newInstance = SVGElementInstance::create(this, static_cast<SVGUseElement*>(target), newTarget); SVGElementInstance* newInstancePtr = newInstance.get(); targetInstance->appendChild(newInstance.release()); buildInstanceTree(newTarget, newInstancePtr, foundProblem); @@ -812,7 +821,7 @@ void SVGUseElement::buildShadowTree(SVGShadowTreeRootElement* shadowRoot, SVGEle } #if ENABLE(SVG) && ENABLE(SVG_USE) -void SVGUseElement::expandUseElementsInShadowTree(SVGShadowTreeRootElement* shadowRoot, Node* element) +void SVGUseElement::expandUseElementsInShadowTree(Node* element) { // Why expand the <use> elements in the shadow tree here, and not just // do this directly in buildShadowTree, if we encounter a <use> element? @@ -860,21 +869,25 @@ void SVGUseElement::expandUseElementsInShadowTree(SVGShadowTreeRootElement* shad if (subtreeContainsDisallowedElement(cloneParent.get())) removeDisallowedElementsFromSubtree(cloneParent.get()); + RefPtr<Node> replacingElement(cloneParent.get()); + // Replace <use> with referenced content. ASSERT(use->parentNode()); use->parentNode()->replaceChild(cloneParent.release(), use, ec); ASSERT(!ec); - // Immediately stop here, and restart expanding. - expandUseElementsInShadowTree(shadowRoot, shadowRoot); - return; + // Expand the siblings because the *element* is replaced and we will + // lose the sibling chain when we are back from recursion. + element = replacingElement.get(); + for (RefPtr<Node> sibling = element->nextSibling(); sibling; sibling = sibling->nextSibling()) + expandUseElementsInShadowTree(sibling.get()); } for (RefPtr<Node> child = element->firstChild(); child; child = child->nextSibling()) - expandUseElementsInShadowTree(shadowRoot, child.get()); + expandUseElementsInShadowTree(child.get()); } -void SVGUseElement::expandSymbolElementsInShadowTree(SVGShadowTreeRootElement* shadowRoot, Node* element) +void SVGUseElement::expandSymbolElementsInShadowTree(Node* element) { if (element->hasTagName(SVGNames::symbolTag)) { // Spec: The referenced 'symbol' and its contents are deep-cloned into the generated tree, @@ -904,18 +917,22 @@ void SVGUseElement::expandSymbolElementsInShadowTree(SVGShadowTreeRootElement* s if (subtreeContainsDisallowedElement(svgElement.get())) removeDisallowedElementsFromSubtree(svgElement.get()); + RefPtr<Node> replacingElement(svgElement.get()); + // Replace <symbol> with <svg>. ASSERT(element->parentNode()); element->parentNode()->replaceChild(svgElement.release(), element, ec); ASSERT(!ec); - // Immediately stop here, and restart expanding. - expandSymbolElementsInShadowTree(shadowRoot, shadowRoot); - return; + // Expand the siblings because the *element* is replaced and we will + // lose the sibling chain when we are back from recursion. + element = replacingElement.get(); + for (RefPtr<Node> sibling = element->nextSibling(); sibling; sibling = sibling->nextSibling()) + expandSymbolElementsInShadowTree(sibling.get()); } for (RefPtr<Node> child = element->firstChild(); child; child = child->nextSibling()) - expandSymbolElementsInShadowTree(shadowRoot, child.get()); + expandSymbolElementsInShadowTree(child.get()); } #endif diff --git a/Source/WebCore/svg/SVGUseElement.h b/Source/WebCore/svg/SVGUseElement.h index 10c9be9..30569b5 100644 --- a/Source/WebCore/svg/SVGUseElement.h +++ b/Source/WebCore/svg/SVGUseElement.h @@ -91,8 +91,8 @@ private: void buildShadowTree(SVGShadowTreeRootElement*, SVGElement* target, SVGElementInstance* targetInstance); #if ENABLE(SVG) && ENABLE(SVG_USE) - void expandUseElementsInShadowTree(SVGShadowTreeRootElement*, Node* element); - void expandSymbolElementsInShadowTree(SVGShadowTreeRootElement*, Node* element); + void expandUseElementsInShadowTree(Node* element); + void expandSymbolElementsInShadowTree(Node* element); #endif // "Tree connector" diff --git a/Source/WebCore/svg/properties/SVGAnimatedPropertyDescription.h b/Source/WebCore/svg/properties/SVGAnimatedPropertyDescription.h index 6fb5e66..5fbaf9e 100644 --- a/Source/WebCore/svg/properties/SVGAnimatedPropertyDescription.h +++ b/Source/WebCore/svg/properties/SVGAnimatedPropertyDescription.h @@ -69,7 +69,7 @@ struct SVGAnimatedPropertyDescription { struct SVGAnimatedPropertyDescriptionHash { static unsigned hash(const SVGAnimatedPropertyDescription& key) { - return WTF::StringHasher::createBlobHash<sizeof(SVGAnimatedPropertyDescription)>(&key); + return StringHasher::hashMemory<sizeof(SVGAnimatedPropertyDescription)>(&key); } static bool equal(const SVGAnimatedPropertyDescription& a, const SVGAnimatedPropertyDescription& b) |