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

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

Issue 1544673003: Refactor propagation of parsing errors for SVG attributes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 12 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) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org> 2 * Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org>
3 * Copyright (C) 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org> 3 * Copyright (C) 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org>
4 * Copyright (C) 2010 Dirk Schulze <krit@webkit.org> 4 * Copyright (C) 2010 Dirk Schulze <krit@webkit.org>
5 * 5 *
6 * This library is free software; you can redistribute it and/or 6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public 7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either 8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version. 9 * version 2 of the License, or (at your option) any later version.
10 * 10 *
11 * This library is distributed in the hope that it will be useful, 11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details. 14 * Library General Public License for more details.
15 * 15 *
16 * You should have received a copy of the GNU Library General Public License 16 * You should have received a copy of the GNU Library General Public License
17 * along with this library; see the file COPYING.LIB. If not, write to 17 * along with this library; see the file COPYING.LIB. If not, write to
18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 * Boston, MA 02110-1301, USA. 19 * Boston, MA 02110-1301, USA.
20 */ 20 */
21 21
22 #include "core/svg/SVGPreserveAspectRatio.h" 22 #include "core/svg/SVGPreserveAspectRatio.h"
23 23
24 #include "bindings/core/v8/ExceptionState.h"
25 #include "bindings/core/v8/ExceptionStatePlaceholder.h"
26 #include "core/dom/ExceptionCode.h"
27 #include "core/svg/SVGAnimationElement.h" 24 #include "core/svg/SVGAnimationElement.h"
28 #include "core/svg/SVGParserUtilities.h" 25 #include "core/svg/SVGParserUtilities.h"
29 #include "platform/geometry/FloatRect.h" 26 #include "platform/geometry/FloatRect.h"
30 #include "platform/text/ParserUtilities.h" 27 #include "platform/text/ParserUtilities.h"
31 #include "platform/transforms/AffineTransform.h" 28 #include "platform/transforms/AffineTransform.h"
32 #include "wtf/text/WTFString.h" 29 #include "wtf/text/WTFString.h"
33 30
34 namespace blink { 31 namespace blink {
35 32
36 SVGPreserveAspectRatio::SVGPreserveAspectRatio() 33 SVGPreserveAspectRatio::SVGPreserveAspectRatio()
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 141
145 if (end != ptr && validate) 142 if (end != ptr && validate)
146 return false; 143 return false;
147 144
148 setAlign(align); 145 setAlign(align);
149 setMeetOrSlice(meetOrSlice); 146 setMeetOrSlice(meetOrSlice);
150 147
151 return true; 148 return true;
152 } 149 }
153 150
154 void SVGPreserveAspectRatio::setValueAsString(const String& string, ExceptionSta te& exceptionState) 151 SVGParsingError SVGPreserveAspectRatio::setValueAsString(const String& string)
155 { 152 {
156 setDefault(); 153 setDefault();
157 154
158 if (string.isEmpty()) 155 if (string.isEmpty())
159 return; 156 return NoError;
160 157
161 bool valid = false; 158 bool valid = false;
162 if (string.is8Bit()) { 159 if (string.is8Bit()) {
163 const LChar* ptr = string.characters8(); 160 const LChar* ptr = string.characters8();
164 const LChar* end = ptr + string.length(); 161 const LChar* end = ptr + string.length();
165 valid = parseInternal(ptr, end, true); 162 valid = parseInternal(ptr, end, true);
166 } else { 163 } else {
167 const UChar* ptr = string.characters16(); 164 const UChar* ptr = string.characters16();
168 const UChar* end = ptr + string.length(); 165 const UChar* end = ptr + string.length();
169 valid = parseInternal(ptr, end, true); 166 valid = parseInternal(ptr, end, true);
170 } 167 }
171 168 return valid ? NoError : ParsingAttributeFailedError;
172 if (!valid) {
173 exceptionState.throwDOMException(SyntaxError, "The value provided ('" + string + "') is invalid.");
174 }
175 } 169 }
176 170
177 bool SVGPreserveAspectRatio::parse(const LChar*& ptr, const LChar* end, bool val idate) 171 bool SVGPreserveAspectRatio::parse(const LChar*& ptr, const LChar* end, bool val idate)
178 { 172 {
179 return parseInternal(ptr, end, validate); 173 return parseInternal(ptr, end, validate);
180 } 174 }
181 175
182 bool SVGPreserveAspectRatio::parse(const UChar*& ptr, const UChar* end, bool val idate) 176 bool SVGPreserveAspectRatio::parse(const UChar*& ptr, const UChar* end, bool val idate)
183 { 177 {
184 return parseInternal(ptr, end, validate); 178 return parseInternal(ptr, end, validate);
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 m_meetOrSlice = preserveAspectRatioToUse->m_meetOrSlice; 399 m_meetOrSlice = preserveAspectRatioToUse->m_meetOrSlice;
406 } 400 }
407 401
408 float SVGPreserveAspectRatio::calculateDistance(PassRefPtrWillBeRawPtr<SVGProper tyBase> toValue, SVGElement* contextElement) 402 float SVGPreserveAspectRatio::calculateDistance(PassRefPtrWillBeRawPtr<SVGProper tyBase> toValue, SVGElement* contextElement)
409 { 403 {
410 // No paced animations for SVGPreserveAspectRatio. 404 // No paced animations for SVGPreserveAspectRatio.
411 return -1; 405 return -1;
412 } 406 }
413 407
414 } 408 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698