ChangeLog

 12007-06-06 Eric Seidel <eric@webkit.org>
 2
 3 Reviewed by NOBODY (OOPS!).
 4
 5 Break out common SVG rendering logic into prepareToRenderSVGContent in SVGRenderSupport
 6
 7 No test cases should be changed by this.
 8
 9 * WebCore.xcodeproj/project.pbxproj:
 10 * rendering/RenderPath.cpp:
 11 (WebCore::fillAndStrokePath):
 12 (WebCore::RenderPath::paint):
 13 * rendering/RenderSVGContainer.cpp:
 14 (WebCore::RenderSVGContainer::RenderSVGContainer):
 15 (WebCore::RenderSVGContainer::requiresLayer):
 16 (WebCore::RenderSVGContainer::isOutermostSVG):
 17 (WebCore::RenderSVGContainer::layout):
 18 (WebCore::RenderSVGContainer::applyContentTransforms):
 19 (WebCore::RenderSVGContainer::paint):
 20 (WebCore::RenderSVGContainer::viewportTransform):
 21 (WebCore::RenderSVGContainer::absoluteTransform):
 22 * rendering/RenderSVGContainer.h:
 23 * rendering/RenderSVGImage.cpp:
 24 (WebCore::RenderSVGImage::paint):
 25 (WebCore::RenderSVGImage::translationForAttributes):
 26 * rendering/SVGRenderSupport.cpp: Added.
 27 (WebCore::prepareToRenderSVGContent):
 28 * rendering/SVGRenderSupport.h: Added.
 29 * rendering/SVGRootInlineBox.cpp:
 30 (WebCore::prepareTextRendering):
 31 (WebCore::SVGRootInlineBox::paint):
 32 (WebCore::SVGRootInlineBox::paintInlineBoxes):
 33
1342007-06-06 Rob Buis <buis@kde.org>
235
336 Reviewed by olliej and eric.
22024

WebCore.xcodeproj/project.pbxproj

22502250 A8EA800C0A19516E00A8EF5F /* StyleSheet.h in Headers */ = {isa = PBXBuildFile; fileRef = A8EA80040A19516E00A8EF5F /* StyleSheet.h */; };
22512251 A8EA800D0A19516E00A8EF5F /* StyleSheet.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A8EA80050A19516E00A8EF5F /* StyleSheet.cpp */; };
22522252 A8EA800E0A19516E00A8EF5F /* MediaList.h in Headers */ = {isa = PBXBuildFile; fileRef = A8EA80060A19516E00A8EF5F /* MediaList.h */; };
 2253 A8F4FB940C169E7B002AFED5 /* SVGRenderSupport.h in Headers */ = {isa = PBXBuildFile; fileRef = A8F4FB930C169E7B002AFED5 /* SVGRenderSupport.h */; };
 2254 A8F4FB960C169E85002AFED5 /* SVGRenderSupport.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A8F4FB950C169E85002AFED5 /* SVGRenderSupport.cpp */; };
22532255 A8FEFB310979F4F6005839FD /* SVGForeignObjectElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A8FEFB2F0979F4F6005839FD /* SVGForeignObjectElement.cpp */; };
22542256 A8FEFB320979F4F6005839FD /* SVGForeignObjectElement.h in Headers */ = {isa = PBXBuildFile; fileRef = A8FEFB300979F4F6005839FD /* SVGForeignObjectElement.h */; };
22552257 AA0972CC0B6947A800A705E9 /* SVGInlineTextBox.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AA0972CA0B6947A800A705E9 /* SVGInlineTextBox.cpp */; };

53425344 A8EA80040A19516E00A8EF5F /* StyleSheet.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = StyleSheet.h; sourceTree = "<group>"; };
53435345 A8EA80050A19516E00A8EF5F /* StyleSheet.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = StyleSheet.cpp; sourceTree = "<group>"; };
53445346 A8EA80060A19516E00A8EF5F /* MediaList.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = MediaList.h; sourceTree = "<group>"; };
 5347 A8F4FB930C169E7B002AFED5 /* SVGRenderSupport.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGRenderSupport.h; sourceTree = "<group>"; };
 5348 A8F4FB950C169E85002AFED5 /* SVGRenderSupport.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SVGRenderSupport.cpp; sourceTree = "<group>"; };
53455349 A8FEFB2F0979F4F6005839FD /* SVGForeignObjectElement.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = SVGForeignObjectElement.cpp; sourceTree = "<group>"; };
53465350 A8FEFB300979F4F6005839FD /* SVGForeignObjectElement.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = SVGForeignObjectElement.h; sourceTree = "<group>"; };
53475351 AA0972CA0B6947A800A705E9 /* SVGInlineTextBox.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = SVGInlineTextBox.cpp; sourceTree = "<group>"; };

96269630 853CA9E30AEEC608002372DC /* SVGInlineFlowBox.h */,
96279631 AA0972CA0B6947A800A705E9 /* SVGInlineTextBox.cpp */,
96289632 AA0972CB0B6947A800A705E9 /* SVGInlineTextBox.h */,
 9633 A8F4FB950C169E85002AFED5 /* SVGRenderSupport.cpp */,
 9634 A8F4FB930C169E7B002AFED5 /* SVGRenderSupport.h */,
