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

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

Issue 908243002: Move rendering/svg/RenderSVGResource* to layout/svg. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 10 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 | Annotate | Revision Log
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 *
11 * This library is distributed in the hope that it will be useful, 11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details. 14 * Library General Public License for more details.
15 * 15 *
16 * You should have received a copy of the GNU Library General Public License 16 * You should have received a copy of the GNU Library General Public License
17 * along with this library; see the file COPYING.LIB. If not, write to 17 * along with this library; see the file COPYING.LIB. If not, write to
18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 * Boston, MA 02110-1301, USA. 19 * Boston, MA 02110-1301, USA.
20 */ 20 */
21 21
22 #include "config.h" 22 #include "config.h"
23 #include "core/rendering/svg/RenderSVGResourceMarker.h" 23 #include "core/layout/svg/LayoutSVGResourceMarker.h"
24 24
25 #include "core/layout/svg/SVGLayoutSupport.h" 25 #include "core/layout/svg/SVGLayoutSupport.h"
26 #include "core/rendering/svg/RenderSVGContainer.h" 26 #include "core/rendering/svg/RenderSVGContainer.h"
27 #include "wtf/TemporaryChange.h" 27 #include "wtf/TemporaryChange.h"
28 28
29 namespace blink { 29 namespace blink {
30 30
31 RenderSVGResourceMarker::RenderSVGResourceMarker(SVGMarkerElement* node) 31 LayoutSVGResourceMarker::LayoutSVGResourceMarker(SVGMarkerElement* node)
32 : RenderSVGResourceContainer(node) 32 : LayoutSVGResourceContainer(node)
33 { 33 {
34 } 34 }
35 35
36 RenderSVGResourceMarker::~RenderSVGResourceMarker() 36 LayoutSVGResourceMarker::~LayoutSVGResourceMarker()
37 { 37 {
38 } 38 }
39 39
40 void RenderSVGResourceMarker::layout() 40 void LayoutSVGResourceMarker::layout()
41 { 41 {
42 ASSERT(needsLayout()); 42 ASSERT(needsLayout());
43 if (m_isInLayout) 43 if (m_isInLayout)
44 return; 44 return;
45 45
46 TemporaryChange<bool> inLayoutChange(m_isInLayout, true); 46 TemporaryChange<bool> inLayoutChange(m_isInLayout, true);
47 47
48 // RenderSVGHiddenContainer overwrites layout(). We need the 48 // RenderSVGHiddenContainer overwrites layout(). We need the
49 // layouting of RenderSVGContainer for calculating local 49 // layouting of RenderSVGContainer for calculating local
50 // transformations and paint invalidation. 50 // transformations and paint invalidation.
51 RenderSVGContainer::layout(); 51 RenderSVGContainer::layout();
52 52
53 clearInvalidationMask(); 53 clearInvalidationMask();
54 } 54 }
55 55
56 void RenderSVGResourceMarker::removeAllClientsFromCache(bool markForInvalidation ) 56 void LayoutSVGResourceMarker::removeAllClientsFromCache(bool markForInvalidation )
57 { 57 {
58 markAllClientsForInvalidation(markForInvalidation ? LayoutAndBoundariesInval idation : ParentOnlyInvalidation); 58 markAllClientsForInvalidation(markForInvalidation ? LayoutAndBoundariesInval idation : ParentOnlyInvalidation);
59 } 59 }
60 60
61 void RenderSVGResourceMarker::removeClientFromCache(LayoutObject* client, bool m arkForInvalidation) 61 void LayoutSVGResourceMarker::removeClientFromCache(LayoutObject* client, bool m arkForInvalidation)
62 { 62 {
63 ASSERT(client); 63 ASSERT(client);
64 markClientForInvalidation(client, markForInvalidation ? BoundariesInvalidati on : ParentOnlyInvalidation); 64 markClientForInvalidation(client, markForInvalidation ? BoundariesInvalidati on : ParentOnlyInvalidation);
65 } 65 }
66 66
67 FloatRect RenderSVGResourceMarker::markerBoundaries(const AffineTransform& marke rTransformation) const 67 FloatRect LayoutSVGResourceMarker::markerBoundaries(const AffineTransform& marke rTransformation) const
68 { 68 {
69 FloatRect coordinates = RenderSVGContainer::paintInvalidationRectInLocalCoor dinates(); 69 FloatRect coordinates = RenderSVGContainer::paintInvalidationRectInLocalCoor dinates();
70 70
71 // Map paint invalidation rect into parent coordinate space, in which the ma rker boundaries have to be evaluated 71 // Map paint invalidation rect into parent coordinate space, in which the ma rker boundaries have to be evaluated
72 coordinates = localToParentTransform().mapRect(coordinates); 72 coordinates = localToParentTransform().mapRect(coordinates);
73 73
74 return markerTransformation.mapRect(coordinates); 74 return markerTransformation.mapRect(coordinates);
75 } 75 }
76 76
77 const AffineTransform& RenderSVGResourceMarker::localToParentTransform() const 77 const AffineTransform& LayoutSVGResourceMarker::localToParentTransform() const
78 { 78 {
79 m_localToParentTransform = AffineTransform::translation(m_viewport.x(), m_vi ewport.y()) * viewportTransform(); 79 m_localToParentTransform = AffineTransform::translation(m_viewport.x(), m_vi ewport.y()) * viewportTransform();
80 return m_localToParentTransform; 80 return m_localToParentTransform;
81 // If this class were ever given a localTransform(), then the above would re ad: 81 // If this class were ever given a localTransform(), then the above would re ad:
82 // return viewportTranslation * localTransform() * viewportTransform(); 82 // return viewportTranslation * localTransform() * viewportTransform();
83 } 83 }
84 84
85 FloatPoint RenderSVGResourceMarker::referencePoint() const 85 FloatPoint LayoutSVGResourceMarker::referencePoint() const
86 { 86 {
87 SVGMarkerElement* marker = toSVGMarkerElement(element()); 87 SVGMarkerElement* marker = toSVGMarkerElement(element());
88 ASSERT(marker); 88 ASSERT(marker);
89 89
90 SVGLengthContext lengthContext(marker); 90 SVGLengthContext lengthContext(marker);
91 return FloatPoint(marker->refX()->currentValue()->value(lengthContext), mark er->refY()->currentValue()->value(lengthContext)); 91 return FloatPoint(marker->refX()->currentValue()->value(lengthContext), mark er->refY()->currentValue()->value(lengthContext));
92 } 92 }
93 93
94 float RenderSVGResourceMarker::angle() const 94 float LayoutSVGResourceMarker::angle() const
95 { 95 {
96 SVGMarkerElement* marker = toSVGMarkerElement(element()); 96 SVGMarkerElement* marker = toSVGMarkerElement(element());
97 ASSERT(marker); 97 ASSERT(marker);
98 98
99 float angle = -1; 99 float angle = -1;
100 if (marker->orientType()->currentValue()->enumValue() == SVGMarkerOrientAngl e) 100 if (marker->orientType()->currentValue()->enumValue() == SVGMarkerOrientAngl e)
101 angle = marker->orientAngle()->currentValue()->value(); 101 angle = marker->orientAngle()->currentValue()->value();
102 102
103 return angle; 103 return angle;
104 } 104 }
105 105
106 AffineTransform RenderSVGResourceMarker::markerTransformation(const FloatPoint& origin, float autoAngle, float strokeWidth) const 106 AffineTransform LayoutSVGResourceMarker::markerTransformation(const FloatPoint& origin, float autoAngle, float strokeWidth) const
107 { 107 {
108 SVGMarkerElement* marker = toSVGMarkerElement(element()); 108 SVGMarkerElement* marker = toSVGMarkerElement(element());
109 ASSERT(marker); 109 ASSERT(marker);
110 110
111 float markerAngle = angle(); 111 float markerAngle = angle();
112 bool useStrokeWidth = marker->markerUnits()->currentValue()->enumValue() == SVGMarkerUnitsStrokeWidth; 112 bool useStrokeWidth = marker->markerUnits()->currentValue()->enumValue() == SVGMarkerUnitsStrokeWidth;
113 113
114 AffineTransform transform; 114 AffineTransform transform;
115 transform.translate(origin.x(), origin.y()); 115 transform.translate(origin.x(), origin.y());
116 transform.rotate(markerAngle == -1 ? autoAngle : markerAngle); 116 transform.rotate(markerAngle == -1 ? autoAngle : markerAngle);
117 transform = markerContentTransformation(transform, referencePoint(), useStro keWidth ? strokeWidth : -1); 117 transform = markerContentTransformation(transform, referencePoint(), useStro keWidth ? strokeWidth : -1);
118 return transform; 118 return transform;
119 } 119 }
120 120
121 AffineTransform RenderSVGResourceMarker::markerContentTransformation(const Affin eTransform& contentTransformation, const FloatPoint& origin, float strokeWidth) const 121 AffineTransform LayoutSVGResourceMarker::markerContentTransformation(const Affin eTransform& contentTransformation, const FloatPoint& origin, float strokeWidth) const
122 { 122 {
123 // The 'origin' coordinate maps to SVGs refX/refY, given in coordinates rela tive to the viewport established by the marker 123 // The 'origin' coordinate maps to SVGs refX/refY, given in coordinates rela tive to the viewport established by the marker
124 FloatPoint mappedOrigin = viewportTransform().mapPoint(origin); 124 FloatPoint mappedOrigin = viewportTransform().mapPoint(origin);
125 125
126 AffineTransform transformation = contentTransformation; 126 AffineTransform transformation = contentTransformation;
127 if (strokeWidth != -1) 127 if (strokeWidth != -1)
128 transformation.scaleNonUniform(strokeWidth, strokeWidth); 128 transformation.scaleNonUniform(strokeWidth, strokeWidth);
129 129
130 transformation.translate(-mappedOrigin.x(), -mappedOrigin.y()); 130 transformation.translate(-mappedOrigin.x(), -mappedOrigin.y());
131 return transformation; 131 return transformation;
132 } 132 }
133 133
134 AffineTransform RenderSVGResourceMarker::viewportTransform() const 134 AffineTransform LayoutSVGResourceMarker::viewportTransform() const
135 { 135 {
136 SVGMarkerElement* marker = toSVGMarkerElement(element()); 136 SVGMarkerElement* marker = toSVGMarkerElement(element());
137 ASSERT(marker); 137 ASSERT(marker);
138 138
139 return marker->viewBoxToViewTransform(m_viewport.width(), m_viewport.height( )); 139 return marker->viewBoxToViewTransform(m_viewport.width(), m_viewport.height( ));
140 } 140 }
141 141
142 void RenderSVGResourceMarker::calcViewport() 142 void LayoutSVGResourceMarker::calcViewport()
143 { 143 {
144 if (!selfNeedsLayout()) 144 if (!selfNeedsLayout())
145 return; 145 return;
146 146
147 SVGMarkerElement* marker = toSVGMarkerElement(element()); 147 SVGMarkerElement* marker = toSVGMarkerElement(element());
148 ASSERT(marker); 148 ASSERT(marker);
149 149
150 SVGLengthContext lengthContext(marker); 150 SVGLengthContext lengthContext(marker);
151 float w = marker->markerWidth()->currentValue()->value(lengthContext); 151 float w = marker->markerWidth()->currentValue()->value(lengthContext);
152 float h = marker->markerHeight()->currentValue()->value(lengthContext); 152 float h = marker->markerHeight()->currentValue()->value(lengthContext);
153 m_viewport = FloatRect(0, 0, w, h); 153 m_viewport = FloatRect(0, 0, w, h);
154 } 154 }
155 155
156 } 156 }
OLDNEW
« no previous file with comments | « Source/core/layout/svg/LayoutSVGResourceMarker.h ('k') | Source/core/layout/svg/LayoutSVGResourceMasker.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698