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

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

Issue 2176623003: Remove platform/text/ParserUtilities.h (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove from blink_platform.gypi Created 4 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2007, 2010 Rob Buis <buis@kde.org> 2 * Copyright (C) 2007, 2010 Rob Buis <buis@kde.org>
3 * 3 *
4 * This library is free software; you can redistribute it and/or 4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public 5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either 6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version. 7 * version 2 of the License, or (at your option) any later version.
8 * 8 *
9 * This library is distributed in the hope that it will be useful, 9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details. 12 * Library General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU Library General Public License 14 * You should have received a copy of the GNU Library General Public License
15 * along with this library; see the file COPYING.LIB. If not, write to 15 * along with this library; see the file COPYING.LIB. If not, write to
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA. 17 * Boston, MA 02110-1301, USA.
18 */ 18 */
19 19
20 #include "core/svg/SVGViewSpec.h" 20 #include "core/svg/SVGViewSpec.h"
21 21
22 #include "bindings/core/v8/ExceptionMessages.h" 22 #include "bindings/core/v8/ExceptionMessages.h"
23 #include "bindings/core/v8/ExceptionState.h" 23 #include "bindings/core/v8/ExceptionState.h"
24 #include "core/SVGNames.h" 24 #include "core/SVGNames.h"
25 #include "core/dom/ExceptionCode.h" 25 #include "core/dom/ExceptionCode.h"
26 #include "core/svg/SVGAnimatedTransformList.h" 26 #include "core/svg/SVGAnimatedTransformList.h"
27 #include "core/svg/SVGParserUtilities.h" 27 #include "core/svg/SVGParserUtilities.h"
28 #include "platform/text/ParserUtilities.h" 28 #include "platform/ParsingUtilities.h"
29 29
30 namespace blink { 30 namespace blink {
31 31
32 SVGViewSpec::SVGViewSpec(SVGSVGElement* contextElement) 32 SVGViewSpec::SVGViewSpec(SVGSVGElement* contextElement)
33 // Note: addToPropertyMap is not needed, as SVGViewSpec do not correspond to an element. 33 // Note: addToPropertyMap is not needed, as SVGViewSpec do not correspond to an element.
34 // Note: We make tear-offs' contextElement the target element of SVGViewSpec . 34 // Note: We make tear-offs' contextElement the target element of SVGViewSpec .
35 // This contextElement will be only used for keeping this alive from the tea roff. 35 // This contextElement will be only used for keeping this alive from the tea roff.
36 // SVGSVGElement holds a strong-ref to this SVGViewSpec, so this is kept ali ve as: 36 // SVGSVGElement holds a strong-ref to this SVGViewSpec, so this is kept ali ve as:
37 // AnimatedProperty tearoff -(contextElement)-> SVGSVGElement -(RefPtr)-> SV GViewSpec. 37 // AnimatedProperty tearoff -(contextElement)-> SVGSVGElement -(RefPtr)-> SV GViewSpec.
38 : SVGFitToViewBox(contextElement, PropertyMapPolicySkip) 38 : SVGFitToViewBox(contextElement, PropertyMapPolicySkip)
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 125
126 return m_transform->baseValue()->valueAsString(); 126 return m_transform->baseValue()->valueAsString();
127 } 127 }
128 128
129 void SVGViewSpec::setZoomAndPan(unsigned short, ExceptionState& exceptionState) 129 void SVGViewSpec::setZoomAndPan(unsigned short, ExceptionState& exceptionState)
130 { 130 {
131 // SVGViewSpec and all of its content is read-only. 131 // SVGViewSpec and all of its content is read-only.
132 exceptionState.throwDOMException(NoModificationAllowedError, ExceptionMessag es::readOnly()); 132 exceptionState.throwDOMException(NoModificationAllowedError, ExceptionMessag es::readOnly());
133 } 133 }
134 134
135 static const LChar svgViewSpec[] = {'s', 'v', 'g', 'V', 'i', 'e', 'w'};
136 static const LChar viewBoxSpec[] = {'v', 'i', 'e', 'w', 'B', 'o', 'x'};
137 static const LChar preserveAspectRatioSpec[] = {'p', 'r', 'e', 's', 'e', 'r', 'v ', 'e', 'A', 's', 'p', 'e', 'c', 't', 'R', 'a', 't', 'i', 'o'};
138 static const LChar transformSpec[] = {'t', 'r', 'a', 'n', 's', 'f', 'o', 'r', 'm '};
139 static const LChar zoomAndPanSpec[] = {'z', 'o', 'o', 'm', 'A', 'n', 'd', 'P', ' a', 'n'};
140 static const LChar viewTargetSpec[] = {'v', 'i', 'e', 'w', 'T', 'a', 'r', 'g', 'e', 't'};
141
142 template<typename CharType> 135 template<typename CharType>
143 bool SVGViewSpec::parseViewSpecInternal(const CharType* ptr, const CharType* end ) 136 bool SVGViewSpec::parseViewSpecInternal(const CharType* ptr, const CharType* end )
144 { 137 {
145 if (!skipString(ptr, end, svgViewSpec, WTF_ARRAY_LENGTH(svgViewSpec))) 138 if (!skipToken(ptr, end, "svgView"))
146 return false; 139 return false;
147 140
148 if (ptr >= end || *ptr != '(') 141 if (ptr >= end || *ptr != '(')
149 return false; 142 return false;
150 ptr++; 143 ptr++;
151 144
152 while (ptr < end && *ptr != ')') { 145 while (ptr < end && *ptr != ')') {
153 if (*ptr == 'v') { 146 if (*ptr == 'v') {
154 if (skipString(ptr, end, viewBoxSpec, WTF_ARRAY_LENGTH(viewBoxSpec)) ) { 147 if (skipToken(ptr, end, "viewBox")) {
155 if (ptr >= end || *ptr != '(') 148 if (ptr >= end || *ptr != '(')
156 return false; 149 return false;
157 ptr++; 150 ptr++;
158 float x = 0.0f; 151 float x = 0.0f;
159 float y = 0.0f; 152 float y = 0.0f;
160 float width = 0.0f; 153 float width = 0.0f;
161 float height = 0.0f; 154 float height = 0.0f;
162 if (!(parseNumber(ptr, end, x) && parseNumber(ptr, end, y) && pa rseNumber(ptr, end, width) && parseNumber(ptr, end, height, DisallowWhitespace)) ) 155 if (!(parseNumber(ptr, end, x) && parseNumber(ptr, end, y) && pa rseNumber(ptr, end, width) && parseNumber(ptr, end, height, DisallowWhitespace)) )
163 return false; 156 return false;
164 updateViewBox(FloatRect(x, y, width, height)); 157 updateViewBox(FloatRect(x, y, width, height));
165 if (ptr >= end || *ptr != ')') 158 if (ptr >= end || *ptr != ')')
166 return false; 159 return false;
167 ptr++; 160 ptr++;
168 } else if (skipString(ptr, end, viewTargetSpec, WTF_ARRAY_LENGTH(vie wTargetSpec))) { 161 } else if (skipToken(ptr, end, "viewTarget")) {
169 if (ptr >= end || *ptr != '(') 162 if (ptr >= end || *ptr != '(')
170 return false; 163 return false;
171 const CharType* viewTargetStart = ++ptr; 164 const CharType* viewTargetStart = ++ptr;
172 while (ptr < end && *ptr != ')') 165 while (ptr < end && *ptr != ')')
173 ptr++; 166 ptr++;
174 if (ptr >= end) 167 if (ptr >= end)
175 return false; 168 return false;
176 m_viewTargetString = String(viewTargetStart, ptr - viewTargetSta rt); 169 m_viewTargetString = String(viewTargetStart, ptr - viewTargetSta rt);
177 ptr++; 170 ptr++;
178 } else 171 } else
179 return false; 172 return false;
180 } else if (*ptr == 'z') { 173 } else if (*ptr == 'z') {
181 if (!skipString(ptr, end, zoomAndPanSpec, WTF_ARRAY_LENGTH(zoomAndPa nSpec))) 174 if (!skipToken(ptr, end, "zoomAndPan"))
182 return false; 175 return false;
183 if (ptr >= end || *ptr != '(') 176 if (ptr >= end || *ptr != '(')
184 return false; 177 return false;
185 ptr++; 178 ptr++;
186 if (!parseZoomAndPan(ptr, end)) 179 if (!parseZoomAndPan(ptr, end))
187 return false; 180 return false;
188 if (ptr >= end || *ptr != ')') 181 if (ptr >= end || *ptr != ')')
189 return false; 182 return false;
190 ptr++; 183 ptr++;
191 } else if (*ptr == 'p') { 184 } else if (*ptr == 'p') {
192 if (!skipString(ptr, end, preserveAspectRatioSpec, WTF_ARRAY_LENGTH( preserveAspectRatioSpec))) 185 if (!skipToken(ptr, end, "preserveAspectRatio"))
193 return false; 186 return false;
194 if (ptr >= end || *ptr != '(') 187 if (ptr >= end || *ptr != '(')
195 return false; 188 return false;
196 ptr++; 189 ptr++;
197 if (!preserveAspectRatio()->baseValue()->parse(ptr, end, false)) 190 if (!preserveAspectRatio()->baseValue()->parse(ptr, end, false))
198 return false; 191 return false;
199 if (ptr >= end || *ptr != ')') 192 if (ptr >= end || *ptr != ')')
200 return false; 193 return false;
201 ptr++; 194 ptr++;
202 } else if (*ptr == 't') { 195 } else if (*ptr == 't') {
203 if (!skipString(ptr, end, transformSpec, WTF_ARRAY_LENGTH(transformS pec))) 196 if (!skipToken(ptr, end, "transform"))
204 return false; 197 return false;
205 if (ptr >= end || *ptr != '(') 198 if (ptr >= end || *ptr != '(')
206 return false; 199 return false;
207 ptr++; 200 ptr++;
208 m_transform->baseValue()->parse(ptr, end); 201 m_transform->baseValue()->parse(ptr, end);
209 if (ptr >= end || *ptr != ')') 202 if (ptr >= end || *ptr != ')')
210 return false; 203 return false;
211 ptr++; 204 ptr++;
212 } else 205 } else
213 return false; 206 return false;
214 207
215 if (ptr < end && *ptr == ';') 208 if (ptr < end && *ptr == ';')
216 ptr++; 209 ptr++;
217 } 210 }
218 211
219 if (ptr >= end || *ptr != ')') 212 if (ptr >= end || *ptr != ')')
220 return false; 213 return false;
221 214
222 return true; 215 return true;
223 } 216 }
224 217
225 } // namespace blink 218 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/svg/SVGTransformList.cpp ('k') | third_party/WebKit/Source/core/svg/SVGZoomAndPan.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698