OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2007 Eric Seidel <eric@webkit.org> | 2 * Copyright (C) 2007 Eric Seidel <eric@webkit.org> |
3 * | 3 * |
4 * This library is free software; you can redistribute it and/or | 4 * This library is free software; you can redistribute it and/or |
5 * modify it under the terms of the GNU Library General Public | 5 * modify it under the terms of the GNU Library General Public |
6 * License as published by the Free Software Foundation; either | 6 * License as published by the Free Software Foundation; either |
7 * version 2 of the License, or (at your option) any later version. | 7 * version 2 of the License, or (at your option) any later version. |
8 * | 8 * |
9 * This library is distributed in the hope that it will be useful, | 9 * This library is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
12 * Library General Public License for more details. | 12 * Library General Public License for more details. |
13 * | 13 * |
14 * You should have received a copy of the GNU Library General Public License | 14 * You should have received a copy of the GNU Library General Public License |
15 * along with this library; see the file COPYING.LIB. If not, write to | 15 * along with this library; see the file COPYING.LIB. If not, write to |
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
17 * Boston, MA 02110-1301, USA. | 17 * Boston, MA 02110-1301, USA. |
18 */ | 18 */ |
19 | 19 |
20 #include "core/svg/SVGMPathElement.h" | 20 #include "core/svg/SVGMPathElement.h" |
21 | 21 |
| 22 #include "core/SVGNames.h" |
22 #include "core/dom/Document.h" | 23 #include "core/dom/Document.h" |
| 24 #include "core/dom/IdTargetObserver.h" |
23 #include "core/svg/SVGAnimateMotionElement.h" | 25 #include "core/svg/SVGAnimateMotionElement.h" |
24 #include "core/svg/SVGPathElement.h" | 26 #include "core/svg/SVGPathElement.h" |
25 #include "core/svg/SVGTreeScopeResources.h" | |
26 | 27 |
27 namespace blink { | 28 namespace blink { |
28 | 29 |
29 inline SVGMPathElement::SVGMPathElement(Document& document) | 30 inline SVGMPathElement::SVGMPathElement(Document& document) |
30 : SVGElement(SVGNames::mpathTag, document), SVGURIReference(this) { | 31 : SVGElement(SVGNames::mpathTag, document), SVGURIReference(this) { |
31 ASSERT(RuntimeEnabledFeatures::smilEnabled()); | 32 ASSERT(RuntimeEnabledFeatures::smilEnabled()); |
32 } | 33 } |
33 | 34 |
34 DEFINE_TRACE(SVGMPathElement) { | 35 DEFINE_TRACE(SVGMPathElement) { |
| 36 visitor->trace(m_targetIdObserver); |
35 SVGElement::trace(visitor); | 37 SVGElement::trace(visitor); |
36 SVGURIReference::trace(visitor); | 38 SVGURIReference::trace(visitor); |
37 } | 39 } |
38 | 40 |
39 DEFINE_NODE_FACTORY(SVGMPathElement) | 41 DEFINE_NODE_FACTORY(SVGMPathElement) |
40 | 42 |
41 SVGMPathElement::~SVGMPathElement() {} | 43 SVGMPathElement::~SVGMPathElement() {} |
42 | 44 |
43 void SVGMPathElement::buildPendingResource() { | 45 void SVGMPathElement::buildPendingResource() { |
44 clearResourceReferences(); | 46 clearResourceReferences(); |
45 if (!isConnected()) | 47 if (!isConnected()) |
46 return; | 48 return; |
47 | 49 Element* target = observeTarget(m_targetIdObserver, *this); |
48 AtomicString id; | 50 if (isSVGPathElement(target)) { |
49 Element* target = SVGURIReference::targetElementFromIRIString( | |
50 hrefString(), treeScope(), &id); | |
51 if (!target) { | |
52 // Do not register as pending if we are already pending this resource. | |
53 if (treeScope().ensureSVGTreeScopedResources().isElementPendingResource( | |
54 *this, id)) | |
55 return; | |
56 if (!id.isEmpty()) { | |
57 treeScope().ensureSVGTreeScopedResources().addPendingResource(id, *this); | |
58 DCHECK(hasPendingResources()); | |
59 } | |
60 } else if (isSVGPathElement(target)) { | |
61 // Register us with the target in the dependencies map. Any change of | 51 // Register us with the target in the dependencies map. Any change of |
62 // hrefElement that leads to relayout/repainting now informs us, so we can | 52 // hrefElement that leads to relayout/repainting now informs us, so we can |
63 // react to it. | 53 // react to it. |
64 addReferenceTo(toSVGElement(target)); | 54 addReferenceTo(toSVGElement(target)); |
65 } | 55 } |
66 | |
67 targetPathChanged(); | 56 targetPathChanged(); |
68 } | 57 } |
69 | 58 |
70 void SVGMPathElement::clearResourceReferences() { | 59 void SVGMPathElement::clearResourceReferences() { |
| 60 unobserveTarget(m_targetIdObserver); |
71 removeAllOutgoingReferences(); | 61 removeAllOutgoingReferences(); |
72 } | 62 } |
73 | 63 |
74 Node::InsertionNotificationRequest SVGMPathElement::insertedInto( | 64 Node::InsertionNotificationRequest SVGMPathElement::insertedInto( |
75 ContainerNode* rootParent) { | 65 ContainerNode* rootParent) { |
76 SVGElement::insertedInto(rootParent); | 66 SVGElement::insertedInto(rootParent); |
77 if (rootParent->isConnected()) | 67 if (rootParent->isConnected()) |
78 buildPendingResource(); | 68 buildPendingResource(); |
79 return InsertionDone; | 69 return InsertionDone; |
80 } | 70 } |
(...skipping 23 matching lines...) Expand all Loading... |
104 void SVGMPathElement::targetPathChanged() { | 94 void SVGMPathElement::targetPathChanged() { |
105 notifyParentOfPathChange(parentNode()); | 95 notifyParentOfPathChange(parentNode()); |
106 } | 96 } |
107 | 97 |
108 void SVGMPathElement::notifyParentOfPathChange(ContainerNode* parent) { | 98 void SVGMPathElement::notifyParentOfPathChange(ContainerNode* parent) { |
109 if (isSVGAnimateMotionElement(parent)) | 99 if (isSVGAnimateMotionElement(parent)) |
110 toSVGAnimateMotionElement(parent)->updateAnimationPath(); | 100 toSVGAnimateMotionElement(parent)->updateAnimationPath(); |
111 } | 101 } |
112 | 102 |
113 } // namespace blink | 103 } // namespace blink |
OLD | NEW |