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

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

Issue 2738863002: Replace ASSERT with DCHECK in core/svg/ (Closed)
Patch Set: Split DCHECKS wherever possible Created 3 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) Research In Motion Limited 2010. All rights reserved. 2 * Copyright (C) Research In Motion Limited 2010. All rights reserved.
3 * Copyright (C) 2013 Apple Inc. All rights reserved. 3 * Copyright (C) 2013 Apple Inc. All rights reserved.
4 * 4 *
5 * This library is free software; you can redistribute it and/or 5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public 6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either 7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version. 8 * version 2 of the License, or (at your option) any later version.
9 * 9 *
10 * This library is distributed in the hope that it will be useful, 10 * This library is distributed in the hope that it will be useful,
(...skipping 11 matching lines...) Expand all
22 22
23 #include "core/svg/SVGParserUtilities.h" 23 #include "core/svg/SVGParserUtilities.h"
24 #include "platform/geometry/FloatPoint.h" 24 #include "platform/geometry/FloatPoint.h"
25 25
26 namespace blink { 26 namespace blink {
27 27
28 SVGPathStringSource::SVGPathStringSource(const String& string) 28 SVGPathStringSource::SVGPathStringSource(const String& string)
29 : m_is8BitSource(string.is8Bit()), 29 : m_is8BitSource(string.is8Bit()),
30 m_previousCommand(PathSegUnknown), 30 m_previousCommand(PathSegUnknown),
31 m_string(string) { 31 m_string(string) {
32 ASSERT(!string.isNull()); 32 DCHECK(!string.isNull());
33 33
34 if (m_is8BitSource) { 34 if (m_is8BitSource) {
35 m_current.m_character8 = string.characters8(); 35 m_current.m_character8 = string.characters8();
36 m_end.m_character8 = m_current.m_character8 + string.length(); 36 m_end.m_character8 = m_current.m_character8 + string.length();
37 } else { 37 } else {
38 m_current.m_character16 = string.characters16(); 38 m_current.m_character16 = string.characters16();
39 m_end.m_character16 = m_current.m_character16 + string.length(); 39 m_end.m_character16 = m_current.m_character16 + string.length();
40 } 40 }
41 eatWhitespace(); 41 eatWhitespace();
42 } 42 }
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 !parseArcFlag(m_current.m_character8, m_end.m_character8, flagValue); 152 !parseArcFlag(m_current.m_character8, m_end.m_character8, flagValue);
153 else 153 else
154 error = 154 error =
155 !parseArcFlag(m_current.m_character16, m_end.m_character16, flagValue); 155 !parseArcFlag(m_current.m_character16, m_end.m_character16, flagValue);
156 if (UNLIKELY(error)) 156 if (UNLIKELY(error))
157 setErrorMark(SVGParseStatus::ExpectedArcFlag); 157 setErrorMark(SVGParseStatus::ExpectedArcFlag);
158 return flagValue; 158 return flagValue;
159 } 159 }
160 160
161 PathSegmentData SVGPathStringSource::parseSegment() { 161 PathSegmentData SVGPathStringSource::parseSegment() {
162 ASSERT(hasMoreData()); 162 DCHECK(hasMoreData());
163 PathSegmentData segment; 163 PathSegmentData segment;
164 unsigned lookahead = 164 unsigned lookahead =
165 m_is8BitSource ? *m_current.m_character8 : *m_current.m_character16; 165 m_is8BitSource ? *m_current.m_character8 : *m_current.m_character16;
166 SVGPathSegType command = mapLetterToSegmentType(lookahead); 166 SVGPathSegType command = mapLetterToSegmentType(lookahead);
167 if (UNLIKELY(m_previousCommand == PathSegUnknown)) { 167 if (UNLIKELY(m_previousCommand == PathSegUnknown)) {
168 // First command has to be a moveto. 168 // First command has to be a moveto.
169 if (command != PathSegMoveToRel && command != PathSegMoveToAbs) { 169 if (command != PathSegMoveToRel && command != PathSegMoveToAbs) {
170 setErrorMark(SVGParseStatus::ExpectedMoveToCommand); 170 setErrorMark(SVGParseStatus::ExpectedMoveToCommand);
171 return segment; 171 return segment;
172 } 172 }
173 // Consume command letter. 173 // Consume command letter.
174 if (m_is8BitSource) 174 if (m_is8BitSource)
175 m_current.m_character8++; 175 m_current.m_character8++;
176 else 176 else
177 m_current.m_character16++; 177 m_current.m_character16++;
178 } else if (command == PathSegUnknown) { 178 } else if (command == PathSegUnknown) {
179 // Possibly an implicit command. 179 // Possibly an implicit command.
180 ASSERT(m_previousCommand != PathSegUnknown); 180 DCHECK_NE(m_previousCommand, PathSegUnknown);
181 if (!maybeImplicitCommand(lookahead, m_previousCommand, command)) { 181 if (!maybeImplicitCommand(lookahead, m_previousCommand, command)) {
182 setErrorMark(SVGParseStatus::ExpectedPathCommand); 182 setErrorMark(SVGParseStatus::ExpectedPathCommand);
183 return segment; 183 return segment;
184 } 184 }
185 } else { 185 } else {
186 // Valid explicit command. 186 // Valid explicit command.
187 if (m_is8BitSource) 187 if (m_is8BitSource)
188 m_current.m_character8++; 188 m_current.m_character8++;
189 else 189 else
190 m_current.m_character16++; 190 m_current.m_character16++;
191 } 191 }
192 192
193 segment.command = m_previousCommand = command; 193 segment.command = m_previousCommand = command;
194 194
195 ASSERT(m_error.status() == SVGParseStatus::NoError); 195 DCHECK_EQ(m_error.status(), SVGParseStatus::NoError);
196 196
197 switch (segment.command) { 197 switch (segment.command) {
198 case PathSegCurveToCubicRel: 198 case PathSegCurveToCubicRel:
199 case PathSegCurveToCubicAbs: 199 case PathSegCurveToCubicAbs:
200 segment.point1.setX(parseNumberWithError()); 200 segment.point1.setX(parseNumberWithError());
201 segment.point1.setY(parseNumberWithError()); 201 segment.point1.setY(parseNumberWithError());
202 /* fall through */ 202 /* fall through */
203 case PathSegCurveToCubicSmoothRel: 203 case PathSegCurveToCubicSmoothRel:
204 case PathSegCurveToCubicSmoothAbs: 204 case PathSegCurveToCubicSmoothAbs:
205 segment.point2.setX(parseNumberWithError()); 205 segment.point2.setX(parseNumberWithError());
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 case PathSegUnknown: 245 case PathSegUnknown:
246 ASSERT_NOT_REACHED(); 246 ASSERT_NOT_REACHED();
247 } 247 }
248 248
249 if (UNLIKELY(m_error.status() != SVGParseStatus::NoError)) 249 if (UNLIKELY(m_error.status() != SVGParseStatus::NoError))
250 segment.command = PathSegUnknown; 250 segment.command = PathSegUnknown;
251 return segment; 251 return segment;
252 } 252 }
253 253
254 } // namespace blink 254 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/svg/SVGPathStringBuilder.cpp ('k') | third_party/WebKit/Source/core/svg/SVGPolyElement.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698