@@ -73,6 +73,36 @@ static Length parseHTMLAreaCoordinate(const CharType* data, unsigned length)
73
73
return Length (0 , Fixed );
74
74
}
75
75
76
+ template <typename CharType>
77
+ static Length parseFrameSetDimension (const CharType* data, unsigned length)
78
+ {
79
+ if (!length)
80
+ return Length (1 , Relative);
81
+
82
+ unsigned intLength;
83
+ unsigned doubleLength;
84
+ unsigned i = splitLength (data, length, intLength, doubleLength);
85
+
86
+ bool ok;
87
+ CharType next = (i < length) ? data[i] : ' ' ;
88
+ if (next == ' %' ) {
89
+ // IE quirk: accept decimal fractions for percentages.
90
+ double r = charactersToDouble (data, doubleLength, &ok);
91
+ if (ok)
92
+ return Length (r, Percent);
93
+ return Length (1 , Relative);
94
+ }
95
+ int r = charactersToIntStrict (data, intLength, &ok);
96
+ if (next == ' *' ) {
97
+ if (ok)
98
+ return Length (r, Relative);
99
+ return Length (1 , Relative);
100
+ }
101
+ if (ok)
102
+ return Length (r, Fixed );
103
+ return Length (0 , Relative);
104
+ }
105
+
76
106
// FIXME: Per HTML5, this should follow the "rules for parsing a list of integers".
77
107
Vector<Length> parseHTMLAreaElementCoords (const String& string)
78
108
{
@@ -110,6 +140,43 @@ Vector<Length> parseHTMLAreaElementCoords(const String& string)
110
140
return r;
111
141
}
112
142
143
+ template <typename CharType>
144
+ static Vector<Length> parseFrameSetListOfDimensionsInternal (StringImpl* str)
145
+ {
146
+ unsigned len = str->count (' ,' ) + 1 ;
147
+ Vector<Length> r (len);
148
+
149
+ int i = 0 ;
150
+ unsigned pos = 0 ;
151
+ size_t pos2;
152
+
153
+ while ((pos2 = str->find (' ,' , pos)) != notFound) {
154
+ r[i++] = parseFrameSetDimension (str->getCharacters <CharType>() + pos, pos2 - pos);
155
+ pos = pos2 + 1 ;
156
+ }
157
+
158
+ ASSERT (i == len - 1 );
159
+
160
+ // IE Quirk: If the last comma is the last char skip it and reduce len by one.
161
+ if (str->length () - pos > 0 )
162
+ r[i] = parseFrameSetDimension (str->getCharacters <CharType>() + pos, str->length () - pos);
163
+ else
164
+ r.shrink (r.size () - 1 );
165
+
166
+ return r;
167
+ }
168
+
169
+ // FIXME: Per HTML5, this should "use the rules for parsing a list of dimensions".
170
+ Vector<Length> parseFrameSetListOfDimensions (const String& string)
171
+ {
172
+ RefPtr<StringImpl> str = string.impl ()->simplifyWhiteSpace ();
173
+ if (!str->length ())
174
+ return Vector<Length>();
175
+ if (str->is8Bit ())
176
+ return parseFrameSetListOfDimensionsInternal<LChar>(str.get ());
177
+ return parseFrameSetListOfDimensionsInternal<UChar>(str.get ());
178
+ }
179
+
113
180
class CalculationValueHandleMap {
114
181
WTF_MAKE_FAST_ALLOCATED;
115
182
public:
0 commit comments