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

Side by Side Diff: Source/core/rendering/svg/RenderSVGShape.cpp

Issue 18053005: Introduce SVGGraphicsElement IDL interface (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 5 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 Nikolas Zimmermann <zimmermann@kde.org> 2 * Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org>
3 * Copyright (C) 2004, 2005, 2008 Rob Buis <buis@kde.org> 3 * Copyright (C) 2004, 2005, 2008 Rob Buis <buis@kde.org>
4 * Copyright (C) 2005, 2007 Eric Seidel <eric@webkit.org> 4 * Copyright (C) 2005, 2007 Eric Seidel <eric@webkit.org>
5 * Copyright (C) 2009 Google, Inc. 5 * Copyright (C) 2009 Google, Inc.
6 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org> 6 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org>
7 * Copyright (C) Research In Motion Limited 2010. All rights reserved. 7 * Copyright (C) Research In Motion Limited 2010. All rights reserved.
8 * Copyright (C) 2009 Jeff Schiller <codedread@gmail.com> 8 * Copyright (C) 2009 Jeff Schiller <codedread@gmail.com>
9 * Copyright (C) 2011 Renata Hodovan <reni@webkit.org> 9 * Copyright (C) 2011 Renata Hodovan <reni@webkit.org>
10 * Copyright (C) 2011 University of Szeged 10 * Copyright (C) 2011 University of Szeged
(...skipping 22 matching lines...) Expand all
33 #include "core/platform/graphics/GraphicsContextStateSaver.h" 33 #include "core/platform/graphics/GraphicsContextStateSaver.h"
34 #include "core/rendering/HitTestRequest.h" 34 #include "core/rendering/HitTestRequest.h"
35 #include "core/rendering/LayoutRepainter.h" 35 #include "core/rendering/LayoutRepainter.h"
36 #include "core/rendering/PointerEventsHitRules.h" 36 #include "core/rendering/PointerEventsHitRules.h"
37 #include "core/rendering/svg/RenderSVGResourceMarker.h" 37 #include "core/rendering/svg/RenderSVGResourceMarker.h"
38 #include "core/rendering/svg/RenderSVGResourceSolidColor.h" 38 #include "core/rendering/svg/RenderSVGResourceSolidColor.h"
39 #include "core/rendering/svg/SVGPathData.h" 39 #include "core/rendering/svg/SVGPathData.h"
40 #include "core/rendering/svg/SVGRenderingContext.h" 40 #include "core/rendering/svg/SVGRenderingContext.h"
41 #include "core/rendering/svg/SVGResources.h" 41 #include "core/rendering/svg/SVGResources.h"
42 #include "core/rendering/svg/SVGResourcesCache.h" 42 #include "core/rendering/svg/SVGResourcesCache.h"
43 #include "core/svg/SVGStyledTransformableElement.h" 43 #include "core/svg/SVGGraphicsElement.h"
44 #include <wtf/MathExtras.h> 44 #include <wtf/MathExtras.h>
45 45
46 namespace WebCore { 46 namespace WebCore {
47 47
48 RenderSVGShape::RenderSVGShape(SVGStyledTransformableElement* node) 48 RenderSVGShape::RenderSVGShape(SVGGraphicsElement* node)
49 : RenderSVGModelObject(node) 49 : RenderSVGModelObject(node)
50 , m_needsBoundariesUpdate(false) // Default is false, the cached rects are e mpty from the beginning. 50 , m_needsBoundariesUpdate(false) // Default is false, the cached rects are e mpty from the beginning.
51 , m_needsShapeUpdate(true) // Default is true, so we grab a Path object once from SVGStyledTransformableElement. 51 , m_needsShapeUpdate(true) // Default is true, so we grab a Path object once from SVGGraphicsElement.
52 , m_needsTransformUpdate(true) // Default is true, so we grab a AffineTransf orm object once from SVGStyledTransformableElement. 52 , m_needsTransformUpdate(true) // Default is true, so we grab a AffineTransf orm object once from SVGGraphicsElement.
53 { 53 {
54 } 54 }
55 55
56 RenderSVGShape::~RenderSVGShape() 56 RenderSVGShape::~RenderSVGShape()
57 { 57 {
58 } 58 }
59 59
60 void RenderSVGShape::updateShapeFromElement() 60 void RenderSVGShape::updateShapeFromElement()
61 { 61 {
62 m_path.clear(); 62 m_path.clear();
63 m_path = adoptPtr(new Path); 63 m_path = adoptPtr(new Path);
64 ASSERT(RenderSVGShape::isEmpty()); 64 ASSERT(RenderSVGShape::isEmpty());
65 65
66 SVGStyledTransformableElement* element = toSVGStyledTransformableElement(nod e()); 66 SVGGraphicsElement* element = toSVGGraphicsElement(node());
67 updatePathFromGraphicsElement(element, path()); 67 updatePathFromGraphicsElement(element, path());
68 processMarkerPositions(); 68 processMarkerPositions();
69 69
70 m_fillBoundingBox = calculateObjectBoundingBox(); 70 m_fillBoundingBox = calculateObjectBoundingBox();
71 m_strokeBoundingBox = calculateStrokeBoundingBox(); 71 m_strokeBoundingBox = calculateStrokeBoundingBox();
72 } 72 }
73 73
74 bool RenderSVGShape::isEmpty() const 74 bool RenderSVGShape::isEmpty() const
75 { 75 {
76 return path().isEmpty(); 76 return path().isEmpty();
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 if (requiresStroke && !RenderSVGResource::strokePaintingResource(this, style (), fallbackColor)) 134 if (requiresStroke && !RenderSVGResource::strokePaintingResource(this, style (), fallbackColor))
135 return false; 135 return false;
136 136
137 return shapeDependentStrokeContains(point); 137 return shapeDependentStrokeContains(point);
138 } 138 }
139 139
140 void RenderSVGShape::layout() 140 void RenderSVGShape::layout()
141 { 141 {
142 StackStats::LayoutCheckPoint layoutCheckPoint; 142 StackStats::LayoutCheckPoint layoutCheckPoint;
143 LayoutRepainter repainter(*this, SVGRenderSupport::checkForSVGRepaintDuringL ayout(this) && selfNeedsLayout()); 143 LayoutRepainter repainter(*this, SVGRenderSupport::checkForSVGRepaintDuringL ayout(this) && selfNeedsLayout());
144 SVGStyledTransformableElement* element = toSVGStyledTransformableElement(nod e()); 144 SVGGraphicsElement* element = toSVGGraphicsElement(node());
145 145
146 bool updateCachedBoundariesInParents = false; 146 bool updateCachedBoundariesInParents = false;
147 147
148 if (m_needsShapeUpdate || m_needsBoundariesUpdate) { 148 if (m_needsShapeUpdate || m_needsBoundariesUpdate) {
149 updateShapeFromElement(); 149 updateShapeFromElement();
150 m_needsShapeUpdate = false; 150 m_needsShapeUpdate = false;
151 updateRepaintBoundingBox(); 151 updateRepaintBoundingBox();
152 m_needsBoundariesUpdate = false; 152 m_needsBoundariesUpdate = false;
153 updateCachedBoundariesInParents = true; 153 updateCachedBoundariesInParents = true;
154 } 154 }
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 if (!strokeTransform.isInvertible()) 186 if (!strokeTransform.isInvertible())
187 return false; 187 return false;
188 188
189 stateSaver.save(); 189 stateSaver.save();
190 stateSaver.context()->concatCTM(strokeTransform.inverse()); 190 stateSaver.context()->concatCTM(strokeTransform.inverse());
191 return true; 191 return true;
192 } 192 }
193 193
194 AffineTransform RenderSVGShape::nonScalingStrokeTransform() const 194 AffineTransform RenderSVGShape::nonScalingStrokeTransform() const
195 { 195 {
196 SVGStyledTransformableElement* element = toSVGStyledTransformableElement(nod e()); 196 SVGGraphicsElement* element = toSVGGraphicsElement(node());
197 return element->getScreenCTM(SVGLocatable::DisallowStyleUpdate); 197 return element->getScreenCTM(SVGLocatable::DisallowStyleUpdate);
198 } 198 }
199 199
200 bool RenderSVGShape::shouldGenerateMarkerPositions() const 200 bool RenderSVGShape::shouldGenerateMarkerPositions() const
201 { 201 {
202 if (!style()->svgStyle()->hasMarkers()) 202 if (!style()->svgStyle()->hasMarkers())
203 return false; 203 return false;
204 204
205 SVGStyledTransformableElement* element = toSVGStyledTransformableElement(nod e()); 205 SVGGraphicsElement* element = toSVGGraphicsElement(node());
206 if (!element->supportsMarkers()) 206 if (!element->supportsMarkers())
207 return false; 207 return false;
208 208
209 SVGResources* resources = SVGResourcesCache::cachedResourcesForRenderObject( this); 209 SVGResources* resources = SVGResourcesCache::cachedResourcesForRenderObject( this);
210 if (!resources) 210 if (!resources)
211 return false; 211 return false;
212 212
213 return resources->markerStart() || resources->markerMid() || resources->mark erEnd(); 213 return resources->markerStart() || resources->markerMid() || resources->mark erEnd();
214 } 214 }
215 215
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
457 return; 457 return;
458 458
459 ASSERT(m_path); 459 ASSERT(m_path);
460 460
461 SVGMarkerData markerData(m_markerPositions); 461 SVGMarkerData markerData(m_markerPositions);
462 m_path->apply(&markerData, SVGMarkerData::updateFromPathElement); 462 m_path->apply(&markerData, SVGMarkerData::updateFromPathElement);
463 markerData.pathIsDone(); 463 markerData.pathIsDone();
464 } 464 }
465 465
466 } 466 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698