OLD | NEW |
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 "core/svg/SVGAnimationElement.h" | 24 #include "core/svg/SVGAnimationElement.h" |
25 #include "core/svg/SVGParserUtilities.h" | 25 #include "core/svg/SVGParserUtilities.h" |
| 26 #include "platform/ParsingUtilities.h" |
26 #include "platform/geometry/FloatRect.h" | 27 #include "platform/geometry/FloatRect.h" |
27 #include "platform/text/ParserUtilities.h" | |
28 #include "platform/transforms/AffineTransform.h" | 28 #include "platform/transforms/AffineTransform.h" |
29 #include "wtf/text/WTFString.h" | 29 #include "wtf/text/WTFString.h" |
30 | 30 |
31 namespace blink { | 31 namespace blink { |
32 | 32 |
33 SVGPreserveAspectRatio::SVGPreserveAspectRatio() | 33 SVGPreserveAspectRatio::SVGPreserveAspectRatio() |
34 { | 34 { |
35 setDefault(); | 35 setDefault(); |
36 } | 36 } |
37 | 37 |
(...skipping 20 matching lines...) Expand all Loading... |
58 SVGMeetOrSliceType meetOrSlice = SVG_MEETORSLICE_MEET; | 58 SVGMeetOrSliceType meetOrSlice = SVG_MEETORSLICE_MEET; |
59 | 59 |
60 setAlign(align); | 60 setAlign(align); |
61 setMeetOrSlice(meetOrSlice); | 61 setMeetOrSlice(meetOrSlice); |
62 | 62 |
63 const CharType* start = ptr; | 63 const CharType* start = ptr; |
64 if (!skipOptionalSVGSpaces(ptr, end)) | 64 if (!skipOptionalSVGSpaces(ptr, end)) |
65 return SVGParsingError(SVGParseStatus::ExpectedEnumeration, ptr - start)
; | 65 return SVGParsingError(SVGParseStatus::ExpectedEnumeration, ptr - start)
; |
66 | 66 |
67 if (*ptr == 'n') { | 67 if (*ptr == 'n') { |
68 if (!skipString(ptr, end, "none")) | 68 if (!skipToken(ptr, end, "none")) |
69 return SVGParsingError(SVGParseStatus::ExpectedEnumeration, ptr - st
art); | 69 return SVGParsingError(SVGParseStatus::ExpectedEnumeration, ptr - st
art); |
70 align = SVG_PRESERVEASPECTRATIO_NONE; | 70 align = SVG_PRESERVEASPECTRATIO_NONE; |
71 skipOptionalSVGSpaces(ptr, end); | 71 skipOptionalSVGSpaces(ptr, end); |
72 } else if (*ptr == 'x') { | 72 } else if (*ptr == 'x') { |
73 if ((end - ptr) < 8) | 73 if ((end - ptr) < 8) |
74 return SVGParsingError(SVGParseStatus::ExpectedEnumeration, ptr - st
art); | 74 return SVGParsingError(SVGParseStatus::ExpectedEnumeration, ptr - st
art); |
75 if (ptr[1] != 'M' || ptr[4] != 'Y' || ptr[5] != 'M') | 75 if (ptr[1] != 'M' || ptr[4] != 'Y' || ptr[5] != 'M') |
76 return SVGParsingError(SVGParseStatus::ExpectedEnumeration, ptr - st
art); | 76 return SVGParsingError(SVGParseStatus::ExpectedEnumeration, ptr - st
art); |
77 if (ptr[2] == 'i') { | 77 if (ptr[2] == 'i') { |
78 if (ptr[3] == 'n') { | 78 if (ptr[3] == 'n') { |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 return SVGParsingError(SVGParseStatus::ExpectedEnumeration, ptr - st
art); | 121 return SVGParsingError(SVGParseStatus::ExpectedEnumeration, ptr - st
art); |
122 } | 122 } |
123 ptr += 8; | 123 ptr += 8; |
124 skipOptionalSVGSpaces(ptr, end); | 124 skipOptionalSVGSpaces(ptr, end); |
125 } else { | 125 } else { |
126 return SVGParsingError(SVGParseStatus::ExpectedEnumeration, ptr - start)
; | 126 return SVGParsingError(SVGParseStatus::ExpectedEnumeration, ptr - start)
; |
127 } | 127 } |
128 | 128 |
129 if (ptr < end) { | 129 if (ptr < end) { |
130 if (*ptr == 'm') { | 130 if (*ptr == 'm') { |
131 if (!skipString(ptr, end, "meet")) | 131 if (!skipToken(ptr, end, "meet")) |
132 return SVGParsingError(SVGParseStatus::ExpectedEnumeration, ptr
- start); | 132 return SVGParsingError(SVGParseStatus::ExpectedEnumeration, ptr
- start); |
133 skipOptionalSVGSpaces(ptr, end); | 133 skipOptionalSVGSpaces(ptr, end); |
134 } else if (*ptr == 's') { | 134 } else if (*ptr == 's') { |
135 if (!skipString(ptr, end, "slice")) | 135 if (!skipToken(ptr, end, "slice")) |
136 return SVGParsingError(SVGParseStatus::ExpectedEnumeration, ptr
- start); | 136 return SVGParsingError(SVGParseStatus::ExpectedEnumeration, ptr
- start); |
137 skipOptionalSVGSpaces(ptr, end); | 137 skipOptionalSVGSpaces(ptr, end); |
138 if (align != SVG_PRESERVEASPECTRATIO_NONE) | 138 if (align != SVG_PRESERVEASPECTRATIO_NONE) |
139 meetOrSlice = SVG_MEETORSLICE_SLICE; | 139 meetOrSlice = SVG_MEETORSLICE_SLICE; |
140 } | 140 } |
141 } | 141 } |
142 | 142 |
143 if (end != ptr && validate) | 143 if (end != ptr && validate) |
144 return SVGParsingError(SVGParseStatus::TrailingGarbage, ptr - start); | 144 return SVGParsingError(SVGParseStatus::TrailingGarbage, ptr - start); |
145 | 145 |
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
397 m_meetOrSlice = preserveAspectRatioToUse->m_meetOrSlice; | 397 m_meetOrSlice = preserveAspectRatioToUse->m_meetOrSlice; |
398 } | 398 } |
399 | 399 |
400 float SVGPreserveAspectRatio::calculateDistance(SVGPropertyBase* toValue, SVGEle
ment* contextElement) | 400 float SVGPreserveAspectRatio::calculateDistance(SVGPropertyBase* toValue, SVGEle
ment* contextElement) |
401 { | 401 { |
402 // No paced animations for SVGPreserveAspectRatio. | 402 // No paced animations for SVGPreserveAspectRatio. |
403 return -1; | 403 return -1; |
404 } | 404 } |
405 | 405 |
406 } // namespace blink | 406 } // namespace blink |
OLD | NEW |