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

Side by Side Diff: Source/core/svg/GradientAttributes.h

Issue 423093014: [SVG2] Make transform, gradientTransform and patternTransform presentation attributes. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: transform attr syntax should match property, with minor quirks Created 6 years, 4 months 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) 2006 Nikolas Zimmermann <zimmermann@kde.org> 2 * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.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
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 m_spreadMethod = value; 45 m_spreadMethod = value;
46 m_spreadMethodSet = true; 46 m_spreadMethodSet = true;
47 } 47 }
48 48
49 void setGradientUnits(SVGUnitTypes::SVGUnitType unitType) 49 void setGradientUnits(SVGUnitTypes::SVGUnitType unitType)
50 { 50 {
51 m_gradientUnits = unitType; 51 m_gradientUnits = unitType;
52 m_gradientUnitsSet = true; 52 m_gradientUnitsSet = true;
53 } 53 }
54 54
55 void setGradientTransformFromStyle(SVGGradientElement* element)
56 {
57 AffineTransform transform;
58 RenderStyle* style = element->renderer() ? element->renderer()->style() : 0;
59
60 // If CSS property was set, use that, otherwise fallback to attribute (i f set).
61 if (style && style->hasTransform()) {
62 TransformationMatrix matrix;
63 float zoom = style->effectiveZoom();
64
65 // CSS transforms operate with pre-scaled lengths. To make this work with SVG
pdr. 2014/08/01 22:43:10 This logic is all duplicated from SVGGraphicsEleme
Erik Dahlström (inactive) 2014/08/04 13:57:57 Yes, who likes duplicated code, right? :) I'll see
66 // (which applies the zoom factor globally, at the root level) we
67 //
68 // * pre-scale the bounding box (to bring it into the same space a s the other CSS values)
69 // * invert the zoom factor (to effectively compute the CSS transf orm under a 1.0 zoom)
70 //
71 // Note: objectBoundingBox is an emptyRect for elements like pattern or clipPath.
72 // See the "Object bounding box units" section of http://dev.w3.org/ csswg/css3-transforms/
73 if (zoom != 1) {
74 FloatRect scaledBBox = element->renderer()->objectBoundingBox();
75 scaledBBox.scale(zoom);
76 transform.scale(1 / zoom);
77 style->applyTransform(matrix, scaledBBox);
78 matrix.scale(zoom);
79 } else {
80 style->applyTransform(matrix, element->renderer()->objectBoundin gBox());
81 }
82
83 // Flatten any 3D transform.
84 transform = matrix.toAffineTransform();
85 } else if (element->gradientTransform()->isSpecified()) {
86 element->gradientTransform()->currentValue()->concatenate(transform) ;
87 }
88
89 if (!transform.isIdentity())
pdr. 2014/08/01 22:43:10 Is this check needed?
Erik Dahlström (inactive) 2014/08/04 13:57:57 Technically no, since it won't make any visible di
90 setGradientTransform(transform);
91 }
92
55 void setGradientTransform(const AffineTransform& value) 93 void setGradientTransform(const AffineTransform& value)
56 { 94 {
57 m_gradientTransform = value; 95 m_gradientTransform = value;
58 m_gradientTransformSet = true; 96 m_gradientTransformSet = true;
59 } 97 }
60 98
61 void setStops(const Vector<Gradient::ColorStop>& value) 99 void setStops(const Vector<Gradient::ColorStop>& value)
62 { 100 {
63 m_stops = value; 101 m_stops = value;
64 m_stopsSet = true; 102 m_stopsSet = true;
(...skipping 23 matching lines...) Expand all
88 AffineTransform a; 126 AffineTransform a;
89 Vector<Gradient::ColorStop> b; 127 Vector<Gradient::ColorStop> b;
90 unsigned c : 8; 128 unsigned c : 8;
91 }; 129 };
92 130
93 COMPILE_ASSERT(sizeof(GradientAttributes) == sizeof(SameSizeAsGradientAttributes ), GradientAttributes_size_guard); 131 COMPILE_ASSERT(sizeof(GradientAttributes) == sizeof(SameSizeAsGradientAttributes ), GradientAttributes_size_guard);
94 132
95 } // namespace blink 133 } // namespace blink
96 134
97 #endif 135 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698