OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2007 Nikolas Zimmermann <zimmermann@kde.org> | 2 * Copyright (C) 2007 Nikolas Zimmermann <zimmermann@kde.org> |
3 * Copyright (C) 2010 Rob Buis <rwlbuis@gmail.com> | 3 * Copyright (C) 2010 Rob Buis <rwlbuis@gmail.com> |
4 * | 4 * |
5 * This library is free software; you can redistribute it and/or | 5 * This library is free software; you can redistribute it and/or |
6 * modify it under the terms of the GNU Library General Public | 6 * modify it under the terms of the GNU Library General Public |
7 * License as published by the Free Software Foundation; either | 7 * License as published by the Free Software Foundation; either |
8 * version 2 of the License, or (at your option) any later version. | 8 * version 2 of the License, or (at your option) any later version. |
9 * | 9 * |
10 * This library is distributed in the hope that it will be useful, | 10 * This library is distributed in the hope that it will be useful, |
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 * Library General Public License for more details. | 13 * Library General Public License for more details. |
14 * | 14 * |
15 * You should have received a copy of the GNU Library General Public License | 15 * You should have received a copy of the GNU Library General Public License |
16 * along with this library; see the file COPYING.LIB. If not, write to | 16 * along with this library; see the file COPYING.LIB. If not, write to |
17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
18 * Boston, MA 02110-1301, USA. | 18 * Boston, MA 02110-1301, USA. |
19 */ | 19 */ |
20 | 20 |
21 #include "core/svg/SVGTextPathElement.h" | 21 #include "core/svg/SVGTextPathElement.h" |
22 | 22 |
| 23 #include "core/dom/IdTargetObserver.h" |
23 #include "core/layout/svg/LayoutSVGTextPath.h" | 24 #include "core/layout/svg/LayoutSVGTextPath.h" |
24 #include "core/svg/SVGTreeScopeResources.h" | |
25 | 25 |
26 namespace blink { | 26 namespace blink { |
27 | 27 |
28 template <> | 28 template <> |
29 const SVGEnumerationStringEntries& | 29 const SVGEnumerationStringEntries& |
30 getStaticStringEntries<SVGTextPathMethodType>() { | 30 getStaticStringEntries<SVGTextPathMethodType>() { |
31 DEFINE_STATIC_LOCAL(SVGEnumerationStringEntries, entries, ()); | 31 DEFINE_STATIC_LOCAL(SVGEnumerationStringEntries, entries, ()); |
32 if (entries.isEmpty()) { | 32 if (entries.isEmpty()) { |
33 entries.push_back(std::make_pair(SVGTextPathMethodAlign, "align")); | 33 entries.push_back(std::make_pair(SVGTextPathMethodAlign, "align")); |
34 entries.push_back(std::make_pair(SVGTextPathMethodStretch, "stretch")); | 34 entries.push_back(std::make_pair(SVGTextPathMethodStretch, "stretch")); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 } | 68 } |
69 | 69 |
70 DEFINE_NODE_FACTORY(SVGTextPathElement) | 70 DEFINE_NODE_FACTORY(SVGTextPathElement) |
71 | 71 |
72 SVGTextPathElement::~SVGTextPathElement() {} | 72 SVGTextPathElement::~SVGTextPathElement() {} |
73 | 73 |
74 DEFINE_TRACE(SVGTextPathElement) { | 74 DEFINE_TRACE(SVGTextPathElement) { |
75 visitor->trace(m_startOffset); | 75 visitor->trace(m_startOffset); |
76 visitor->trace(m_method); | 76 visitor->trace(m_method); |
77 visitor->trace(m_spacing); | 77 visitor->trace(m_spacing); |
| 78 visitor->trace(m_targetIdObserver); |
78 SVGTextContentElement::trace(visitor); | 79 SVGTextContentElement::trace(visitor); |
79 SVGURIReference::trace(visitor); | 80 SVGURIReference::trace(visitor); |
80 } | 81 } |
81 | 82 |
82 void SVGTextPathElement::clearResourceReferences() { | 83 void SVGTextPathElement::clearResourceReferences() { |
| 84 unobserveTarget(m_targetIdObserver); |
83 removeAllOutgoingReferences(); | 85 removeAllOutgoingReferences(); |
84 } | 86 } |
85 | 87 |
86 void SVGTextPathElement::svgAttributeChanged(const QualifiedName& attrName) { | 88 void SVGTextPathElement::svgAttributeChanged(const QualifiedName& attrName) { |
87 if (SVGURIReference::isKnownAttribute(attrName)) { | 89 if (SVGURIReference::isKnownAttribute(attrName)) { |
88 SVGElement::InvalidationGuard invalidationGuard(this); | 90 SVGElement::InvalidationGuard invalidationGuard(this); |
89 buildPendingResource(); | 91 buildPendingResource(); |
90 return; | 92 return; |
91 } | 93 } |
92 | 94 |
(...skipping 21 matching lines...) Expand all Loading... |
114 (isSVGAElement(*parentNode()) || isSVGTextElement(*parentNode()))) | 116 (isSVGAElement(*parentNode()) || isSVGTextElement(*parentNode()))) |
115 return SVGElement::layoutObjectIsNeeded(style); | 117 return SVGElement::layoutObjectIsNeeded(style); |
116 | 118 |
117 return false; | 119 return false; |
118 } | 120 } |
119 | 121 |
120 void SVGTextPathElement::buildPendingResource() { | 122 void SVGTextPathElement::buildPendingResource() { |
121 clearResourceReferences(); | 123 clearResourceReferences(); |
122 if (!isConnected()) | 124 if (!isConnected()) |
123 return; | 125 return; |
124 | 126 Element* target = observeTarget(m_targetIdObserver, *this); |
125 AtomicString id; | 127 if (isSVGPathElement(target)) { |
126 Element* target = SVGURIReference::targetElementFromIRIString( | |
127 hrefString(), treeScope(), &id); | |
128 if (!target) { | |
129 // Do not register as pending if we are already pending this resource. | |
130 if (treeScope().ensureSVGTreeScopedResources().isElementPendingResource( | |
131 *this, id)) | |
132 return; | |
133 if (!id.isEmpty()) { | |
134 treeScope().ensureSVGTreeScopedResources().addPendingResource(id, *this); | |
135 DCHECK(hasPendingResources()); | |
136 } | |
137 } else if (isSVGPathElement(*target)) { | |
138 // Register us with the target in the dependencies map. Any change of | 128 // Register us with the target in the dependencies map. Any change of |
139 // hrefElement that leads to relayout/repainting now informs us, so we can | 129 // hrefElement that leads to relayout/repainting now informs us, so we can |
140 // react to it. | 130 // react to it. |
141 addReferenceTo(toSVGElement((target))); | 131 addReferenceTo(toSVGElement(target)); |
142 } | 132 } |
143 | 133 |
144 if (LayoutObject* layoutObject = this->layoutObject()) | 134 if (LayoutObject* layoutObject = this->layoutObject()) |
145 markForLayoutAndParentResourceInvalidation(layoutObject); | 135 markForLayoutAndParentResourceInvalidation(layoutObject); |
146 } | 136 } |
147 | 137 |
148 Node::InsertionNotificationRequest SVGTextPathElement::insertedInto( | 138 Node::InsertionNotificationRequest SVGTextPathElement::insertedInto( |
149 ContainerNode* rootParent) { | 139 ContainerNode* rootParent) { |
150 SVGTextContentElement::insertedInto(rootParent); | 140 SVGTextContentElement::insertedInto(rootParent); |
151 buildPendingResource(); | 141 buildPendingResource(); |
152 return InsertionDone; | 142 return InsertionDone; |
153 } | 143 } |
154 | 144 |
155 void SVGTextPathElement::removedFrom(ContainerNode* rootParent) { | 145 void SVGTextPathElement::removedFrom(ContainerNode* rootParent) { |
156 SVGTextContentElement::removedFrom(rootParent); | 146 SVGTextContentElement::removedFrom(rootParent); |
157 if (rootParent->isConnected()) | 147 if (rootParent->isConnected()) |
158 clearResourceReferences(); | 148 clearResourceReferences(); |
159 } | 149 } |
160 | 150 |
161 bool SVGTextPathElement::selfHasRelativeLengths() const { | 151 bool SVGTextPathElement::selfHasRelativeLengths() const { |
162 return m_startOffset->currentValue()->isRelative() || | 152 return m_startOffset->currentValue()->isRelative() || |
163 SVGTextContentElement::selfHasRelativeLengths(); | 153 SVGTextContentElement::selfHasRelativeLengths(); |
164 } | 154 } |
165 | 155 |
166 } // namespace blink | 156 } // namespace blink |
OLD | NEW |