OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Nikolas Zimmermann <zimmermann@kde .org> | 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Nikolas Zimmermann <zimmermann@kde .org> |
3 * Copyright (C) 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org> | 3 * Copyright (C) 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org> |
4 * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved. | 4 * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved. |
5 * Copyright (C) 2011 Torch Mobile (Beijing) Co. Ltd. All rights reserved. | 5 * Copyright (C) 2011 Torch Mobile (Beijing) Co. Ltd. All rights reserved. |
6 * Copyright (C) 2012 University of Szeged | 6 * Copyright (C) 2012 University of Szeged |
7 * Copyright (C) 2012 Renata Hodovan <reni@webkit.org> | 7 * Copyright (C) 2012 Renata Hodovan <reni@webkit.org> |
8 * | 8 * |
9 * This library is free software; you can redistribute it and/or | 9 * This library is free software; you can redistribute it and/or |
10 * modify it under the terms of the GNU Library General Public | 10 * modify it under the terms of the GNU Library General Public |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
187 if (m_resource && m_resource->isLoaded()) { | 187 if (m_resource && m_resource->isLoaded()) { |
188 // Gracefully handle error condition. | 188 // Gracefully handle error condition. |
189 if (m_resource->errorOccurred()) | 189 if (m_resource->errorOccurred()) |
190 return 0; | 190 return 0; |
191 ASSERT(m_resource->document()); | 191 ASSERT(m_resource->document()); |
192 return m_resource->document(); | 192 return m_resource->document(); |
193 } | 193 } |
194 return 0; | 194 return 0; |
195 } | 195 } |
196 | 196 |
197 inline void transferUseWidthAndHeightIfNeeded(const SVGUseElement& use, SVGEleme nt* shadowElement, SVGElement* originalElement) | |
pdr.
2014/05/02 23:03:51
I still don't understand why this is inline.
pdr.
2014/05/02 23:03:51
Nit: can originalElement be a const reference?
| |
198 { | |
199 ASSERT(shadowElement); | |
200 ASSERT(originalElement); | |
201 if (isSVGSymbolElement(*shadowElement)) { | |
202 // Spec (<use> on <symbol>): This generated 'svg' will always have expli cit values for attributes width and height. | |
203 // If attributes width and/or height are provided on the 'use' element, then these attributes | |
204 // will be transferred to the generated 'svg'. If attributes width and/o r height are not specified, | |
205 // the generated 'svg' element will use values of 100% for these attribu tes. | |
206 shadowElement->setAttribute(SVGNames::widthAttr, use.width()->isSpecifie d() ? AtomicString(use.width()->currentValue()->valueAsString()) : "100%"); | |
207 shadowElement->setAttribute(SVGNames::heightAttr, use.height()->isSpecif ied() ? AtomicString(use.height()->currentValue()->valueAsString()) : "100%"); | |
208 } else if (isSVGSVGElement(*shadowElement)) { | |
209 // Spec (<use> on <svg>): If attributes width and/or height are provided on the 'use' element, then these | |
210 // values will override the corresponding attributes on the 'svg' in the generated tree. | |
211 if (use.width()->isSpecified()) | |
212 shadowElement->setAttribute(SVGNames::widthAttr, AtomicString(use.wi dth()->currentValue()->valueAsString())); | |
213 else | |
214 shadowElement->setAttribute(SVGNames::widthAttr, originalElement->ge tAttribute(SVGNames::widthAttr)); | |
215 if (use.height()->isSpecified()) | |
216 shadowElement->setAttribute(SVGNames::heightAttr, AtomicString(use.h eight()->currentValue()->valueAsString())); | |
217 else | |
218 shadowElement->setAttribute(SVGNames::heightAttr, originalElement->g etAttribute(SVGNames::heightAttr)); | |
219 } | |
220 } | |
221 | |
197 void SVGUseElement::svgAttributeChanged(const QualifiedName& attrName) | 222 void SVGUseElement::svgAttributeChanged(const QualifiedName& attrName) |
198 { | 223 { |
199 if (!isSupportedAttribute(attrName)) { | 224 if (!isSupportedAttribute(attrName)) { |
200 SVGGraphicsElement::svgAttributeChanged(attrName); | 225 SVGGraphicsElement::svgAttributeChanged(attrName); |
201 return; | 226 return; |
202 } | 227 } |
203 | 228 |
204 SVGElementInstance::InvalidationGuard invalidationGuard(this); | 229 SVGElementInstance::InvalidationGuard invalidationGuard(this); |
205 | 230 |
206 RenderObject* renderer = this->renderer(); | 231 RenderObject* renderer = this->renderer(); |
207 if (attrName == SVGNames::xAttr | 232 if (attrName == SVGNames::xAttr |
208 || attrName == SVGNames::yAttr | 233 || attrName == SVGNames::yAttr |
209 || attrName == SVGNames::widthAttr | 234 || attrName == SVGNames::widthAttr |
210 || attrName == SVGNames::heightAttr) { | 235 || attrName == SVGNames::heightAttr) { |
211 updateRelativeLengthsInformation(); | 236 updateRelativeLengthsInformation(); |
237 if (m_targetElementInstance) | |
238 transferUseWidthAndHeightIfNeeded(*this, m_targetElementInstance->sh adowTreeElement(), m_targetElementInstance->correspondingElement()); | |
212 if (renderer) | 239 if (renderer) |
213 RenderSVGResource::markForLayoutAndParentResourceInvalidation(render er); | 240 RenderSVGResource::markForLayoutAndParentResourceInvalidation(render er); |
214 return; | 241 return; |
215 } | 242 } |
216 | 243 |
217 if (SVGURIReference::isKnownAttribute(attrName)) { | 244 if (SVGURIReference::isKnownAttribute(attrName)) { |
218 bool isExternalReference = isExternalURIReference(hrefString(), document ()); | 245 bool isExternalReference = isExternalURIReference(hrefString(), document ()); |
219 if (isExternalReference) { | 246 if (isExternalReference) { |
220 KURL url = document().completeURL(hrefString()); | 247 KURL url = document().completeURL(hrefString()); |
221 if (url.hasFragmentIdentifier()) { | 248 if (url.hasFragmentIdentifier()) { |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
460 expandUseElementsInShadowTree(shadowTreeRootElement); | 487 expandUseElementsInShadowTree(shadowTreeRootElement); |
461 | 488 |
462 // Expand all <symbol> elements in the shadow tree. | 489 // Expand all <symbol> elements in the shadow tree. |
463 // Expand means: replace the actual <symbol> element by the <svg> element. | 490 // Expand means: replace the actual <symbol> element by the <svg> element. |
464 expandSymbolElementsInShadowTree(shadowTreeRootElement); | 491 expandSymbolElementsInShadowTree(shadowTreeRootElement); |
465 | 492 |
466 // Now that the shadow tree is completly expanded, we can associate | 493 // Now that the shadow tree is completly expanded, we can associate |
467 // shadow tree elements <-> instances in the instance tree. | 494 // shadow tree elements <-> instances in the instance tree. |
468 associateInstancesWithShadowTreeElements(shadowTreeRootElement->firstChild() , m_targetElementInstance.get()); | 495 associateInstancesWithShadowTreeElements(shadowTreeRootElement->firstChild() , m_targetElementInstance.get()); |
469 | 496 |
497 transferUseWidthAndHeightIfNeeded(*this, m_targetElementInstance->shadowTree Element(), m_targetElementInstance->correspondingElement()); | |
498 | |
470 // If no shadow tree element is present, this means that the reference root | 499 // If no shadow tree element is present, this means that the reference root |
471 // element was removed, as it is disallowed (ie. <use> on <foreignObject>) | 500 // element was removed, as it is disallowed (ie. <use> on <foreignObject>) |
472 // Do NOT leave an inconsistent instance tree around, instead destruct it. | 501 // Do NOT leave an inconsistent instance tree around, instead destruct it. |
473 if (!m_targetElementInstance->shadowTreeElement()) { | 502 if (!m_targetElementInstance->shadowTreeElement()) { |
474 clearResourceReferences(); | 503 clearResourceReferences(); |
475 return; | 504 return; |
476 } | 505 } |
477 | 506 |
478 ASSERT(m_targetElementInstance->shadowTreeElement()->parentNode() == shadowT reeRootElement); | 507 ASSERT(m_targetElementInstance->shadowTreeElement()->parentNode() == shadowT reeRootElement); |
479 | 508 |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
695 RefPtr<SVGGElement> cloneParent = SVGGElement::create(referencedScope()- >document()); | 724 RefPtr<SVGGElement> cloneParent = SVGGElement::create(referencedScope()- >document()); |
696 use->cloneChildNodes(cloneParent.get()); | 725 use->cloneChildNodes(cloneParent.get()); |
697 | 726 |
698 // Spec: In the generated content, the 'use' will be replaced by 'g', wh ere all attributes from the | 727 // Spec: In the generated content, the 'use' will be replaced by 'g', wh ere all attributes from the |
699 // 'use' element except for x, y, width, height and xlink:href are trans ferred to the generated 'g' element. | 728 // 'use' element except for x, y, width, height and xlink:href are trans ferred to the generated 'g' element. |
700 transferUseAttributesToReplacedElement(use, cloneParent.get()); | 729 transferUseAttributesToReplacedElement(use, cloneParent.get()); |
701 | 730 |
702 if (target && !isDisallowedElement(target)) { | 731 if (target && !isDisallowedElement(target)) { |
703 RefPtr<Element> newChild = target->cloneElementWithChildren(); | 732 RefPtr<Element> newChild = target->cloneElementWithChildren(); |
704 ASSERT(newChild->isSVGElement()); | 733 ASSERT(newChild->isSVGElement()); |
734 transferUseWidthAndHeightIfNeeded(*use, toSVGElement(newChild.get()) , target); | |
705 cloneParent->appendChild(newChild.release()); | 735 cloneParent->appendChild(newChild.release()); |
706 } | 736 } |
707 | 737 |
708 // We don't walk the target tree element-by-element, and clone each elem ent, | 738 // We don't walk the target tree element-by-element, and clone each elem ent, |
709 // but instead use cloneElementWithChildren(). This is an optimization f or the common | 739 // but instead use cloneElementWithChildren(). This is an optimization f or the common |
710 // case where <use> doesn't contain disallowed elements (ie. <foreignObj ect>). | 740 // case where <use> doesn't contain disallowed elements (ie. <foreignObj ect>). |
711 // Though if there are disallowed elements in the subtree, we have to re move them. | 741 // Though if there are disallowed elements in the subtree, we have to re move them. |
712 // For instance: <use> on <g> containing <foreignObject> (indirect case) . | 742 // For instance: <use> on <g> containing <foreignObject> (indirect case) . |
713 if (subtreeContainsDisallowedElement(cloneParent.get())) | 743 if (subtreeContainsDisallowedElement(cloneParent.get())) |
714 removeDisallowedElementsFromSubtree(*cloneParent); | 744 removeDisallowedElementsFromSubtree(*cloneParent); |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
965 | 995 |
966 if (m_resource) | 996 if (m_resource) |
967 m_resource->removeClient(this); | 997 m_resource->removeClient(this); |
968 | 998 |
969 m_resource = resource; | 999 m_resource = resource; |
970 if (m_resource) | 1000 if (m_resource) |
971 m_resource->addClient(this); | 1001 m_resource->addClient(this); |
972 } | 1002 } |
973 | 1003 |
974 } | 1004 } |
OLD | NEW |