Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(60)

Side by Side Diff: third_party/WebKit/Source/core/svg/SVGPatternElement.cpp

Issue 2478233002: Make 'transform' a presentation attribute on SVG elements (Closed)
Patch Set: Rebase Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Nikolas Zimmermann 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Nikolas Zimmermann
3 * <zimmermann@kde.org> 3 * <zimmermann@kde.org>
4 * Copyright (C) 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org> 4 * Copyright (C) 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org>
5 * Copyright (C) Research In Motion Limited 2010. All rights reserved. 5 * Copyright (C) Research In Motion Limited 2010. All rights reserved.
6 * 6 *
7 * This library is free software; you can redistribute it and/or 7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public 8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either 9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version. 10 * version 2 of the License, or (at your option) any later version.
11 * 11 *
12 * This library is distributed in the hope that it will be useful, 12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Library General Public License for more details. 15 * Library General Public License for more details.
16 * 16 *
17 * You should have received a copy of the GNU Library General Public License 17 * You should have received a copy of the GNU Library General Public License
18 * along with this library; see the file COPYING.LIB. If not, write to 18 * along with this library; see the file COPYING.LIB. If not, write to
19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 * Boston, MA 02110-1301, USA. 20 * Boston, MA 02110-1301, USA.
21 */ 21 */
22 22
23 #include "core/svg/SVGPatternElement.h" 23 #include "core/svg/SVGPatternElement.h"
24 24
25 #include "core/dom/ElementTraversal.h" 25 #include "core/dom/ElementTraversal.h"
26 #include "core/dom/StyleChangeReason.h"
26 #include "core/layout/svg/LayoutSVGResourcePattern.h" 27 #include "core/layout/svg/LayoutSVGResourcePattern.h"
27 #include "core/svg/PatternAttributes.h" 28 #include "core/svg/PatternAttributes.h"
28 #include "platform/transforms/AffineTransform.h" 29 #include "platform/transforms/AffineTransform.h"
29 30
30 namespace blink { 31 namespace blink {
31 32
32 inline SVGPatternElement::SVGPatternElement(Document& document) 33 inline SVGPatternElement::SVGPatternElement(Document& document)
33 : SVGElement(SVGNames::patternTag, document), 34 : SVGElement(SVGNames::patternTag, document),
34 SVGURIReference(this), 35 SVGURIReference(this),
35 SVGTests(this), 36 SVGTests(this),
36 SVGFitToViewBox(this), 37 SVGFitToViewBox(this),
37 m_x(SVGAnimatedLength::create(this, 38 m_x(SVGAnimatedLength::create(this,
38 SVGNames::xAttr, 39 SVGNames::xAttr,
39 SVGLength::create(SVGLengthMode::Width))), 40 SVGLength::create(SVGLengthMode::Width))),
40 m_y(SVGAnimatedLength::create(this, 41 m_y(SVGAnimatedLength::create(this,
41 SVGNames::yAttr, 42 SVGNames::yAttr,
42 SVGLength::create(SVGLengthMode::Height))), 43 SVGLength::create(SVGLengthMode::Height))),
43 m_width( 44 m_width(
44 SVGAnimatedLength::create(this, 45 SVGAnimatedLength::create(this,
45 SVGNames::widthAttr, 46 SVGNames::widthAttr,
46 SVGLength::create(SVGLengthMode::Width))), 47 SVGLength::create(SVGLengthMode::Width))),
47 m_height( 48 m_height(
48 SVGAnimatedLength::create(this, 49 SVGAnimatedLength::create(this,
49 SVGNames::heightAttr, 50 SVGNames::heightAttr,
50 SVGLength::create(SVGLengthMode::Height))), 51 SVGLength::create(SVGLengthMode::Height))),
51 m_patternTransform( 52 m_patternTransform(
52 SVGAnimatedTransformList::create(this, 53 SVGAnimatedTransformList::create(this,
53 SVGNames::patternTransformAttr)), 54 SVGNames::patternTransformAttr,
55 CSSPropertyTransform)),
54 m_patternUnits(SVGAnimatedEnumeration<SVGUnitTypes::SVGUnitType>::create( 56 m_patternUnits(SVGAnimatedEnumeration<SVGUnitTypes::SVGUnitType>::create(
55 this, 57 this,
56 SVGNames::patternUnitsAttr, 58 SVGNames::patternUnitsAttr,
57 SVGUnitTypes::kSvgUnitTypeObjectboundingbox)), 59 SVGUnitTypes::kSvgUnitTypeObjectboundingbox)),
58 m_patternContentUnits( 60 m_patternContentUnits(
59 SVGAnimatedEnumeration<SVGUnitTypes::SVGUnitType>::create( 61 SVGAnimatedEnumeration<SVGUnitTypes::SVGUnitType>::create(
60 this, 62 this,
61 SVGNames::patternContentUnitsAttr, 63 SVGNames::patternContentUnitsAttr,
62 SVGUnitTypes::kSvgUnitTypeUserspaceonuse)) { 64 SVGUnitTypes::kSvgUnitTypeUserspaceonuse)) {
63 addToPropertyMap(m_x); 65 addToPropertyMap(m_x);
(...skipping 14 matching lines...) Expand all
78 visitor->trace(m_patternUnits); 80 visitor->trace(m_patternUnits);
79 visitor->trace(m_patternContentUnits); 81 visitor->trace(m_patternContentUnits);
80 SVGElement::trace(visitor); 82 SVGElement::trace(visitor);
81 SVGURIReference::trace(visitor); 83 SVGURIReference::trace(visitor);
82 SVGTests::trace(visitor); 84 SVGTests::trace(visitor);
83 SVGFitToViewBox::trace(visitor); 85 SVGFitToViewBox::trace(visitor);
84 } 86 }
85 87
86 DEFINE_NODE_FACTORY(SVGPatternElement) 88 DEFINE_NODE_FACTORY(SVGPatternElement)
87 89
90 void SVGPatternElement::collectStyleForPresentationAttribute(
91 const QualifiedName& name,
92 const AtomicString& value,
93 MutableStylePropertySet* style) {
94 if (name == SVGNames::patternTransformAttr) {
95 addPropertyToPresentationAttributeStyle(
96 style, CSSPropertyTransform,
97 m_patternTransform->currentValue()->cssValue());
98 return;
99 }
100 SVGElement::collectStyleForPresentationAttribute(name, value, style);
101 }
102
88 void SVGPatternElement::svgAttributeChanged(const QualifiedName& attrName) { 103 void SVGPatternElement::svgAttributeChanged(const QualifiedName& attrName) {
89 bool isLengthAttr = 104 bool isLengthAttr =
90 attrName == SVGNames::xAttr || attrName == SVGNames::yAttr || 105 attrName == SVGNames::xAttr || attrName == SVGNames::yAttr ||
91 attrName == SVGNames::widthAttr || attrName == SVGNames::heightAttr; 106 attrName == SVGNames::widthAttr || attrName == SVGNames::heightAttr;
92 107
108 if (attrName == SVGNames::patternTransformAttr) {
109 invalidateSVGPresentationAttributeStyle();
110 setNeedsStyleRecalc(LocalStyleChange,
111 StyleChangeReasonForTracing::fromAttribute(attrName));
112 }
113
93 if (isLengthAttr || attrName == SVGNames::patternUnitsAttr || 114 if (isLengthAttr || attrName == SVGNames::patternUnitsAttr ||
94 attrName == SVGNames::patternContentUnitsAttr || 115 attrName == SVGNames::patternContentUnitsAttr ||
95 attrName == SVGNames::patternTransformAttr || 116 attrName == SVGNames::patternTransformAttr ||
96 SVGFitToViewBox::isKnownAttribute(attrName) || 117 SVGFitToViewBox::isKnownAttribute(attrName) ||
97 SVGURIReference::isKnownAttribute(attrName) || 118 SVGURIReference::isKnownAttribute(attrName) ||
98 SVGTests::isKnownAttribute(attrName)) { 119 SVGTests::isKnownAttribute(attrName)) {
99 SVGElement::InvalidationGuard invalidationGuard(this); 120 SVGElement::InvalidationGuard invalidationGuard(this);
100 121
101 if (isLengthAttr) 122 if (isLengthAttr)
102 updateRelativeLengthsInformation(); 123 updateRelativeLengthsInformation();
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 if (!attributes.hasPatternUnits() && element->patternUnits()->isSpecified()) 174 if (!attributes.hasPatternUnits() && element->patternUnits()->isSpecified())
154 attributes.setPatternUnits( 175 attributes.setPatternUnits(
155 element->patternUnits()->currentValue()->enumValue()); 176 element->patternUnits()->currentValue()->enumValue());
156 177
157 if (!attributes.hasPatternContentUnits() && 178 if (!attributes.hasPatternContentUnits() &&
158 element->patternContentUnits()->isSpecified()) 179 element->patternContentUnits()->isSpecified())
159 attributes.setPatternContentUnits( 180 attributes.setPatternContentUnits(
160 element->patternContentUnits()->currentValue()->enumValue()); 181 element->patternContentUnits()->currentValue()->enumValue());
161 182
162 if (!attributes.hasPatternTransform() && 183 if (!attributes.hasPatternTransform() &&
163 element->patternTransform()->isSpecified()) { 184 element->hasTransform(SVGElement::ExcludeMotionTransform)) {
164 AffineTransform transform; 185 attributes.setPatternTransform(
165 element->patternTransform()->currentValue()->concatenate(transform); 186 element->calculateTransform(SVGElement::ExcludeMotionTransform));
166 attributes.setPatternTransform(transform);
167 } 187 }
168 188
169 if (!attributes.hasPatternContentElement() && 189 if (!attributes.hasPatternContentElement() &&
170 ElementTraversal::firstWithin(*element)) 190 ElementTraversal::firstWithin(*element))
171 attributes.setPatternContentElement(element); 191 attributes.setPatternContentElement(element);
172 } 192 }
173 193
174 void SVGPatternElement::collectPatternAttributes( 194 void SVGPatternElement::collectPatternAttributes(
175 PatternAttributes& attributes) const { 195 PatternAttributes& attributes) const {
176 HeapHashSet<Member<const SVGPatternElement>> processedPatterns; 196 HeapHashSet<Member<const SVGPatternElement>> processedPatterns;
(...skipping 14 matching lines...) Expand all
191 current = toSVGPatternElement(refNode); 211 current = toSVGPatternElement(refNode);
192 212
193 // Cycle detection 213 // Cycle detection
194 if (processedPatterns.contains(current)) 214 if (processedPatterns.contains(current))
195 break; 215 break;
196 } 216 }
197 } 217 }
198 218
199 AffineTransform SVGPatternElement::localCoordinateSpaceTransform( 219 AffineTransform SVGPatternElement::localCoordinateSpaceTransform(
200 SVGElement::CTMScope) const { 220 SVGElement::CTMScope) const {
201 AffineTransform matrix; 221 return calculateTransform(SVGElement::ExcludeMotionTransform);
202 m_patternTransform->currentValue()->concatenate(matrix);
203 return matrix;
204 } 222 }
205 223
206 bool SVGPatternElement::selfHasRelativeLengths() const { 224 bool SVGPatternElement::selfHasRelativeLengths() const {
207 return m_x->currentValue()->isRelative() || 225 return m_x->currentValue()->isRelative() ||
208 m_y->currentValue()->isRelative() || 226 m_y->currentValue()->isRelative() ||
209 m_width->currentValue()->isRelative() || 227 m_width->currentValue()->isRelative() ||
210 m_height->currentValue()->isRelative(); 228 m_height->currentValue()->isRelative();
211 } 229 }
212 230
213 } // namespace blink 231 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698