96299635 B2EBDC9A0AF77E3400AE4A68 /* SVGRenderTreeAsText.cpp */,
96309636 B2EBDC9B0AF77E3400AE4A68 /* SVGRenderTreeAsText.h */,
96319637 853CA9E40AEEC608002372DC /* SVGRootInlineBox.cpp */,

1129311299 E1EC29A00BB04C6B00EA187B /* XPathNodeSet.h in Headers */,
1129411300 2D9066070BE141D400956998 /* LayoutState.h in Headers */,
1129511301 14C9A29A0BF04DB600D734A8 /* WebScriptObjectPendingPublic.h in Headers */,
 11302 A8F4FB940C169E7B002AFED5 /* SVGRenderSupport.h in Headers */,
1129611303 );
1129711304 runOnlyForDeploymentPostprocessing = 0;
1129811305 };

1266912676 2D9066060BE141D400956998 /* LayoutState.cpp in Sources */,
1267012677 4A8C96EB0BE69032004EEFF0 /* SelectionControllerMac.mm in Sources */,
1267112678 AACF144D0BEC1EF000827982 /* TextBreakIteratorInternalICUMac.mm in Sources */,
 12679 A8F4FB960C169E85002AFED5 /* SVGRenderSupport.cpp in Sources */,
1267212680 );
1267312681 runOnlyForDeploymentPostprocessing = 0;
1267412682 };
21978

rendering/RenderPath.cpp

3333#include "RenderSVGContainer.h"
3434#include "PointerEventsHitRules.h"
3535#include "SVGPaintServer.h"
36 #include "SVGResourceClipper.h"
 36#include "SVGRenderSupport.h"
3737#include "SVGResourceFilter.h"
38 #include "SVGResourceMasker.h"
3938#include "SVGResourceMarker.h"
4039#include "SVGStyledElement.h"
4140#include "SVGURIReference.h"

@@short RenderPath::baselinePosition(bool
174173 return static_cast<short>(relativeBBox(true).height());
175174}
176175
 176static inline void fillAndStrokePath(const Path& path, GraphicsContext* context, RenderStyle* style, RenderPath* object)
 177{
 178 context->beginPath();
 179
 180 SVGPaintServer* fillPaintServer = KSVGPainterFactory::fillPaintServer(style, object);
 181 if (fillPaintServer) {
 182 context->addPath(path);
 183 fillPaintServer->draw(context, object, ApplyToFillTargetType);
 184 }
 185
 186 SVGPaintServer* strokePaintServer = KSVGPainterFactory::strokePaintServer(style, object);
 187 if (strokePaintServer) {
 188 context->addPath(path); // path is cleared when filled.
 189 strokePaintServer->draw(context, object, ApplyToStrokeTargetType);
 190 }
 191}
 192
