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

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

Issue 977113003: Rename renderer() to layoutObject(). (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 9 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 * Copyright (C) 2011 Dirk Schulze <krit@webkit.org> 5 * Copyright (C) 2011 Dirk Schulze <krit@webkit.org>
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.
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 67
68 bool LayoutSVGResourceClipper::tryPathOnlyClipping(DisplayItemClient client, Gra phicsContext* context, 68 bool LayoutSVGResourceClipper::tryPathOnlyClipping(DisplayItemClient client, Gra phicsContext* context,
69 const AffineTransform& animatedLocalTransform, const FloatRect& objectBoundi ngBox) { 69 const AffineTransform& animatedLocalTransform, const FloatRect& objectBoundi ngBox) {
70 // If the current clip-path gets clipped itself, we have to fallback to mask ing. 70 // If the current clip-path gets clipped itself, we have to fallback to mask ing.
71 if (!style()->svgStyle().clipperResource().isEmpty()) 71 if (!style()->svgStyle().clipperResource().isEmpty())
72 return false; 72 return false;
73 WindRule clipRule = RULE_NONZERO; 73 WindRule clipRule = RULE_NONZERO;
74 Path clipPath = Path(); 74 Path clipPath = Path();
75 75
76 for (SVGElement* childElement = Traversal<SVGElement>::firstChild(*element() ); childElement; childElement = Traversal<SVGElement>::nextSibling(*childElement )) { 76 for (SVGElement* childElement = Traversal<SVGElement>::firstChild(*element() ); childElement; childElement = Traversal<SVGElement>::nextSibling(*childElement )) {
77 LayoutObject* renderer = childElement->renderer(); 77 LayoutObject* renderer = childElement->layoutObject();
78 if (!renderer) 78 if (!renderer)
79 continue; 79 continue;
80 // Only shapes or paths are supported for direct clipping. We need to fa llback to masking for texts. 80 // Only shapes or paths are supported for direct clipping. We need to fa llback to masking for texts.
81 if (renderer->isSVGText()) 81 if (renderer->isSVGText())
82 return false; 82 return false;
83 if (!childElement->isSVGGraphicsElement()) 83 if (!childElement->isSVGGraphicsElement())
84 continue; 84 continue;
85 SVGGraphicsElement* styled = toSVGGraphicsElement(childElement); 85 SVGGraphicsElement* styled = toSVGGraphicsElement(childElement);
86 const LayoutStyle* style = renderer->style(); 86 const LayoutStyle* style = renderer->style();
87 if (!style || style->display() == NONE || style->visibility() != VISIBLE ) 87 if (!style || style->display() == NONE || style->visibility() != VISIBLE )
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 // userSpaceOnUse units (http://crbug.com/294900). 154 // userSpaceOnUse units (http://crbug.com/294900).
155 FloatRect bounds = strokeBoundingBox(); 155 FloatRect bounds = strokeBoundingBox();
156 156
157 OwnPtr<DisplayItemList> displayItemList; 157 OwnPtr<DisplayItemList> displayItemList;
158 if (RuntimeEnabledFeatures::slimmingPaintEnabled()) 158 if (RuntimeEnabledFeatures::slimmingPaintEnabled())
159 displayItemList = DisplayItemList::create(); 159 displayItemList = DisplayItemList::create();
160 GraphicsContext context(nullptr, displayItemList.get()); 160 GraphicsContext context(nullptr, displayItemList.get());
161 context.beginRecording(bounds); 161 context.beginRecording(bounds);
162 162
163 for (SVGElement* childElement = Traversal<SVGElement>::firstChild(*element() ); childElement; childElement = Traversal<SVGElement>::nextSibling(*childElement )) { 163 for (SVGElement* childElement = Traversal<SVGElement>::firstChild(*element() ); childElement; childElement = Traversal<SVGElement>::nextSibling(*childElement )) {
164 LayoutObject* renderer = childElement->renderer(); 164 LayoutObject* renderer = childElement->layoutObject();
165 if (!renderer) 165 if (!renderer)
166 continue; 166 continue;
167 167
168 const LayoutStyle* style = renderer->style(); 168 const LayoutStyle* style = renderer->style();
169 if (!style || style->display() == NONE || style->visibility() != VISIBLE ) 169 if (!style || style->display() == NONE || style->visibility() != VISIBLE )
170 continue; 170 continue;
171 171
172 WindRule newClipRule = style->svgStyle().clipRule(); 172 WindRule newClipRule = style->svgStyle().clipRule();
173 bool isUseElement = isSVGUseElement(*childElement); 173 bool isUseElement = isSVGUseElement(*childElement);
174 if (isUseElement) { 174 if (isUseElement) {
175 SVGUseElement& useElement = toSVGUseElement(*childElement); 175 SVGUseElement& useElement = toSVGUseElement(*childElement);
176 renderer = useElement.rendererClipChild(); 176 renderer = useElement.rendererClipChild();
177 if (!renderer) 177 if (!renderer)
178 continue; 178 continue;
179 if (!useElement.hasAttribute(SVGNames::clip_ruleAttr)) 179 if (!useElement.hasAttribute(SVGNames::clip_ruleAttr))
180 newClipRule = renderer->style()->svgStyle().clipRule(); 180 newClipRule = renderer->style()->svgStyle().clipRule();
181 } 181 }
182 182
183 // Only shapes, paths and texts are allowed for clipping. 183 // Only shapes, paths and texts are allowed for clipping.
184 if (!renderer->isSVGShape() && !renderer->isSVGText()) 184 if (!renderer->isSVGShape() && !renderer->isSVGText())
185 continue; 185 continue;
186 186
187 context.setFillRule(newClipRule); 187 context.setFillRule(newClipRule);
188 188
189 if (isUseElement) 189 if (isUseElement)
190 renderer = childElement->renderer(); 190 renderer = childElement->layoutObject();
191 191
192 // Switch to a paint behavior where all children of this <clipPath> will be rendered using special constraints: 192 // Switch to a paint behavior where all children of this <clipPath> will be rendered using special constraints:
193 // - fill-opacity/stroke-opacity/opacity set to 1 193 // - fill-opacity/stroke-opacity/opacity set to 1
194 // - masker/filter not applied when rendering the children 194 // - masker/filter not applied when rendering the children
195 // - fill is set to the initial fill paint server (solid, black) 195 // - fill is set to the initial fill paint server (solid, black)
196 // - stroke is set to the initial stroke paint server (none) 196 // - stroke is set to the initial stroke paint server (none)
197 PaintInfo info(&context, LayoutRect::infiniteIntRect(), PaintPhaseForegr ound, PaintBehaviorRenderingClipPathAsMask); 197 PaintInfo info(&context, LayoutRect::infiniteIntRect(), PaintPhaseForegr ound, PaintBehaviorRenderingClipPathAsMask);
198 renderer->paint(info, IntPoint()); 198 renderer->paint(info, IntPoint());
199 } 199 }
200 200
201 if (displayItemList) 201 if (displayItemList)
202 displayItemList->replay(&context); 202 displayItemList->replay(&context);
203 m_clipContentPicture = context.endRecording(); 203 m_clipContentPicture = context.endRecording();
204 return m_clipContentPicture; 204 return m_clipContentPicture;
205 } 205 }
206 206
207 void LayoutSVGResourceClipper::calculateClipContentPaintInvalidationRect() 207 void LayoutSVGResourceClipper::calculateClipContentPaintInvalidationRect()
208 { 208 {
209 // This is a rough heuristic to appraise the clip size and doesn't consider clip on clip. 209 // This is a rough heuristic to appraise the clip size and doesn't consider clip on clip.
210 for (SVGElement* childElement = Traversal<SVGElement>::firstChild(*element() ); childElement; childElement = Traversal<SVGElement>::nextSibling(*childElement )) { 210 for (SVGElement* childElement = Traversal<SVGElement>::firstChild(*element() ); childElement; childElement = Traversal<SVGElement>::nextSibling(*childElement )) {
211 LayoutObject* renderer = childElement->renderer(); 211 LayoutObject* renderer = childElement->layoutObject();
212 if (!renderer) 212 if (!renderer)
213 continue; 213 continue;
214 if (!renderer->isSVGShape() && !renderer->isSVGText() && !isSVGUseElemen t(*childElement)) 214 if (!renderer->isSVGShape() && !renderer->isSVGText() && !isSVGUseElemen t(*childElement))
215 continue; 215 continue;
216 const LayoutStyle* style = renderer->style(); 216 const LayoutStyle* style = renderer->style();
217 if (!style || style->display() == NONE || style->visibility() != VISIBLE ) 217 if (!style || style->display() == NONE || style->visibility() != VISIBLE )
218 continue; 218 continue;
219 m_clipBoundaries.unite(renderer->localToParentTransform().mapRect(render er->paintInvalidationRectInLocalCoordinates())); 219 m_clipBoundaries.unite(renderer->localToParentTransform().mapRect(render er->paintInvalidationRectInLocalCoordinates()));
220 } 220 }
221 m_clipBoundaries = toSVGClipPathElement(element())->calculateAnimatedLocalTr ansform().mapRect(m_clipBoundaries); 221 m_clipBoundaries = toSVGClipPathElement(element())->calculateAnimatedLocalTr ansform().mapRect(m_clipBoundaries);
(...skipping 12 matching lines...) Expand all
234 point = transform.inverse().mapPoint(point); 234 point = transform.inverse().mapPoint(point);
235 } 235 }
236 236
237 AffineTransform animatedLocalTransform = toSVGClipPathElement(element())->ca lculateAnimatedLocalTransform(); 237 AffineTransform animatedLocalTransform = toSVGClipPathElement(element())->ca lculateAnimatedLocalTransform();
238 if (!animatedLocalTransform.isInvertible()) 238 if (!animatedLocalTransform.isInvertible())
239 return false; 239 return false;
240 240
241 point = animatedLocalTransform.inverse().mapPoint(point); 241 point = animatedLocalTransform.inverse().mapPoint(point);
242 242
243 for (SVGElement* childElement = Traversal<SVGElement>::firstChild(*element() ); childElement; childElement = Traversal<SVGElement>::nextSibling(*childElement )) { 243 for (SVGElement* childElement = Traversal<SVGElement>::firstChild(*element() ); childElement; childElement = Traversal<SVGElement>::nextSibling(*childElement )) {
244 LayoutObject* renderer = childElement->renderer(); 244 LayoutObject* renderer = childElement->layoutObject();
245 if (!renderer) 245 if (!renderer)
246 continue; 246 continue;
247 if (!renderer->isSVGShape() && !renderer->isSVGText() && !isSVGUseElemen t(*childElement)) 247 if (!renderer->isSVGShape() && !renderer->isSVGText() && !isSVGUseElemen t(*childElement))
248 continue; 248 continue;
249 IntPoint hitPoint; 249 IntPoint hitPoint;
250 HitTestResult result(hitPoint); 250 HitTestResult result(hitPoint);
251 if (renderer->nodeAtFloatPoint(HitTestRequest(HitTestRequest::SVGClipCon tent), result, point, HitTestForeground)) 251 if (renderer->nodeAtFloatPoint(HitTestRequest(HitTestRequest::SVGClipCon tent), result, point, HitTestForeground))
252 return true; 252 return true;
253 } 253 }
254 254
(...skipping 14 matching lines...) Expand all
269 AffineTransform transform; 269 AffineTransform transform;
270 transform.translate(objectBoundingBox.x(), objectBoundingBox.y()); 270 transform.translate(objectBoundingBox.x(), objectBoundingBox.y());
271 transform.scaleNonUniform(objectBoundingBox.width(), objectBoundingBox.h eight()); 271 transform.scaleNonUniform(objectBoundingBox.width(), objectBoundingBox.h eight());
272 return transform.mapRect(m_clipBoundaries); 272 return transform.mapRect(m_clipBoundaries);
273 } 273 }
274 274
275 return m_clipBoundaries; 275 return m_clipBoundaries;
276 } 276 }
277 277
278 } 278 }
OLDNEW
« no previous file with comments | « Source/core/layout/svg/LayoutSVGGradientStop.cpp ('k') | Source/core/layout/svg/LayoutSVGResourceContainer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698