OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2004, 2005, 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org> | 2 * Copyright (C) 2004, 2005, 2006, 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 * | 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 "config.h" | 21 #include "config.h" |
22 #include "core/svg/SVGPathElement.h" | 22 #include "core/svg/SVGPathElement.h" |
23 | 23 |
24 #include "core/dom/NodeComputedStyle.h" | |
fs
2015/12/11 13:01:58
No longer needed?
Eric Willigers
2015/12/14 05:36:46
Acknowledged.
| |
24 #include "core/layout/svg/LayoutSVGPath.h" | 25 #include "core/layout/svg/LayoutSVGPath.h" |
25 #include "core/svg/SVGDocumentExtensions.h" | 26 #include "core/svg/SVGDocumentExtensions.h" |
26 #include "core/svg/SVGMPathElement.h" | 27 #include "core/svg/SVGMPathElement.h" |
27 #include "core/svg/SVGPathQuery.h" | 28 #include "core/svg/SVGPathQuery.h" |
29 #include "core/svg/SVGPathUtilities.h" | |
28 #include "core/svg/SVGPointTearOff.h" | 30 #include "core/svg/SVGPointTearOff.h" |
29 | 31 |
30 namespace blink { | 32 namespace blink { |
31 | 33 |
32 class SVGAnimatedPathLength final : public SVGAnimatedNumber { | 34 class SVGAnimatedPathLength final : public SVGAnimatedNumber { |
33 public: | 35 public: |
34 static PassRefPtrWillBeRawPtr<SVGAnimatedPathLength> create(SVGPathElement* contextElement) | 36 static PassRefPtrWillBeRawPtr<SVGAnimatedPathLength> create(SVGPathElement* contextElement) |
35 { | 37 { |
36 return adoptRefWillBeNoop(new SVGAnimatedPathLength(contextElement)); | 38 return adoptRefWillBeNoop(new SVGAnimatedPathLength(contextElement)); |
37 } | 39 } |
(...skipping 27 matching lines...) Expand all Loading... | |
65 { | 67 { |
66 visitor->trace(m_pathLength); | 68 visitor->trace(m_pathLength); |
67 visitor->trace(m_path); | 69 visitor->trace(m_path); |
68 SVGGeometryElement::trace(visitor); | 70 SVGGeometryElement::trace(visitor); |
69 } | 71 } |
70 | 72 |
71 DEFINE_NODE_FACTORY(SVGPathElement) | 73 DEFINE_NODE_FACTORY(SVGPathElement) |
72 | 74 |
73 Path SVGPathElement::asPath() const | 75 Path SVGPathElement::asPath() const |
74 { | 76 { |
75 // If this is a <use> instance, return the referenced path to maximize geome try sharing. | 77 Path path; |
76 if (const SVGElement* element = correspondingElement()) | 78 buildPathFromByteStream(pathByteStream(), path); |
77 return toSVGPathElement(element)->asPath(); | 79 return path; |
80 } | |
78 | 81 |
79 return m_path->currentValue()->path(); | 82 const SVGPathByteStream& SVGPathElement::pathByteStream() const |
83 { | |
84 if (layoutObject()) { | |
85 const SVGComputedStyle& svgStyle = layoutObject()->styleRef().svgStyle() ; | |
86 return svgStyle.d()->byteStream(); | |
87 | |
88 } | |
89 | |
90 return m_path->currentValue()->byteStream(); | |
80 } | 91 } |
81 | 92 |
82 float SVGPathElement::getTotalLength() | 93 float SVGPathElement::getTotalLength() |
83 { | 94 { |
84 return SVGPathQuery(m_path->currentValue()->byteStream()).getTotalLength(); | 95 document().updateLayoutIgnorePendingStylesheets(); |
96 return SVGPathQuery(pathByteStream()).getTotalLength(); | |
85 } | 97 } |
86 | 98 |
87 PassRefPtrWillBeRawPtr<SVGPointTearOff> SVGPathElement::getPointAtLength(float l ength) | 99 PassRefPtrWillBeRawPtr<SVGPointTearOff> SVGPathElement::getPointAtLength(float l ength) |
88 { | 100 { |
89 FloatPoint point = SVGPathQuery(m_path->currentValue()->byteStream()).getPoi ntAtLength(length); | 101 document().updateLayoutIgnorePendingStylesheets(); |
102 FloatPoint point = SVGPathQuery(pathByteStream()).getPointAtLength(length); | |
90 return SVGPointTearOff::create(SVGPoint::create(point), 0, PropertyIsNotAnim Val); | 103 return SVGPointTearOff::create(SVGPoint::create(point), 0, PropertyIsNotAnim Val); |
91 } | 104 } |
92 | 105 |
93 unsigned SVGPathElement::getPathSegAtLength(float length) | 106 unsigned SVGPathElement::getPathSegAtLength(float length) |
94 { | 107 { |
95 return SVGPathQuery(m_path->currentValue()->byteStream()).getPathSegIndexAtL ength(length); | 108 document().updateLayoutIgnorePendingStylesheets(); |
109 return SVGPathQuery(pathByteStream()).getPathSegIndexAtLength(length); | |
110 } | |
111 | |
112 bool SVGPathElement::isPresentationAttribute(const QualifiedName& attrName) cons t | |
113 { | |
114 if (attrName == SVGNames::dAttr) | |
115 return true; | |
116 return SVGGeometryElement::isPresentationAttribute(attrName); | |
117 } | |
118 | |
119 bool SVGPathElement::isPresentationAttributeWithSVGDOM(const QualifiedName& attr Name) const | |
120 { | |
121 if (attrName == SVGNames::dAttr) | |
122 return true; | |
123 return SVGGeometryElement::isPresentationAttributeWithSVGDOM(attrName); | |
96 } | 124 } |
97 | 125 |
98 void SVGPathElement::svgAttributeChanged(const QualifiedName& attrName) | 126 void SVGPathElement::svgAttributeChanged(const QualifiedName& attrName) |
99 { | 127 { |
100 if (attrName == SVGNames::dAttr || attrName == SVGNames::pathLengthAttr) { | 128 if (attrName == SVGNames::dAttr) { |
101 SVGElement::InvalidationGuard invalidationGuard(this); | 129 SVGElement::InvalidationGuard invalidationGuard(this); |
130 invalidateSVGPresentationAttributeStyle(); | |
131 setNeedsStyleRecalc(LocalStyleChange, | |
132 StyleChangeReasonForTracing::fromAttribute(attrName)); | |
102 | 133 |
103 LayoutSVGShape* layoutObject = toLayoutSVGShape(this->layoutObject()); | 134 if (LayoutSVGShape* layoutPath = toLayoutSVGShape(this->layoutObject())) |
135 layoutPath->setNeedsShapeUpdate(); | |
104 | 136 |
105 if (attrName == SVGNames::dAttr) { | 137 invalidateMPathDependencies(); |
106 if (layoutObject) | 138 if (layoutObject()) |
107 layoutObject->setNeedsShapeUpdate(); | 139 markForLayoutAndParentResourceInvalidation(layoutObject()); |
108 | 140 |
109 invalidateMPathDependencies(); | 141 return; |
110 } | 142 } |
111 | 143 |
112 if (layoutObject) | 144 if (attrName == SVGNames::pathLengthAttr) { |
113 markForLayoutAndParentResourceInvalidation(layoutObject); | 145 SVGElement::InvalidationGuard invalidationGuard(this); |
114 | 146 if (layoutObject()) |
147 markForLayoutAndParentResourceInvalidation(layoutObject()); | |
115 return; | 148 return; |
116 } | 149 } |
117 | 150 |
118 SVGGeometryElement::svgAttributeChanged(attrName); | 151 SVGGeometryElement::svgAttributeChanged(attrName); |
119 } | 152 } |
120 | 153 |
154 void SVGPathElement::collectStyleForPresentationAttribute(const QualifiedName& n ame, const AtomicString& value, MutableStylePropertySet* style) | |
155 { | |
156 RefPtrWillBeRawPtr<SVGAnimatedPropertyBase> property = propertyFromAttribute (name); | |
157 if (property == m_path) | |
158 addPropertyToPresentationAttributeStyle(style, CSSPropertyD, m_path->cur rentValue()->pathValue()); | |
159 else | |
160 SVGGeometryElement::collectStyleForPresentationAttribute(name, value, st yle); | |
161 } | |
162 | |
121 void SVGPathElement::invalidateMPathDependencies() | 163 void SVGPathElement::invalidateMPathDependencies() |
122 { | 164 { |
123 // <mpath> can only reference <path> but this dependency is not handled in | 165 // <mpath> can only reference <path> but this dependency is not handled in |
124 // markForLayoutAndParentResourceInvalidation so we update any mpath depende ncies manually. | 166 // markForLayoutAndParentResourceInvalidation so we update any mpath depende ncies manually. |
125 if (SVGElementSet* dependencies = setOfIncomingReferences()) { | 167 if (SVGElementSet* dependencies = setOfIncomingReferences()) { |
126 for (SVGElement* element : *dependencies) { | 168 for (SVGElement* element : *dependencies) { |
127 if (isSVGMPathElement(*element)) | 169 if (isSVGMPathElement(*element)) |
128 toSVGMPathElement(element)->targetPathChanged(); | 170 toSVGMPathElement(element)->targetPathChanged(); |
129 } | 171 } |
130 } | 172 } |
131 } | 173 } |
132 | 174 |
133 Node::InsertionNotificationRequest SVGPathElement::insertedInto(ContainerNode* r ootParent) | 175 Node::InsertionNotificationRequest SVGPathElement::insertedInto(ContainerNode* r ootParent) |
134 { | 176 { |
135 SVGGeometryElement::insertedInto(rootParent); | 177 SVGGeometryElement::insertedInto(rootParent); |
136 invalidateMPathDependencies(); | 178 invalidateMPathDependencies(); |
137 return InsertionDone; | 179 return InsertionDone; |
138 } | 180 } |
139 | 181 |
140 void SVGPathElement::removedFrom(ContainerNode* rootParent) | 182 void SVGPathElement::removedFrom(ContainerNode* rootParent) |
141 { | 183 { |
142 SVGGeometryElement::removedFrom(rootParent); | 184 SVGGeometryElement::removedFrom(rootParent); |
143 invalidateMPathDependencies(); | 185 invalidateMPathDependencies(); |
144 } | 186 } |
145 | 187 |
146 } // namespace blink | 188 } // namespace blink |
OLD | NEW |