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

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

Issue 2748103015: Replace ASSERT with DCHECK in core/layout/<sub dirs> (Closed)
Patch Set: Rebase with latest Created 3 years, 8 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) 2006 Nikolas Zimmermann <zimmermann@kde.org> 2 * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org>
3 * Copyright (C) 2007 Rob Buis <buis@kde.org> 3 * Copyright (C) 2007 Rob Buis <buis@kde.org>
4 * Copyright (C) 2008 Dirk Schulze <krit@webkit.org> 4 * Copyright (C) 2008 Dirk Schulze <krit@webkit.org>
5 * Copyright (C) Research In Motion Limited 2010. All rights reserved. 5 * Copyright (C) Research In Motion Limited 2010. All rights reserved.
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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 if (m_pattern) { 52 if (m_pattern) {
53 m_pattern->applyToFlags(flags, affineTransformToSkMatrix(m_transform)); 53 m_pattern->applyToFlags(flags, affineTransformToSkMatrix(m_transform));
54 } else if (m_gradient) { 54 } else if (m_gradient) {
55 m_gradient->applyToFlags(flags, affineTransformToSkMatrix(m_transform)); 55 m_gradient->applyToFlags(flags, affineTransformToSkMatrix(m_transform));
56 } else { 56 } else {
57 flags.setShader(nullptr); 57 flags.setShader(nullptr);
58 } 58 }
59 } 59 }
60 60
61 void SVGPaintServer::prependTransform(const AffineTransform& transform) { 61 void SVGPaintServer::prependTransform(const AffineTransform& transform) {
62 ASSERT(m_gradient || m_pattern); 62 DCHECK(m_gradient || m_pattern);
63 m_transform = transform * m_transform; 63 m_transform = transform * m_transform;
64 } 64 }
65 65
66 static SVGPaintDescription requestPaint(const LayoutObject& object, 66 static SVGPaintDescription requestPaint(const LayoutObject& object,
67 const ComputedStyle& style, 67 const ComputedStyle& style,
68 LayoutSVGResourceMode mode) { 68 LayoutSVGResourceMode mode) {
69 // If we have no style at all, ignore it. 69 // If we have no style at all, ignore it.
70 const SVGComputedStyle& svgStyle = style.svgStyle(); 70 const SVGComputedStyle& svgStyle = style.svgStyle();
71 71
72 // If we have no fill/stroke, return 0. 72 // If we have no fill/stroke, return 0.
73 if (mode == ApplyToFillMode) { 73 if (mode == ApplyToFillMode) {
74 if (!svgStyle.hasFill()) 74 if (!svgStyle.hasFill())
75 return SVGPaintDescription(); 75 return SVGPaintDescription();
76 } else { 76 } else {
77 if (!svgStyle.hasStroke()) 77 if (!svgStyle.hasStroke())
78 return SVGPaintDescription(); 78 return SVGPaintDescription();
79 } 79 }
80 80
81 bool applyToFill = mode == ApplyToFillMode; 81 bool applyToFill = mode == ApplyToFillMode;
82 SVGPaintType paintType = 82 SVGPaintType paintType =
83 applyToFill ? svgStyle.fillPaintType() : svgStyle.strokePaintType(); 83 applyToFill ? svgStyle.fillPaintType() : svgStyle.strokePaintType();
84 ASSERT(paintType != SVG_PAINTTYPE_NONE); 84 DCHECK_NE(paintType, SVG_PAINTTYPE_NONE);
85 85
86 Color color; 86 Color color;
87 bool hasColor = false; 87 bool hasColor = false;
88 switch (paintType) { 88 switch (paintType) {
89 case SVG_PAINTTYPE_CURRENTCOLOR: 89 case SVG_PAINTTYPE_CURRENTCOLOR:
90 case SVG_PAINTTYPE_URI_CURRENTCOLOR: 90 case SVG_PAINTTYPE_URI_CURRENTCOLOR:
91 // The keyword `currentcolor` takes its value from the value of the 91 // The keyword `currentcolor` takes its value from the value of the
92 // `color` property on the same element. 92 // `color` property on the same element.
93 color = style.visitedDependentColor(CSSPropertyColor); 93 color = style.visitedDependentColor(CSSPropertyColor);
94 hasColor = true; 94 hasColor = true;
(...skipping 24 matching lines...) Expand all
119 color = Color(visitedColor.red(), visitedColor.green(), 119 color = Color(visitedColor.red(), visitedColor.green(),
120 visitedColor.blue(), color.alpha()); 120 visitedColor.blue(), color.alpha());
121 hasColor = true; 121 hasColor = true;
122 } 122 }
123 } 123 }
124 124
125 // If the primary resource is just a color, return immediately. 125 // If the primary resource is just a color, return immediately.
126 if (paintType < SVG_PAINTTYPE_URI_NONE) { 126 if (paintType < SVG_PAINTTYPE_URI_NONE) {
127 // |paintType| will be either <current-color> or <rgb-color> here - both of 127 // |paintType| will be either <current-color> or <rgb-color> here - both of
128 // which will have a color. 128 // which will have a color.
129 ASSERT(hasColor); 129 DCHECK(hasColor);
130 return SVGPaintDescription(color); 130 return SVGPaintDescription(color);
131 } 131 }
132 132
133 LayoutSVGResourcePaintServer* uriResource = nullptr; 133 LayoutSVGResourcePaintServer* uriResource = nullptr;
134 if (SVGResources* resources = 134 if (SVGResources* resources =
135 SVGResourcesCache::cachedResourcesForLayoutObject(&object)) 135 SVGResourcesCache::cachedResourcesForLayoutObject(&object))
136 uriResource = applyToFill ? resources->fill() : resources->stroke(); 136 uriResource = applyToFill ? resources->fill() : resources->stroke();
137 137
138 // If the requested resource is not available, return the color resource or 138 // If the requested resource is not available, return the color resource or
139 // 'none'. 139 // 'none'.
(...skipping 12 matching lines...) Expand all
152 if (hasColor) 152 if (hasColor)
153 return SVGPaintDescription(uriResource, color); 153 return SVGPaintDescription(uriResource, color);
154 154
155 return SVGPaintDescription(uriResource); 155 return SVGPaintDescription(uriResource);
156 } 156 }
157 157
158 SVGPaintServer SVGPaintServer::requestForLayoutObject( 158 SVGPaintServer SVGPaintServer::requestForLayoutObject(
159 const LayoutObject& layoutObject, 159 const LayoutObject& layoutObject,
160 const ComputedStyle& style, 160 const ComputedStyle& style,
161 LayoutSVGResourceMode resourceMode) { 161 LayoutSVGResourceMode resourceMode) {
162 ASSERT(resourceMode == ApplyToFillMode || resourceMode == ApplyToStrokeMode); 162 DCHECK(resourceMode == ApplyToFillMode || resourceMode == ApplyToStrokeMode);
163 163
164 SVGPaintDescription paintDescription = 164 SVGPaintDescription paintDescription =
165 requestPaint(layoutObject, style, resourceMode); 165 requestPaint(layoutObject, style, resourceMode);
166 if (!paintDescription.isValid) 166 if (!paintDescription.isValid)
167 return invalid(); 167 return invalid();
168 if (!paintDescription.resource) 168 if (!paintDescription.resource)
169 return SVGPaintServer(paintDescription.color); 169 return SVGPaintServer(paintDescription.color);
170 SVGPaintServer paintServer = 170 SVGPaintServer paintServer =
171 paintDescription.resource->preparePaintServer(layoutObject); 171 paintDescription.resource->preparePaintServer(layoutObject);
172 if (paintServer.isValid()) 172 if (paintServer.isValid())
(...skipping 15 matching lines...) Expand all
188 LayoutSVGResourcePaintServer::~LayoutSVGResourcePaintServer() {} 188 LayoutSVGResourcePaintServer::~LayoutSVGResourcePaintServer() {}
189 189
190 SVGPaintDescription LayoutSVGResourcePaintServer::requestPaintDescription( 190 SVGPaintDescription LayoutSVGResourcePaintServer::requestPaintDescription(
191 const LayoutObject& layoutObject, 191 const LayoutObject& layoutObject,
192 const ComputedStyle& style, 192 const ComputedStyle& style,
193 LayoutSVGResourceMode resourceMode) { 193 LayoutSVGResourceMode resourceMode) {
194 return requestPaint(layoutObject, style, resourceMode); 194 return requestPaint(layoutObject, style, resourceMode);
195 } 195 }
196 196
197 } // namespace blink 197 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698