OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2003 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 2003 Lars Knoll (knoll@kde.org) |
3 * Copyright (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com) | 3 * Copyright (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com) |
4 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc.
All rights reserved. | 4 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc.
All rights reserved. |
5 * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com> | 5 * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com> |
6 * Copyright (C) 2008 Eric Seidel <eric@webkit.org> | 6 * Copyright (C) 2008 Eric Seidel <eric@webkit.org> |
7 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo
bile.com/) | 7 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo
bile.com/) |
8 * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved. | 8 * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved. |
9 * Copyright (C) 2012 Intel Corporation. All rights reserved. | 9 * Copyright (C) 2012 Intel Corporation. All rights reserved. |
10 * | 10 * |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 valueList->next(); | 228 valueList->next(); |
229 return true; | 229 return true; |
230 } | 230 } |
231 | 231 |
232 static inline bool isForwardSlashOperator(CSSParserValue* value) | 232 static inline bool isForwardSlashOperator(CSSParserValue* value) |
233 { | 233 { |
234 ASSERT(value); | 234 ASSERT(value); |
235 return value->m_unit == CSSParserValue::Operator && value->iValue == '/'; | 235 return value->m_unit == CSSParserValue::Operator && value->iValue == '/'; |
236 } | 236 } |
237 | 237 |
238 inline PassRefPtrWillBeRawPtr<CSSPrimitiveValue> CSSPropertyParser::parseValidPr
imitive(CSSValueID identifier, CSSParserValue* value) | |
239 { | |
240 if (identifier) | |
241 return cssValuePool().createIdentifierValue(identifier); | |
242 if (value->unit() >= CSSPrimitiveValue::UnitType::Number && value->unit() <=
CSSPrimitiveValue::UnitType::Kilohertz) | |
243 return createPrimitiveNumericValue(value); | |
244 if (value->unit() >= CSSPrimitiveValue::UnitType::Turns && value->unit() <=
CSSPrimitiveValue::UnitType::Chs) | |
245 return createPrimitiveNumericValue(value); | |
246 if (value->unit() >= CSSPrimitiveValue::UnitType::ViewportWidth && value->un
it() <= CSSPrimitiveValue::UnitType::ViewportMax) | |
247 return createPrimitiveNumericValue(value); | |
248 if (value->unit() >= CSSPrimitiveValue::UnitType::DotsPerPixel && value->uni
t() <= CSSPrimitiveValue::UnitType::DotsPerCentimeter) | |
249 return createPrimitiveNumericValue(value); | |
250 if (value->unit() == CSSPrimitiveValue::UnitType::QuirkyEms) | |
251 return CSSPrimitiveValue::create(value->fValue, CSSPrimitiveValue::UnitT
ype::QuirkyEms); | |
252 if (isCalculation(value)) | |
253 return CSSPrimitiveValue::create(m_parsedCalculation.release()); | |
254 | |
255 return nullptr; | |
256 } | |
257 | |
258 void CSSPropertyParser::addExpandedPropertyForValue(CSSPropertyID propId, PassRe
fPtrWillBeRawPtr<CSSValue> prpValue, bool important) | 238 void CSSPropertyParser::addExpandedPropertyForValue(CSSPropertyID propId, PassRe
fPtrWillBeRawPtr<CSSValue> prpValue, bool important) |
259 { | 239 { |
260 const StylePropertyShorthand& shorthand = shorthandForProperty(propId); | 240 const StylePropertyShorthand& shorthand = shorthandForProperty(propId); |
261 unsigned shorthandLength = shorthand.length(); | 241 unsigned shorthandLength = shorthand.length(); |
262 if (!shorthandLength) { | 242 if (!shorthandLength) { |
263 addProperty(propId, prpValue, important); | 243 addProperty(propId, prpValue, important); |
264 return; | 244 return; |
265 } | 245 } |
266 | 246 |
267 RefPtrWillBeRawPtr<CSSValue> value = prpValue; | 247 RefPtrWillBeRawPtr<CSSValue> value = prpValue; |
268 ShorthandScope scope(this, propId); | 248 ShorthandScope scope(this, propId); |
269 const CSSPropertyID* longhands = shorthand.properties(); | 249 const CSSPropertyID* longhands = shorthand.properties(); |
270 for (unsigned i = 0; i < shorthandLength; ++i) | 250 for (unsigned i = 0; i < shorthandLength; ++i) |
271 addProperty(longhands[i], value, important); | 251 addProperty(longhands[i], value, important); |
272 } | 252 } |
273 | 253 |
274 bool CSSPropertyParser::legacyParseAndApplyValue(CSSPropertyID propertyID, bool
important) | 254 bool CSSPropertyParser::legacyParseAndApplyValue(CSSPropertyID propertyID, bool
important) |
275 { | 255 { |
276 RefPtrWillBeRawPtr<CSSValue> result = legacyParseValue(propertyID); | 256 RefPtrWillBeRawPtr<CSSValue> result = legacyParseValue(propertyID); |
277 if (!result) | 257 if (!result) |
278 return false; | 258 return false; |
279 addProperty(propertyID, result.release(), important); | 259 addProperty(propertyID, result.release(), important); |
280 return true; | 260 return true; |
281 } | 261 } |
282 | 262 |
283 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::legacyParseValue(CSSProperty
ID unresolvedProperty) | 263 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::legacyParseValue(CSSProperty
ID unresolvedProperty) |
284 { | 264 { |
285 CSSPropertyID propId = resolveCSSPropertyID(unresolvedProperty); | 265 CSSPropertyID propId = resolveCSSPropertyID(unresolvedProperty); |
286 | 266 |
287 CSSParserValue* value = m_valueList->current(); | |
288 | |
289 // Note: m_parsedCalculation is used to pass the calc value to validUnit and
then cleared at the end of this function. | 267 // Note: m_parsedCalculation is used to pass the calc value to validUnit and
then cleared at the end of this function. |
290 // FIXME: This is to avoid having to pass parsedCalc to all validUnit caller
s. | 268 // FIXME: This is to avoid having to pass parsedCalc to all validUnit caller
s. |
291 ASSERT(!m_parsedCalculation); | 269 ASSERT(!m_parsedCalculation); |
292 | 270 |
293 CSSValueID id = value->id; | |
294 | |
295 bool validPrimitive = false; | |
296 RefPtrWillBeRawPtr<CSSValue> parsedValue = nullptr; | 271 RefPtrWillBeRawPtr<CSSValue> parsedValue = nullptr; |
297 | 272 |
298 switch (propId) { | 273 switch (propId) { |
299 case CSSPropertyBackgroundColor: // <color> | inherit | 274 case CSSPropertyBackgroundColor: // <color> | inherit |
300 parsedValue = parseColor(m_valueList->current(), inQuirksMode() && !inSh
orthand()); | 275 parsedValue = parseColor(m_valueList->current(), inQuirksMode() && !inSh
orthand()); |
301 if (parsedValue) | 276 if (parsedValue) |
302 m_valueList->next(); | 277 m_valueList->next(); |
303 break; | 278 break; |
304 | 279 |
305 case CSSPropertyImageOrientation: | |
306 if (RuntimeEnabledFeatures::imageOrientationEnabled()) | |
307 validPrimitive = value->id == CSSValueFromImage || (value->unit() !=
CSSPrimitiveValue::UnitType::Number && validUnit(value, FAngle) && value->fValu
e == 0); | |
308 break; | |
309 | |
310 case CSSPropertyBackgroundBlendMode: | 280 case CSSPropertyBackgroundBlendMode: |
311 case CSSPropertyBackgroundAttachment: | 281 case CSSPropertyBackgroundAttachment: |
312 case CSSPropertyBackgroundClip: | 282 case CSSPropertyBackgroundClip: |
313 case CSSPropertyWebkitBackgroundClip: | 283 case CSSPropertyWebkitBackgroundClip: |
314 case CSSPropertyWebkitBackgroundComposite: | 284 case CSSPropertyWebkitBackgroundComposite: |
315 case CSSPropertyBackgroundImage: | 285 case CSSPropertyBackgroundImage: |
316 case CSSPropertyBackgroundOrigin: | 286 case CSSPropertyBackgroundOrigin: |
317 case CSSPropertyMaskSourceType: | 287 case CSSPropertyMaskSourceType: |
318 case CSSPropertyWebkitBackgroundOrigin: | 288 case CSSPropertyWebkitBackgroundOrigin: |
319 case CSSPropertyBackgroundPositionX: | 289 case CSSPropertyBackgroundPositionX: |
320 case CSSPropertyBackgroundPositionY: | 290 case CSSPropertyBackgroundPositionY: |
321 case CSSPropertyBackgroundSize: | 291 case CSSPropertyBackgroundSize: |
322 case CSSPropertyWebkitMaskClip: | 292 case CSSPropertyWebkitMaskClip: |
323 case CSSPropertyWebkitMaskComposite: | 293 case CSSPropertyWebkitMaskComposite: |
324 case CSSPropertyWebkitMaskImage: | 294 case CSSPropertyWebkitMaskImage: |
325 case CSSPropertyWebkitMaskOrigin: | 295 case CSSPropertyWebkitMaskOrigin: |
326 case CSSPropertyWebkitMaskPositionX: | 296 case CSSPropertyWebkitMaskPositionX: |
327 case CSSPropertyWebkitMaskPositionY: | 297 case CSSPropertyWebkitMaskPositionY: |
328 case CSSPropertyWebkitMaskSize: | 298 case CSSPropertyWebkitMaskSize: |
329 case CSSPropertyWebkitMaskRepeatX: | 299 case CSSPropertyWebkitMaskRepeatX: |
330 case CSSPropertyWebkitMaskRepeatY: | 300 case CSSPropertyWebkitMaskRepeatY: |
331 { | 301 { |
332 RefPtrWillBeRawPtr<CSSValue> dummyValue = nullptr; | 302 RefPtrWillBeRawPtr<CSSValue> dummyValue = nullptr; |
333 CSSPropertyID propId1, propId2; | 303 CSSPropertyID propId1, propId2; |
334 if (!parseFillProperty(unresolvedProperty, propId1, propId2, parsedValue
, dummyValue)) | 304 if (!parseFillProperty(unresolvedProperty, propId1, propId2, parsedValue
, dummyValue)) |
335 return nullptr; | 305 return nullptr; |
336 ASSERT(!dummyValue); | 306 ASSERT(!dummyValue); |
337 break; | 307 break; |
338 } | 308 } |
339 case CSSPropertyBottom: // <length> | <percentage> | auto | in
herit | |
340 case CSSPropertyLeft: // <length> | <percentage> | auto | in
herit | |
341 case CSSPropertyRight: // <length> | <percentage> | auto | in
herit | |
342 case CSSPropertyTop: // <length> | <percentage> | auto | in
herit | |
343 if (id == CSSValueAuto) | |
344 validPrimitive = true; | |
345 else | |
346 validPrimitive = validUnit(value, FLength | FPercent | FUnitlessQuir
k); | |
347 break; | |
348 | |
349 case CSSPropertyFontSizeAdjust: // none | <number> | |
350 ASSERT(RuntimeEnabledFeatures::cssFontSizeAdjustEnabled()); | |
351 validPrimitive = (id == CSSValueNone) ? true : validUnit(value, FNumber
| FNonNeg); | |
352 break; | |
353 | |
354 case CSSPropertyJustifySelf: | 309 case CSSPropertyJustifySelf: |
355 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); | 310 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); |
356 parsedValue = parseItemPositionOverflowPosition(); | 311 parsedValue = parseItemPositionOverflowPosition(); |
357 break; | 312 break; |
358 case CSSPropertyJustifyItems: | 313 case CSSPropertyJustifyItems: |
359 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); | 314 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); |
360 | 315 |
361 if ((parsedValue = parseLegacyPosition())) | 316 if ((parsedValue = parseLegacyPosition())) |
362 break; | 317 break; |
363 | 318 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
403 case CSSPropertyAlignItems: | 358 case CSSPropertyAlignItems: |
404 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); | 359 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); |
405 parsedValue = parseItemPositionOverflowPosition(); | 360 parsedValue = parseItemPositionOverflowPosition(); |
406 break; | 361 break; |
407 | 362 |
408 // Everything else is handled in CSSPropertyParser.cpp | 363 // Everything else is handled in CSSPropertyParser.cpp |
409 default: | 364 default: |
410 return nullptr; | 365 return nullptr; |
411 } | 366 } |
412 | 367 |
413 if (validPrimitive) { | |
414 parsedValue = parseValidPrimitive(id, value); | |
415 m_valueList->next(); | |
416 } | |
417 ASSERT(!m_parsedCalculation); | 368 ASSERT(!m_parsedCalculation); |
418 if (parsedValue) { | 369 if (parsedValue) { |
419 if (!m_valueList->current() || inShorthand()) | 370 if (!m_valueList->current() || inShorthand()) |
420 return parsedValue.release(); | 371 return parsedValue.release(); |
421 } | 372 } |
422 return nullptr; | 373 return nullptr; |
423 } | 374 } |
424 | 375 |
425 bool CSSPropertyParser::legacyParseShorthand(CSSPropertyID propertyID, bool impo
rtant) | 376 bool CSSPropertyParser::legacyParseShorthand(CSSPropertyID propertyID, bool impo
rtant) |
426 { | 377 { |
(...skipping 2774 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3201 ASSERT(!m_parsedCalculation); | 3152 ASSERT(!m_parsedCalculation); |
3202 m_parsedCalculation = CSSCalcValue::create(args, range); | 3153 m_parsedCalculation = CSSCalcValue::create(args, range); |
3203 | 3154 |
3204 if (!m_parsedCalculation) | 3155 if (!m_parsedCalculation) |
3205 return false; | 3156 return false; |
3206 | 3157 |
3207 return true; | 3158 return true; |
3208 } | 3159 } |
3209 | 3160 |
3210 } // namespace blink | 3161 } // namespace blink |
OLD | NEW |