| 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 673 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 684 RefPtr<Element> newChild = targetInstance->correspondingElement()->cloneElem
entWithChildren(); | 684 RefPtr<Element> newChild = targetInstance->correspondingElement()->cloneElem
entWithChildren(); |
| 685 | 685 |
| 686 // We don't walk the target tree element-by-element, and clone each element, | 686 // We don't walk the target tree element-by-element, and clone each element, |
| 687 // but instead use cloneElementWithChildren(). This is an optimization for t
he common | 687 // but instead use cloneElementWithChildren(). This is an optimization for t
he common |
| 688 // case where <use> doesn't contain disallowed elements (ie. <foreignObject>
). | 688 // case where <use> doesn't contain disallowed elements (ie. <foreignObject>
). |
| 689 // Though if there are disallowed elements in the subtree, we have to remove
them. | 689 // Though if there are disallowed elements in the subtree, we have to remove
them. |
| 690 // For instance: <use> on <g> containing <foreignObject> (indirect case). | 690 // For instance: <use> on <g> containing <foreignObject> (indirect case). |
| 691 if (subtreeContainsDisallowedElement(newChild.get())) | 691 if (subtreeContainsDisallowedElement(newChild.get())) |
| 692 removeDisallowedElementsFromSubtree(newChild.get()); | 692 removeDisallowedElementsFromSubtree(newChild.get()); |
| 693 | 693 |
| 694 userAgentShadowRoot()->appendChild(newChild.release()); | 694 userAgentShadowRoot()->appendChild(newChild.release(), ASSERT_NO_EXCEPTION,
DeprecatedAttachNow); |
| 695 } | 695 } |
| 696 | 696 |
| 697 void SVGUseElement::expandUseElementsInShadowTree(Node* element) | 697 void SVGUseElement::expandUseElementsInShadowTree(Node* element) |
| 698 { | 698 { |
| 699 // Why expand the <use> elements in the shadow tree here, and not just | 699 // Why expand the <use> elements in the shadow tree here, and not just |
| 700 // do this directly in buildShadowTree, if we encounter a <use> element? | 700 // do this directly in buildShadowTree, if we encounter a <use> element? |
| 701 // | 701 // |
| 702 // Short answer: Because we may miss to expand some elements. Ie. if a <symb
ol> | 702 // Short answer: Because we may miss to expand some elements. Ie. if a <symb
ol> |
| 703 // contains <use> tags, we'd miss them. So once we're done with settin' up t
he | 703 // contains <use> tags, we'd miss them. So once we're done with settin' up t
he |
| 704 // actual shadow tree (after the special case modification for svg/symbol) w
e have | 704 // actual shadow tree (after the special case modification for svg/symbol) w
e have |
| (...skipping 12 matching lines...) Expand all Loading... |
| 717 RefPtr<SVGGElement> cloneParent = SVGGElement::create(SVGNames::gTag, re
ferencedDocument()); | 717 RefPtr<SVGGElement> cloneParent = SVGGElement::create(SVGNames::gTag, re
ferencedDocument()); |
| 718 use->cloneChildNodes(cloneParent.get()); | 718 use->cloneChildNodes(cloneParent.get()); |
| 719 | 719 |
| 720 // Spec: In the generated content, the 'use' will be replaced by 'g', wh
ere all attributes from the | 720 // Spec: In the generated content, the 'use' will be replaced by 'g', wh
ere all attributes from the |
| 721 // 'use' element except for x, y, width, height and xlink:href are trans
ferred to the generated 'g' element. | 721 // 'use' element except for x, y, width, height and xlink:href are trans
ferred to the generated 'g' element. |
| 722 transferUseAttributesToReplacedElement(use, cloneParent.get()); | 722 transferUseAttributesToReplacedElement(use, cloneParent.get()); |
| 723 | 723 |
| 724 if (target && !isDisallowedElement(target)) { | 724 if (target && !isDisallowedElement(target)) { |
| 725 RefPtr<Element> newChild = target->cloneElementWithChildren(); | 725 RefPtr<Element> newChild = target->cloneElementWithChildren(); |
| 726 ASSERT(newChild->isSVGElement()); | 726 ASSERT(newChild->isSVGElement()); |
| 727 cloneParent->appendChild(newChild.release()); | 727 cloneParent->appendChild(newChild.release(), ASSERT_NO_EXCEPTION, De
precatedAttachNow); |
| 728 } | 728 } |
| 729 | 729 |
| 730 // We don't walk the target tree element-by-element, and clone each elem
ent, | 730 // We don't walk the target tree element-by-element, and clone each elem
ent, |
| 731 // but instead use cloneElementWithChildren(). This is an optimization f
or the common | 731 // but instead use cloneElementWithChildren(). This is an optimization f
or the common |
| 732 // case where <use> doesn't contain disallowed elements (ie. <foreignObj
ect>). | 732 // case where <use> doesn't contain disallowed elements (ie. <foreignObj
ect>). |
| 733 // Though if there are disallowed elements in the subtree, we have to re
move them. | 733 // Though if there are disallowed elements in the subtree, we have to re
move them. |
| 734 // For instance: <use> on <g> containing <foreignObject> (indirect case)
. | 734 // For instance: <use> on <g> containing <foreignObject> (indirect case)
. |
| 735 if (subtreeContainsDisallowedElement(cloneParent.get())) | 735 if (subtreeContainsDisallowedElement(cloneParent.get())) |
| 736 removeDisallowedElementsFromSubtree(cloneParent.get()); | 736 removeDisallowedElementsFromSubtree(cloneParent.get()); |
| 737 | 737 |
| 738 RefPtr<Node> replacingElement(cloneParent.get()); | 738 RefPtr<Node> replacingElement(cloneParent.get()); |
| 739 | 739 |
| 740 // Replace <use> with referenced content. | 740 // Replace <use> with referenced content. |
| 741 ASSERT(use->parentNode()); | 741 ASSERT(use->parentNode()); |
| 742 use->parentNode()->replaceChild(cloneParent.release(), use); | 742 use->parentNode()->replaceChild(cloneParent.release(), use, ASSERT_NO_EX
CEPTION, DeprecatedAttachNow); |
| 743 | 743 |
| 744 // Expand the siblings because the *element* is replaced and we will | 744 // Expand the siblings because the *element* is replaced and we will |
| 745 // lose the sibling chain when we are back from recursion. | 745 // lose the sibling chain when we are back from recursion. |
| 746 element = replacingElement.get(); | 746 element = replacingElement.get(); |
| 747 for (RefPtr<Node> sibling = element->nextSibling(); sibling; sibling = s
ibling->nextSibling()) | 747 for (RefPtr<Node> sibling = element->nextSibling(); sibling; sibling = s
ibling->nextSibling()) |
| 748 expandUseElementsInShadowTree(sibling.get()); | 748 expandUseElementsInShadowTree(sibling.get()); |
| 749 } | 749 } |
| 750 | 750 |
| 751 for (RefPtr<Node> child = element->firstChild(); child; child = child->nextS
ibling()) | 751 for (RefPtr<Node> child = element->firstChild(); child; child = child->nextS
ibling()) |
| 752 expandUseElementsInShadowTree(child.get()); | 752 expandUseElementsInShadowTree(child.get()); |
| 753 } | 753 } |
| 754 | 754 |
| 755 void SVGUseElement::expandSymbolElementsInShadowTree(Node* element) | 755 void SVGUseElement::expandSymbolElementsInShadowTree(Node* element) |
| 756 { | 756 { |
| 757 if (element->hasTagName(SVGNames::symbolTag)) { | 757 if (element->hasTagName(SVGNames::symbolTag)) { |
| 758 // Spec: The referenced 'symbol' and its contents are deep-cloned into t
he generated tree, | 758 // Spec: The referenced 'symbol' and its contents are deep-cloned into t
he generated tree, |
| 759 // with the exception that the 'symbol' is replaced by an 'svg'. This ge
nerated 'svg' will | 759 // with the exception that the 'symbol' is replaced by an 'svg'. This ge
nerated 'svg' will |
| 760 // always have explicit values for attributes width and height. If attri
butes width and/or | 760 // always have explicit values for attributes width and height. If attri
butes width and/or |
| 761 // height are provided on the 'use' element, then these attributes will
be transferred to | 761 // height are provided on the 'use' element, then these attributes will
be transferred to |
| 762 // the generated 'svg'. If attributes width and/or height are not specif
ied, the generated | 762 // the generated 'svg'. If attributes width and/or height are not specif
ied, the generated |
| 763 // 'svg' element will use values of 100% for these attributes. | 763 // 'svg' element will use values of 100% for these attributes. |
| 764 RefPtr<SVGSVGElement> svgElement = SVGSVGElement::create(SVGNames::svgTa
g, referencedDocument()); | 764 RefPtr<SVGSVGElement> svgElement = SVGSVGElement::create(SVGNames::svgTa
g, referencedDocument()); |
| 765 | 765 |
| 766 // Transfer all data (attributes, etc.) from <symbol> to the new <svg> e
lement. | 766 // Transfer all data (attributes, etc.) from <symbol> to the new <svg> e
lement. |
| 767 svgElement->cloneDataFromElement(*toElement(element)); | 767 svgElement->cloneDataFromElement(*toElement(element)); |
| 768 | 768 |
| 769 // Only clone symbol children, and add them to the new <svg> element | 769 // Only clone symbol children, and add them to the new <svg> element |
| 770 for (Node* child = element->firstChild(); child; child = child->nextSibl
ing()) { | 770 for (Node* child = element->firstChild(); child; child = child->nextSibl
ing()) { |
| 771 RefPtr<Node> newChild = child->cloneNode(true); | 771 RefPtr<Node> newChild = child->cloneNode(true); |
| 772 svgElement->appendChild(newChild.release()); | 772 svgElement->appendChild(newChild.release(), ASSERT_NO_EXCEPTION, Dep
recatedAttachNow); |
| 773 } | 773 } |
| 774 | 774 |
| 775 // We don't walk the target tree element-by-element, and clone each elem
ent, | 775 // We don't walk the target tree element-by-element, and clone each elem
ent, |
| 776 // but instead use cloneNode(deep=true). This is an optimization for the
common | 776 // but instead use cloneNode(deep=true). This is an optimization for the
common |
| 777 // case where <use> doesn't contain disallowed elements (ie. <foreignObj
ect>). | 777 // case where <use> doesn't contain disallowed elements (ie. <foreignObj
ect>). |
| 778 // Though if there are disallowed elements in the subtree, we have to re
move them. | 778 // Though if there are disallowed elements in the subtree, we have to re
move them. |
| 779 // For instance: <use> on <g> containing <foreignObject> (indirect case)
. | 779 // For instance: <use> on <g> containing <foreignObject> (indirect case)
. |
| 780 if (subtreeContainsDisallowedElement(svgElement.get())) | 780 if (subtreeContainsDisallowedElement(svgElement.get())) |
| 781 removeDisallowedElementsFromSubtree(svgElement.get()); | 781 removeDisallowedElementsFromSubtree(svgElement.get()); |
| 782 | 782 |
| 783 RefPtr<Node> replacingElement(svgElement.get()); | 783 RefPtr<Node> replacingElement(svgElement.get()); |
| 784 | 784 |
| 785 // Replace <symbol> with <svg>. | 785 // Replace <symbol> with <svg>. |
| 786 element->parentNode()->replaceChild(svgElement.release(), element); | 786 element->parentNode()->replaceChild(svgElement.release(), element, ASSER
T_NO_EXCEPTION, DeprecatedAttachNow); |
| 787 | 787 |
| 788 // Expand the siblings because the *element* is replaced and we will | 788 // Expand the siblings because the *element* is replaced and we will |
| 789 // lose the sibling chain when we are back from recursion. | 789 // lose the sibling chain when we are back from recursion. |
| 790 element = replacingElement.get(); | 790 element = replacingElement.get(); |
| 791 for (RefPtr<Node> sibling = element->nextSibling(); sibling; sibling = s
ibling->nextSibling()) | 791 for (RefPtr<Node> sibling = element->nextSibling(); sibling; sibling = s
ibling->nextSibling()) |
| 792 expandSymbolElementsInShadowTree(sibling.get()); | 792 expandSymbolElementsInShadowTree(sibling.get()); |
| 793 } | 793 } |
| 794 | 794 |
| 795 for (RefPtr<Node> child = element->firstChild(); child; child = child->nextS
ibling()) | 795 for (RefPtr<Node> child = element->firstChild(); child; child = child->nextS
ibling()) |
| 796 expandSymbolElementsInShadowTree(child.get()); | 796 expandSymbolElementsInShadowTree(child.get()); |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 985 | 985 |
| 986 if (m_resource) | 986 if (m_resource) |
| 987 m_resource->removeClient(this); | 987 m_resource->removeClient(this); |
| 988 | 988 |
| 989 m_resource = resource; | 989 m_resource = resource; |
| 990 if (m_resource) | 990 if (m_resource) |
| 991 m_resource->addClient(this); | 991 m_resource->addClient(this); |
| 992 } | 992 } |
| 993 | 993 |
| 994 } | 994 } |
| OLD | NEW |