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

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

Issue 1916173003: Don't use a magic value for 'auto' oriented <marker>s (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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) 2004, 2005, 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org> 2 * Copyright (C) 2004, 2005, 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org>
3 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Rob Buis <buis@kde.org> 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Rob Buis <buis@kde.org>
4 * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved. 4 * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved.
5 * 5 *
6 * This library is free software; you can redistribute it and/or 6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public 7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either 8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version. 9 * version 2 of the License, or (at your option) any later version.
10 * 10 *
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 { 83 {
84 SVGMarkerElement* marker = toSVGMarkerElement(element()); 84 SVGMarkerElement* marker = toSVGMarkerElement(element());
85 ASSERT(marker); 85 ASSERT(marker);
86 86
87 SVGLengthContext lengthContext(marker); 87 SVGLengthContext lengthContext(marker);
88 return FloatPoint(marker->refX()->currentValue()->value(lengthContext), mark er->refY()->currentValue()->value(lengthContext)); 88 return FloatPoint(marker->refX()->currentValue()->value(lengthContext), mark er->refY()->currentValue()->value(lengthContext));
89 } 89 }
90 90
91 float LayoutSVGResourceMarker::angle() const 91 float LayoutSVGResourceMarker::angle() const
92 { 92 {
93 ASSERT(element()); 93 return toSVGMarkerElement(element())->orientAngle()->currentValue()->value() ;
94
95 float angle = -1;
96 if (orientType() == SVGMarkerOrientAngle)
97 angle = toSVGMarkerElement(*element()).orientAngle()->currentValue()->va lue();
98
99 return angle;
100 } 94 }
101 95
102 SVGMarkerUnitsType LayoutSVGResourceMarker::markerUnits() const 96 SVGMarkerUnitsType LayoutSVGResourceMarker::markerUnits() const
103 { 97 {
104 return toSVGMarkerElement(element())->markerUnits()->currentValue()->enumVal ue(); 98 return toSVGMarkerElement(element())->markerUnits()->currentValue()->enumVal ue();
105 } 99 }
106 100
107 SVGMarkerOrientType LayoutSVGResourceMarker::orientType() const 101 SVGMarkerOrientType LayoutSVGResourceMarker::orientType() const
108 { 102 {
109 return toSVGMarkerElement(element())->orientType()->currentValue()->enumValu e(); 103 return toSVGMarkerElement(element())->orientType()->currentValue()->enumValu e();
110 } 104 }
111 105
112 AffineTransform LayoutSVGResourceMarker::markerTransformation(const FloatPoint& origin, float autoAngle, float strokeWidth) const 106 AffineTransform LayoutSVGResourceMarker::markerTransformation(const FloatPoint& origin, float autoAngle, float strokeWidth) const
113 { 107 {
114 float markerAngle = angle();
115 bool useStrokeWidth = markerUnits() == SVGMarkerUnitsStrokeWidth; 108 bool useStrokeWidth = markerUnits() == SVGMarkerUnitsStrokeWidth;
116 109
117 AffineTransform transform; 110 AffineTransform transform;
118 transform.translate(origin.x(), origin.y()); 111 transform.translate(origin.x(), origin.y());
119 transform.rotate(markerAngle == -1 ? autoAngle : markerAngle); 112 transform.rotate(orientType() == SVGMarkerOrientAngle ? angle() : autoAngle) ;
120 transform = markerContentTransformation(transform, referencePoint(), useStro keWidth ? strokeWidth : -1); 113 transform = markerContentTransformation(transform, referencePoint(), useStro keWidth ? strokeWidth : -1);
121 return transform; 114 return transform;
122 } 115 }
123 116
124 AffineTransform LayoutSVGResourceMarker::markerContentTransformation(const Affin eTransform& contentTransformation, const FloatPoint& origin, float strokeWidth) const 117 AffineTransform LayoutSVGResourceMarker::markerContentTransformation(const Affin eTransform& contentTransformation, const FloatPoint& origin, float strokeWidth) const
125 { 118 {
126 // The 'origin' coordinate maps to SVGs refX/refY, given in coordinates rela tive to the viewport established by the marker 119 // The 'origin' coordinate maps to SVGs refX/refY, given in coordinates rela tive to the viewport established by the marker
127 FloatPoint mappedOrigin = viewportTransform().mapPoint(origin); 120 FloatPoint mappedOrigin = viewportTransform().mapPoint(origin);
128 121
129 AffineTransform transformation = contentTransformation; 122 AffineTransform transformation = contentTransformation;
(...skipping 28 matching lines...) Expand all
158 151
159 bool LayoutSVGResourceMarker::calculateLocalTransform() 152 bool LayoutSVGResourceMarker::calculateLocalTransform()
160 { 153 {
161 // TODO(fs): Temporarily, needing a layout implies that the local transform 154 // TODO(fs): Temporarily, needing a layout implies that the local transform
162 // has changed. This should be updated to be more precise and factor in the 155 // has changed. This should be updated to be more precise and factor in the
163 // actual (relevant) changes to the computed user-space transform. 156 // actual (relevant) changes to the computed user-space transform.
164 return selfNeedsLayout(); 157 return selfNeedsLayout();
165 } 158 }
166 159
167 } // namespace blink 160 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698