177193void RenderPath::paint(PaintInfo& paintInfo, int, int)
178194{
179195 if (paintInfo.context->paintingDisabled() || (paintInfo.phase != PaintPhaseForeground) || style()->visibility() == HIDDEN || m_path.isEmpty())
180196 return;
181 
 197
182198 paintInfo.context->save();
183199 paintInfo.context->concatCTM(localTransform());
184200
185  FloatRect strokeBBox = relativeBBox(true);
186 
187  SVGElement* svgElement = static_cast<SVGElement*>(element());
188  ASSERT(svgElement && svgElement->document() && svgElement->isStyled());
189 
190  SVGStyledElement* styledElement = static_cast<SVGStyledElement*>(svgElement);
191  const SVGRenderStyle* svgStyle = style()->svgStyle();
192 
193  AtomicString filterId(SVGURIReference::getTarget(svgStyle->filter()));
194  AtomicString clipperId(SVGURIReference::getTarget(svgStyle->clipPath()));
195  AtomicString maskerId(SVGURIReference::getTarget(svgStyle->maskElement()));
196 
197 #if ENABLE(SVG_EXPERIMENTAL_FEATURES)
198  SVGResourceFilter* filter = getFilterById(document(), filterId);
199 #endif
200  SVGResourceClipper* clipper = getClipperById(document(), clipperId);
201  SVGResourceMasker* masker = getMaskerById(document(), maskerId);
202 
203201#if ENABLE(SVG_EXPERIMENTAL_FEATURES)
204  if (filter)
205  filter->prepareFilter(paintInfo.context, strokeBBox);
206  else if (!filterId.isEmpty())
207  svgElement->document()->accessSVGExtensions()->addPendingResource(filterId, styledElement);
 202 SVGResourceFilter* filter = 0;
 203#else
 204 void* filter = 0;
208205#endif
 206 FloatRect boundingBox = relativeBBox(true);
 207 prepareToRenderSVGContent(this, paintInfo, boundingBox, filter);
 208
 209 fillAndStrokePath(m_path, paintInfo.context, style(), this);
209210
210  if (clipper) {
211  clipper->addClient(styledElement);
212  clipper->applyClip(paintInfo.context, strokeBBox);
213  } else if (!clipperId.isEmpty())
214  svgElement->document()->accessSVGExtensions()->addPendingResource(clipperId, styledElement);
215 
216  if (masker) {
217  masker->addClient(styledElement);
218  masker->applyMask(paintInfo.context, strokeBBox);
219  } else if (!maskerId.isEmpty())
220  svgElement->document()->accessSVGExtensions()->addPendingResource(maskerId, styledElement);
221 
222  paintInfo.context->beginPath();
223 
224  SVGPaintServer* fillPaintServer = KSVGPainterFactory::fillPaintServer(style(), this);
225  if (fillPaintServer) {
226  paintInfo.context->addPath(m_path);
227  fillPaintServer->draw(paintInfo.context, this, ApplyToFillTargetType);
228  }
229 
230  SVGPaintServer* strokePaintServer = KSVGPainterFactory::strokePaintServer(style(), this);
231  if (strokePaintServer) {
232  paintInfo.context->addPath(m_path); // path is cleared when filled.
233  strokePaintServer->draw(paintInfo.context, this, ApplyToStrokeTargetType);
234  }
235 
236  if (styledElement->supportsMarkers())
 211 if (static_cast<SVGStyledElement*>(element())->supportsMarkers())
237212 m_markerBounds = drawMarkersIfNeeded(paintInfo.context, paintInfo.rect, m_path);
238213
239214#if ENABLE(SVG_EXPERIMENTAL_FEATURES)
240  // actually apply the filter
241215 if (filter)
242  filter->applyFilter(paintInfo.context, strokeBBox);
 216 filter->applyFilter(paintInfo.context, boundingBox);
243217#endif
244218
245219 paintInfo.context->restore();
21978

rendering/RenderSVGContainer.cpp

3030#include "RenderView.h"
3131#include "SVGLength.h"
3232#include "SVGMarkerElement.h"
 33#include "SVGRenderSupport.h"
3334#include "SVGResourceClipper.h"
3435#include "SVGResourceFilter.h"
3536#include "SVGResourceMasker.h"

3940
4041namespace WebCore {
4142
42 RenderSVGContainer::RenderSVGContainer(SVGStyledElement *node)
 43RenderSVGContainer::RenderSVGContainer(SVGStyledElement* node)
4344 : RenderContainer(node)
4445 , m_drawsContents(true)
4546 , m_slice(false)

@@void RenderSVGContainer::setLocalTransfo
7475bool RenderSVGContainer::requiresLayer()
7576{
7677 // Only allow an <svg> element to generate a layer when it's positioned in a non-SVG context
77  return (isPositioned() || isRelPositioned()) && (element()->parent() && !element()->parent()->isSVGElement());
 78 return (isPositioned() || isRelPositioned()) && isOutermostSVG();
7879}
7980
8081short RenderSVGContainer::lineHeight(bool b, bool isRootLineBox) const

@@short RenderSVGContainer::baselinePositi
8788 return height() + marginTop() + marginBottom();
8889}
8990
 91// This method should be temporary until a RenderSVGRoot class can be made
 92// http://bugs.webkit.org/show_bug.cgi?id=12207
 93bool RenderSVGContainer::isOutermostSVG() const
 94{
 95 return !parent()->isSVGContainer();
 96}
 97
9098void RenderSVGContainer::layout()
9199{
92100 ASSERT(needsLayout());

@@void RenderSVGContainer::layout()
106114
107115 RenderObject* child = firstChild();
108116 while (child) {
 117 // FIXME: This check is bogus, see http://bugs.webkit.org/show_bug.cgi?id=14003
109118 if (!child->isRenderPath() || static_cast<RenderPath*>(child)->hasRelativeValues())
110119 child->setNeedsLayout(true);
111120

@@void RenderSVGContainer::layout()
118127 calcHeight();
119128
120129 m_absoluteBounds = absoluteClippedOverflowRect();
121  if (!parent()->isSVGContainer()) {
 130 if (isOutermostSVG()) {
122131 SVGSVGElement* svg = static_cast<SVGSVGElement*>(element());
123132 m_width = m_width * svg->currentScale();
124133 m_height = m_height * svg->currentScale();

@@void RenderSVGContainer::layout()
131140 setNeedsLayout(false);
132141}
133142
134 void RenderSVGContainer::paint(PaintInfo& paintInfo, int parentX, int parentY)
 143void RenderSVGContainer::applyContentTransforms(PaintInfo& paintInfo, int& parentX, int& parentY)
135144{
136  if (paintInfo.context->paintingDisabled())
137  return;
138 
139  // This should only exist for <svg> renderers
140  if (hasBoxDecorations() && (paintInfo.phase == PaintPhaseForeground || paintInfo.phase == PaintPhaseSelection))
141  paintBoxDecorations(paintInfo, m_x + parentX, m_y + parentY);
142 
143  if ((paintInfo.phase == PaintPhaseOutline || paintInfo.phase == PaintPhaseSelfOutline) && style()->outlineWidth() && style()->visibility() == VISIBLE)
144  paintOutline(paintInfo.context, parentX, parentY, width(), height(), style());
145 
146  if (paintInfo.phase != PaintPhaseForeground || !drawsContents())
147  return;
148 
149  const SVGRenderStyle* svgStyle = style()->svgStyle();
150  AtomicString filterId(SVGURIReference::getTarget(svgStyle->filter()));
151 
152 #if ENABLE(SVG_EXPERIMENTAL_FEATURES)
153  SVGResourceFilter* filter = getFilterById(document(), filterId);
154 #endif
155 
156  if (!firstChild()
157 #if ENABLE(SVG_EXPERIMENTAL_FEATURES)
158  && !filter
159 #endif
160  )
161  return; // Spec: groups w/o children still may render filter content.
162 
163  paintInfo.context->save();
164 
165  if (!parent()->isSVGContainer()) {
 145 if (isOutermostSVG()) {
166146 // Translate from parent offsets (html renderers) to a relative transform (svg renderers)
167147 IntPoint origin;
168148 origin.move(parentX, parentY);

@@void RenderSVGContainer::paint(PaintInfo
184164 ASSERT(m_x == 0);
185165 ASSERT(m_y == 0);
186166 }
187 
 167
188168 if (!viewport().isEmpty()) {
189169 if (style()->overflowX() != OVISIBLE)
190170 paintInfo.context->clip(enclosingIntRect(viewport())); // FIXME: Eventually we'll want float-precision clipping
191 
 171
192172 paintInfo.context->concatCTM(AffineTransform().translate(viewport().x(), viewport().y()));
193173 }
194174 if (!localTransform().isIdentity())
195175 paintInfo.context->concatCTM(localTransform());
196  if (!parent()->isSVGContainer()) {
 176 if (isOutermostSVG()) {
197177 SVGSVGElement* svg = static_cast<SVGSVGElement*>(element());
198178 paintInfo.context->concatCTM(AffineTransform().translate(svg->currentTranslate().x(), svg->currentTranslate().y()));
199179 }
 180}
200181
201  FloatRect strokeBBox = relativeBBox(true);
 182void RenderSVGContainer::paint(PaintInfo& paintInfo, int parentX, int parentY)
 183{
 184 if (paintInfo.context->paintingDisabled())
 185 return;
202186
203  SVGElement* svgElement = static_cast<SVGElement*>(element());
204  ASSERT(svgElement && svgElement->document() && svgElement->isStyled());
 187 // This should only exist for <svg> renderers
 188 if (isOutermostSVG() && hasBoxDecorations() && (paintInfo.phase == PaintPhaseForeground || paintInfo.phase == PaintPhaseSelection))
 189 paintBoxDecorations(paintInfo, m_x + parentX, m_y + parentY);
205190
206  SVGStyledElement* styledElement = static_cast<SVGStyledElement*>(svgElement);
207 
208  AtomicString clipperId(SVGURIReference::getTarget(svgStyle->clipPath()));
209  AtomicString maskerId(SVGURIReference::getTarget(svgStyle->maskElement()));
210 
211  SVGResourceClipper* clipper = getClipperById(document(), clipperId);
212  SVGResourceMasker* masker = getMaskerById(document(), maskerId);
213 
214  if (clipper) {
215  clipper->addClient(styledElement);
216  clipper->applyClip(paintInfo.context, strokeBBox);
217  } else if (!clipperId.isEmpty())
218  svgElement->document()->accessSVGExtensions()->addPendingResource(clipperId, styledElement);
219 
220  if (masker) {
221  masker->addClient(styledElement);
222  masker->applyMask(paintInfo.context, strokeBBox);
223  } else if (!maskerId.isEmpty())
224  svgElement->document()->accessSVGExtensions()->addPendingResource(maskerId, styledElement);
 191 if ((paintInfo.phase == PaintPhaseOutline || paintInfo.phase == PaintPhaseSelfOutline) && style()->outlineWidth() && style()->visibility() == VISIBLE)
 192 paintOutline(paintInfo.context, parentX, parentY, width(), height(), style());
 193
 194 if (paintInfo.phase != PaintPhaseForeground || !drawsContents())
 195 return;
225196
226  float opacity = style()->opacity();
227  if (opacity < 1.0f) {
228  paintInfo.context->clip(enclosingIntRect(strokeBBox));
229  paintInfo.context->beginTransparencyLayer(opacity);
 197 if (!firstChild()) {
 198#if ENABLE(SVG_EXPERIMENTAL_FEATURES)
 199 // Spec: groups w/o children still may render filter content.
 200 const SVGRenderStyle* svgStyle = style()->svgStyle();
 201 AtomicString filterId(SVGURIReference::getTarget(svgStyle->filter()));
 202 SVGResourceFilter* filter = getFilterById(document(), filterId);
 203 if (!filter)
 204#endif
 205 return;
230206 }
 207
 208 paintInfo.context->save();
 209
 210 applyContentTransforms(paintInfo, parentX, parentY);
231211
232212#if ENABLE(SVG_EXPERIMENTAL_FEATURES)
233  if (filter)
234  filter->prepareFilter(paintInfo.context, strokeBBox);
235  else if (!filterId.isEmpty())
236  svgElement->document()->accessSVGExtensions()->addPendingResource(filterId, styledElement);
 213 SVGResourceFilter* filter = 0;
 214#else
 215 void* filter = 0;
237216#endif
 217 FloatRect boundingBox = relativeBBox(true);
 218 prepareToRenderSVGContent(this, paintInfo, boundingBox, filter);
 219
 220 float opacity = style()->opacity();
 221 if (opacity < 1.0f) {
 222 paintInfo.context->clip(enclosingIntRect(boundingBox));
 223 paintInfo.context->beginTransparencyLayer(opacity);
 224 }
238225
239226 if (!viewBox().isEmpty())
240227 paintInfo.context->concatCTM(viewportTransform());

@@void RenderSVGContainer::paint(PaintInfo
243230
244231#if ENABLE(SVG_EXPERIMENTAL_FEATURES)
245232 if (filter)
246  filter->applyFilter(paintInfo.context, strokeBBox);
 233 filter->applyFilter(paintInfo.context, boundingBox);
247234#endif
248235
249236 if (opacity < 1.0f)

@@AffineTransform RenderSVGContainer::view
314301 // fixing bug 12207.
315302 if (!viewBox().isEmpty()) {
316303 FloatRect viewportRect = viewport();
317  if (!parent()->isSVGContainer())
 304 if (isOutermostSVG())
318305 viewportRect = FloatRect(viewport().x(), viewport().y(), width(), height());
319306
320307 return getAspectRatio(viewBox(), viewportRect);

@@void RenderSVGContainer::absoluteRects(V
348335AffineTransform RenderSVGContainer::absoluteTransform() const
349336{
350337 AffineTransform ctm = RenderContainer::absoluteTransform();
351  if (!parent()->isSVGContainer()) {
 338 if (isOutermostSVG()) {
352339 SVGSVGElement* svg = static_cast<SVGSVGElement*>(element());
353340 ctm.scale(svg->currentScale());
354341 ctm.translate(svg->currentTranslate().x(), svg->currentTranslate().y());
21978

rendering/RenderSVGContainer.h

@@public:
9292 AffineTransform viewportTransform() const;
9393
9494 virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, int x, int y, int tx, int ty, HitTestAction);
 95
 96 bool isOutermostSVG() const;
9597
9698private:
9799 void calcViewport();
98100 AffineTransform getAspectRatio(const FloatRect& logical, const FloatRect& physical) const;
 101 void applyContentTransforms(PaintInfo&, int& parentX, int& parentY);
99102
100103 bool m_drawsContents : 1;
101104 bool m_slice : 1;
21978

rendering/RenderSVGImage.cpp

3333#include "SVGResourceFilter.h"
3434#include "SVGResourceMasker.h"
3535#include "SVGLength.h"
 36#include "SVGRenderSupport.h"
3637#include "SVGPreserveAspectRatio.h"
3738#include "SVGImageElement.h"
38 #include "SVGImageElement.h"
3939
4040namespace WebCore {
4141

@@void RenderSVGImage::paint(PaintInfo& pa
132132 paintInfo.context->concatCTM(AffineTransform().translate(parentX, parentY));
133133 paintInfo.context->concatCTM(localTransform());
134134 paintInfo.context->concatCTM(translationForAttributes());
135 
136  FloatRect boundingBox = FloatRect(0, 0, width(), height());
137 
138  SVGElement* svgElement = static_cast<SVGElement*>(element());
139  ASSERT(svgElement && svgElement->document() && svgElement->isStyled());
140 
141  SVGStyledElement* styledElement = static_cast<SVGStyledElement*>(svgElement);
142  const SVGRenderStyle* svgStyle = style()->svgStyle();
143 
144  AtomicString filterId(SVGURIReference::getTarget(svgStyle->filter()));
145  AtomicString clipperId(SVGURIReference::getTarget(svgStyle->clipPath()));
146  AtomicString maskerId(SVGURIReference::getTarget(svgStyle->maskElement()));
147 
148 #if ENABLE(SVG_EXPERIMENTAL_FEATURES)
149  SVGResourceFilter* filter = getFilterById(document(), filterId);
150 #endif
151  SVGResourceClipper* clipper = getClipperById(document(), clipperId);
152  SVGResourceMasker* masker = getMaskerById(document(), maskerId);
153 
 135
154136#if ENABLE(SVG_EXPERIMENTAL_FEATURES)
155  if (filter)
156  filter->prepareFilter(paintInfo.context, boundingBox);
157  else if (!filterId.isEmpty())
158  svgElement->document()->accessSVGExtensions()->addPendingResource(filterId, styledElement);
 137 SVGResourceFilter* filter = 0;
 138#else
 139 void* filter = 0;
159140#endif
160 
161  if (clipper) {
162  clipper->addClient(styledElement);
163  clipper->applyClip(paintInfo.context, boundingBox);
164  } else if (!clipperId.isEmpty())
165  svgElement->document()->accessSVGExtensions()->addPendingResource(clipperId, styledElement);
166 
167  if (masker) {
168  masker->addClient(styledElement);
169  masker->applyMask(paintInfo.context, boundingBox);
170  } else if (!maskerId.isEmpty())
171  svgElement->document()->accessSVGExtensions()->addPendingResource(maskerId, styledElement);
 141 FloatRect boundingBox = FloatRect(0, 0, width(), height());
 142 prepareToRenderSVGContent(this, paintInfo, boundingBox, filter);
172143
173144 float opacity = style()->opacity();
174145 if (opacity < 1.0f) {

@@void RenderSVGImage::absoluteRects(Vecto
269240
270241AffineTransform RenderSVGImage::translationForAttributes()
271242{
272  SVGImageElement *image = static_cast<SVGImageElement*>(node());
 243 SVGImageElement* image = static_cast<SVGImageElement*>(node());
273244 return AffineTransform().translate(image->x().value(), image->y().value());
274245}
275246
21978

rendering/SVGRenderSupport.cpp

 1/**
 2 * This file is part of the DOM implementation for WebKit.
 3 *
 4 * Copyright (C) 2007 Rob Buis <buis@kde.org>
 5 * (C) 2007 Nikolas Zimmermann <zimmermann@kde.org>
 6 * (C) 2007 Eric Seidel <eric@webkit.org>
 7 *
 8 * This library is free software; you can redistribute it and/or
 9 * modify it under the terms of the GNU Library General Public
 10 * License as published by the Free Software Foundation; either
 11 * version 2 of the License, or (at your option) any later version.
 12 *
 13 * This library is distributed in the hope that it will be useful,
 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 16 * Library General Public License for more details.
 17 *
 18 * You should have received a copy of the GNU Library General Public License
 19 * along with this library; see the file COPYING.LIB. If not, write to
 20 * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 21 * Boston, MA 02111-1307, USA.
 22 *
 23 */
 24
 25#include "config.h"
 26
 27#if ENABLE(SVG)
 28
 29#include "AffineTransform.h"
 30#include "RenderObject.h"
 31#include "SVGResourceClipper.h"
 32#include "SVGResourceFilter.h"
 33#include "SVGResourceMasker.h"
 34#include "SVGStyledElement.h"
 35#include "SVGURIReference.h"
 36
 37namespace WebCore {
 38
 39#if ENABLE(SVG_EXPERIMENTAL_FEATURES)
 40void prepareToRenderSVGContent(RenderObject* object, RenderObject::PaintInfo& paintInfo, const FloatRect& boundingBox, SVGResourceFilter*& filter)
 41#else
 42void prepareToRenderSVGContent(RenderObject* object, RenderObject::PaintInfo& paintInfo, const FloatRect& boundingBox, void*)
 43#endif
 44{
 45 SVGElement* svgElement = static_cast<SVGElement*>(object->element());
 46 ASSERT(svgElement && svgElement->document() && svgElement->isStyled());
 47
 48 SVGStyledElement* styledElement = static_cast<SVGStyledElement*>(svgElement);
 49 const SVGRenderStyle* svgStyle = object->style()->svgStyle();
 50
 51 AtomicString filterId(SVGURIReference::getTarget(svgStyle->filter()));
 52 AtomicString clipperId(SVGURIReference::getTarget(svgStyle->clipPath()));
 53 AtomicString maskerId(SVGURIReference::getTarget(svgStyle->maskElement()));
 54
 55 Document* document = object->document();
 56#if ENABLE(SVG_EXPERIMENTAL_FEATURES)
 57 filter = getFilterById(document, filterId);
 58#endif
 59 SVGResourceClipper* clipper = getClipperById(document, clipperId);
 60 SVGResourceMasker* masker = getMaskerById(document, maskerId);
 61
 62#if ENABLE(SVG_EXPERIMENTAL_FEATURES)
 63 if (filter)
 64 filter->prepareFilter(paintInfo.context, boundingBox);
 65 else if (!filterId.isEmpty())
 66 svgElement->document()->accessSVGExtensions()->addPendingResource(filterId, styledElement);
 67#endif
 68
 69 if (clipper) {
 70 clipper->addClient(styledElement);
 71 clipper->applyClip(paintInfo.context, boundingBox);
 72 } else if (!clipperId.isEmpty())
 73 svgElement->document()->accessSVGExtensions()->addPendingResource(clipperId, styledElement);
 74
 75 if (masker) {
 76 masker->addClient(styledElement);
 77 masker->applyMask(paintInfo.context, boundingBox);
 78 } else if (!maskerId.isEmpty())
 79 svgElement->document()->accessSVGExtensions()->addPendingResource(maskerId, styledElement);
 80}
 81
 82} // namespace WebCore
 83
 84#endif // ENABLE(SVG)
0

rendering/SVGRenderSupport.h

 1/**
 2 * This file is part of the DOM implementation for WebKit.
 3 *
 4 * Copyright (C) 2007 Rob Buis <buis@kde.org>
 5 * (C) 2007 Nikolas Zimmermann <zimmermann@kde.org>
 6 * (C) 2007 Eric Seidel <eric@webkit.org>
 7 *
 8 * This library is free software; you can redistribute it and/or
 9 * modify it under the terms of the GNU Library General Public
 10 * License as published by the Free Software Foundation; either
 11 * version 2 of the License, or (at your option) any later version.
 12 *
 13 * This library is distributed in the hope that it will be useful,
 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 16 * Library General Public License for more details.
 17 *
 18 * You should have received a copy of the GNU Library General Public License
 19 * along with this library; see the file COPYING.LIB. If not, write to
 20 * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 21 * Boston, MA 02111-1307, USA.
 22 *
 23 */
 24
 25#if ENABLE(SVG)
 26
 27#include "RenderObject.h"
 28
 29namespace WebCore {
 30
 31#if ENABLE(SVG_EXPERIMENTAL_FEATURES)
 32class SVGResourceFilter;
 33void prepareToRenderSVGContent(RenderObject*, RenderObject::PaintInfo& paintInfo, const FloatRect& boundingBox, SVGResourceFilter*&);
 34#else
 35void prepareToRenderSVGContent(RenderObject*, RenderObject::PaintInfo& paintInfo, const FloatRect& boundingBox, void*);
 36#endif
 37
 38}
 39
 40#endif
0

rendering/SVGRootInlineBox.cpp

3434#include "Range.h"
3535#include "SVGInlineFlowBox.h"
3636#include "SVGPaintServer.h"
 37#include "SVGRenderSupport.h"
3738#include "SVGResourceClipper.h"
3839#include "SVGResourceFilter.h"
3940#include "SVGResourceMasker.h"

@@namespace WebCore {
5051#if ENABLE(SVG_EXPERIMENTAL_FEATURES)
5152static void prepareTextRendering(RenderObject::PaintInfo& paintInfo, int tx, int ty, InlineFlowBox* flowBox, FloatRect& boundingBox, SVGResourceFilter*& filter)
5253#else
53 static void prepareTextRendering(RenderObject::PaintInfo& paintInfo, int tx, int ty, InlineFlowBox* flowBox, FloatRect& boundingBox)
 54static void prepareTextRendering(RenderObject::PaintInfo& paintInfo, int tx, int ty, InlineFlowBox* flowBox, FloatRect& boundingBox, void* filter)
5455#endif
5556{
5657 RenderObject* object = flowBox->object();

@@static void prepareTextRendering(RenderO
6061
6162 boundingBox = FloatRect(tx + flowBox->xPos(), ty + flowBox->yPos(), flowBox->width(), flowBox->height());
6263
63  SVGElement* svgElement = static_cast<SVGElement*>(object->element());
64  ASSERT(svgElement && svgElement->document() && svgElement->isStyled());
65 
66  SVGStyledElement* styledElement = static_cast<SVGStyledElement*>(svgElement);
67  const SVGRenderStyle* svgStyle = object->style()->svgStyle();
68 
69 #if ENABLE(SVG_EXPERIMENTAL_FEATURES)
70  AtomicString filterId(SVGURIReference::getTarget(svgStyle->filter()));
71 #endif
72 
73  AtomicString clipperId(SVGURIReference::getTarget(svgStyle->clipPath()));
74  AtomicString maskerId(SVGURIReference::getTarget(svgStyle->maskElement()));
75 
76  SVGResourceClipper* clipper = getClipperById(object->document(), clipperId);
77  SVGResourceMasker* masker = getMaskerById(object->document(), maskerId);
78 
79 #if ENABLE(SVG_EXPERIMENTAL_FEATURES)
80  filter = getFilterById(object->document(), filterId);
81 
82  if (filter)
83  filter->prepareFilter(paintInfo.context, boundingBox);
84  else if (!filterId.isEmpty())
85  svgElement->document()->accessSVGExtensions()->addPendingResource(filterId, styledElement);
86 #endif
87 
88  if (clipper) {
89  clipper->addClient(styledElement);
90  clipper->applyClip(paintInfo.context, boundingBox);
91  } else if (!clipperId.isEmpty())
92  svgElement->document()->accessSVGExtensions()->addPendingResource(clipperId, styledElement);
93 
94  if (masker) {
95  masker->addClient(styledElement);
96  masker->applyMask(paintInfo.context, boundingBox);
97  } else if (!maskerId.isEmpty())
98  svgElement->document()->accessSVGExtensions()->addPendingResource(maskerId, styledElement);
 64 prepareToRenderSVGContent(object, paintInfo, boundingBox, filter);
9965}
10066
10167inline bool isVerticalWritingMode(const SVGRenderStyle* style)

@@void SVGRootInlineBox::paint(RenderObjec
154120
155121#if ENABLE(SVG_EXPERIMENTAL_FEATURES)
156122 SVGResourceFilter* filter = 0;
157  prepareTextRendering(paintInfo, tx, ty, this, boundingBox, filter);
158123#else
159  prepareTextRendering(paintInfo, tx, ty, this, boundingBox);
 124 void* filter = 0;
160125#endif
 126 prepareTextRendering(paintInfo, tx, ty, this, boundingBox, filter);
161127
162128 RenderObject::PaintInfo pi(paintInfo);
163129

@@void SVGRootInlineBox::paintInlineBoxes(
10471013
10481014#if ENABLE(SVG_EXPERIMENTAL_FEATURES)
10491015 SVGResourceFilter* filter = 0;
1050  prepareTextRendering(paintInfo, tx, ty, flowBox, boundingBox, filter);
10511016#else
1052  prepareTextRendering(paintInfo, tx, ty, flowBox, boundingBox);
 1017 void* filter = 0;
10531018#endif
 1019 prepareTextRendering(paintInfo, tx, ty, flowBox, boundingBox, filter);
10541020
10551021 RenderObject* object = flowBox->object();
10561022 RenderObject::PaintInfo pi(paintInfo);
21978