Chromium Code Reviews| 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 5400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5411 } | 5411 } |
| 5412 | 5412 |
| 5413 return true; | 5413 return true; |
| 5414 } | 5414 } |
| 5415 | 5415 |
| 5416 // This class tracks parsing state for shadow values. If it goes out of scope ( e.g., due to an early return) | 5416 // This class tracks parsing state for shadow values. If it goes out of scope ( e.g., due to an early return) |
| 5417 // without the allowBreak bit being set, then it will clean up all of the object s and destroy them. | 5417 // without the allowBreak bit being set, then it will clean up all of the object s and destroy them. |
| 5418 class ShadowParseContext { | 5418 class ShadowParseContext { |
| 5419 STACK_ALLOCATED(); | 5419 STACK_ALLOCATED(); |
| 5420 public: | 5420 public: |
| 5421 ShadowParseContext(CSSPropertyID prop, CSSPropertyParser* parser) | 5421 ShadowParseContext(CSSPropertyID prop) |
| 5422 : property(prop) | 5422 : property(prop) |
| 5423 , m_parser(parser) | |
| 5424 , allowX(true) | 5423 , allowX(true) |
| 5425 , allowY(false) | 5424 , allowY(false) |
| 5426 , allowBlur(false) | 5425 , allowBlur(false) |
| 5427 , allowSpread(false) | 5426 , allowSpread(false) |
| 5428 , allowColor(true) | 5427 , allowColor(true) |
| 5429 , allowStyle(prop == CSSPropertyWebkitBoxShadow || prop == CSSPropertyBo xShadow) | 5428 , allowStyle(prop == CSSPropertyWebkitBoxShadow || prop == CSSPropertyBo xShadow) |
| 5430 , allowBreak(true) | 5429 , allowBreak(true) |
| 5431 { | 5430 { |
| 5432 } | 5431 } |
| 5433 | 5432 |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 5454 | 5453 |
| 5455 allowX = true; | 5454 allowX = true; |
| 5456 allowColor = true; | 5455 allowColor = true; |
| 5457 allowBreak = true; | 5456 allowBreak = true; |
| 5458 allowY = false; | 5457 allowY = false; |
| 5459 allowBlur = false; | 5458 allowBlur = false; |
| 5460 allowSpread = false; | 5459 allowSpread = false; |
| 5461 allowStyle = property == CSSPropertyWebkitBoxShadow || property == CSSPr opertyBoxShadow; | 5460 allowStyle = property == CSSPropertyWebkitBoxShadow || property == CSSPr opertyBoxShadow; |
| 5462 } | 5461 } |
| 5463 | 5462 |
| 5464 void commitLength(CSSParserValue* v) | 5463 void commitLength(PassRefPtrWillBeRawPtr<CSSPrimitiveValue> val) |
| 5465 { | 5464 { |
| 5466 RefPtrWillBeRawPtr<CSSPrimitiveValue> val = m_parser->createPrimitiveNum ericValue(v); | |
| 5467 | |
| 5468 if (allowX) { | 5465 if (allowX) { |
| 5469 x = val.release(); | 5466 x = val; |
| 5470 allowX = false; | 5467 allowX = false; |
| 5471 allowY = true; | 5468 allowY = true; |
| 5472 allowColor = false; | 5469 allowColor = false; |
| 5473 allowStyle = false; | 5470 allowStyle = false; |
| 5474 allowBreak = false; | 5471 allowBreak = false; |
| 5475 } else if (allowY) { | 5472 } else if (allowY) { |
| 5476 y = val.release(); | 5473 y = val; |
| 5477 allowY = false; | 5474 allowY = false; |
| 5478 allowBlur = true; | 5475 allowBlur = true; |
| 5479 allowColor = true; | 5476 allowColor = true; |
| 5480 allowStyle = property == CSSPropertyWebkitBoxShadow || property == C SSPropertyBoxShadow; | 5477 allowStyle = property == CSSPropertyWebkitBoxShadow || property == C SSPropertyBoxShadow; |
| 5481 allowBreak = true; | 5478 allowBreak = true; |
| 5482 } else if (allowBlur) { | 5479 } else if (allowBlur) { |
| 5483 blur = val.release(); | 5480 blur = val; |
| 5484 allowBlur = false; | 5481 allowBlur = false; |
| 5485 allowSpread = property == CSSPropertyWebkitBoxShadow || property == CSSPropertyBoxShadow; | 5482 allowSpread = property == CSSPropertyWebkitBoxShadow || property == CSSPropertyBoxShadow; |
| 5486 } else if (allowSpread) { | 5483 } else if (allowSpread) { |
| 5487 spread = val.release(); | 5484 spread = val; |
| 5488 allowSpread = false; | 5485 allowSpread = false; |
| 5489 } | 5486 } |
| 5490 } | 5487 } |
| 5491 | 5488 |
| 5492 void commitColor(PassRefPtrWillBeRawPtr<CSSPrimitiveValue> val) | 5489 void commitColor(PassRefPtrWillBeRawPtr<CSSPrimitiveValue> val) |
| 5493 { | 5490 { |
| 5494 color = val; | 5491 color = val; |
| 5495 allowColor = false; | 5492 allowColor = false; |
| 5496 if (allowX) { | 5493 if (allowX) { |
| 5497 allowStyle = false; | 5494 allowStyle = false; |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 5510 if (allowX) | 5507 if (allowX) |
| 5511 allowBreak = false; | 5508 allowBreak = false; |
| 5512 else { | 5509 else { |
| 5513 allowBlur = false; | 5510 allowBlur = false; |
| 5514 allowSpread = false; | 5511 allowSpread = false; |
| 5515 allowColor = false; | 5512 allowColor = false; |
| 5516 } | 5513 } |
| 5517 } | 5514 } |
| 5518 | 5515 |
| 5519 CSSPropertyID property; | 5516 CSSPropertyID property; |
| 5520 CSSPropertyParser* m_parser; | |
| 5521 | 5517 |
| 5522 RefPtrWillBeMember<CSSValueList> values; | 5518 RefPtrWillBeMember<CSSValueList> values; |
| 5523 RefPtrWillBeMember<CSSPrimitiveValue> x; | 5519 RefPtrWillBeMember<CSSPrimitiveValue> x; |
| 5524 RefPtrWillBeMember<CSSPrimitiveValue> y; | 5520 RefPtrWillBeMember<CSSPrimitiveValue> y; |
| 5525 RefPtrWillBeMember<CSSPrimitiveValue> blur; | 5521 RefPtrWillBeMember<CSSPrimitiveValue> blur; |
| 5526 RefPtrWillBeMember<CSSPrimitiveValue> spread; | 5522 RefPtrWillBeMember<CSSPrimitiveValue> spread; |
| 5527 RefPtrWillBeMember<CSSPrimitiveValue> style; | 5523 RefPtrWillBeMember<CSSPrimitiveValue> style; |
| 5528 RefPtrWillBeMember<CSSPrimitiveValue> color; | 5524 RefPtrWillBeMember<CSSPrimitiveValue> color; |
| 5529 | 5525 |
| 5530 bool allowX; | 5526 bool allowX; |
| 5531 bool allowY; | 5527 bool allowY; |
| 5532 bool allowBlur; | 5528 bool allowBlur; |
| 5533 bool allowSpread; | 5529 bool allowSpread; |
| 5534 bool allowColor; | 5530 bool allowColor; |
| 5535 bool allowStyle; // inset or not. | 5531 bool allowStyle; // inset or not. |
| 5536 bool allowBreak; | 5532 bool allowBreak; |
| 5537 }; | 5533 }; |
| 5538 | 5534 |
| 5539 PassRefPtrWillBeRawPtr<CSSValueList> CSSPropertyParser::parseShadow(CSSParserVal ueList* valueList, CSSPropertyID propId) | 5535 PassRefPtrWillBeRawPtr<CSSValueList> CSSPropertyParser::parseShadow(CSSParserVal ueList* valueList, CSSPropertyID propId) |
| 5540 { | 5536 { |
| 5541 ShadowParseContext context(propId, this); | 5537 ShadowParseContext context(propId); |
| 5542 for (CSSParserValue* val = valueList->current(); val; val = valueList->next( )) { | 5538 for (CSSParserValue* val = valueList->current(); val; val = valueList->next( )) { |
| 5543 // Check for a comma break first. | 5539 // Check for a comma break first. |
| 5544 if (val->unit == CSSParserValue::Operator) { | 5540 if (val->unit == CSSParserValue::Operator) { |
| 5545 if (val->iValue != ',' || !context.allowBreak) { | 5541 if (val->iValue != ',' || !context.allowBreak) { |
| 5546 // Other operators aren't legal or we aren't done with the curre nt shadow | 5542 // Other operators aren't legal or we aren't done with the curre nt shadow |
| 5547 // value. Treat as invalid. | 5543 // value. Treat as invalid. |
| 5548 return nullptr; | 5544 return nullptr; |
| 5549 } | 5545 } |
| 5550 // The value is good. Commit it. | 5546 // The value is good. Commit it. |
| 5551 context.commitValue(); | 5547 context.commitValue(); |
| 5552 } else if (validUnit(val, FLength, HTMLStandardMode)) { | 5548 } else if (validUnit(val, FLength, HTMLStandardMode)) { |
| 5553 // We required a length and didn't get one. Invalid. | 5549 // We required a length and didn't get one. Invalid. |
| 5554 if (!context.allowLength()) | 5550 if (!context.allowLength()) |
| 5555 return nullptr; | 5551 return nullptr; |
| 5556 | 5552 |
| 5557 // Blur radius must be non-negative. | 5553 // Blur radius must be non-negative. |
| 5558 if (context.allowBlur && !validUnit(val, FLength | FNonNeg, HTMLStan dardMode)) | 5554 if (context.allowBlur && !validUnit(val, FLength | FNonNeg, HTMLStan dardMode)) |
| 5559 return nullptr; | 5555 return nullptr; |
| 5560 | 5556 |
| 5561 // A length is allowed here. Construct the value and add it. | 5557 // A length is allowed here. Construct the value and add it. |
| 5562 context.commitLength(val); | 5558 RefPtrWillBeRawPtr<CSSPrimitiveValue> length = createPrimitiveNumeri cValue(val); |
|
Timothy Loh
2015/02/11 02:59:48
Maybe just inline this in the function call
| |
| 5559 context.commitLength(length.release()); | |
| 5563 } else if (val->id == CSSValueInset) { | 5560 } else if (val->id == CSSValueInset) { |
| 5564 if (!context.allowStyle) | 5561 if (!context.allowStyle) |
| 5565 return nullptr; | 5562 return nullptr; |
| 5566 | 5563 |
| 5567 context.commitStyle(val); | 5564 context.commitStyle(val); |
| 5568 } else { | 5565 } else { |
| 5569 // The only other type of value that's ok is a color value. | 5566 // The only other type of value that's ok is a color value. |
| 5570 RefPtrWillBeRawPtr<CSSPrimitiveValue> parsedColor = nullptr; | 5567 RefPtrWillBeRawPtr<CSSPrimitiveValue> parsedColor = nullptr; |
| 5571 bool isColor = ((val->id >= CSSValueAqua && val->id <= CSSValueWindo wtext) || val->id == CSSValueMenu | 5568 bool isColor = ((val->id >= CSSValueAqua && val->id <= CSSValueWindo wtext) || val->id == CSSValueMenu |
| 5572 || (val->id >= CSSValueWebkitFocusRingColor && val-> id <= CSSValueWebkitText && inQuirksMode()) | 5569 || (val->id >= CSSValueWebkitFocusRingColor && val-> id <= CSSValueWebkitText && inQuirksMode()) |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5800 m_requireOutset = false; | 5797 m_requireOutset = false; |
| 5801 m_allowImageSlice = !m_imageSlice; | 5798 m_allowImageSlice = !m_imageSlice; |
| 5802 m_allowImage = !m_image; | 5799 m_allowImage = !m_image; |
| 5803 } | 5800 } |
| 5804 | 5801 |
| 5805 PassRefPtrWillBeRawPtr<CSSValue> commitCSSValue() | 5802 PassRefPtrWillBeRawPtr<CSSValue> commitCSSValue() |
| 5806 { | 5803 { |
| 5807 return createBorderImageValue(m_image, m_imageSlice.get(), m_borderWidth .get(), m_outset.get(), m_repeat.get()); | 5804 return createBorderImageValue(m_image, m_imageSlice.get(), m_borderWidth .get(), m_outset.get(), m_repeat.get()); |
| 5808 } | 5805 } |
| 5809 | 5806 |
| 5810 void commitMaskBoxImage(CSSPropertyParser* parser, bool important) | |
| 5811 { | |
| 5812 commitBorderImageProperty(CSSPropertyWebkitMaskBoxImageSource, parser, m _image, important); | |
| 5813 commitBorderImageProperty(CSSPropertyWebkitMaskBoxImageSlice, parser, m_ imageSlice.get(), important); | |
| 5814 commitBorderImageProperty(CSSPropertyWebkitMaskBoxImageWidth, parser, m_ borderWidth.get(), important); | |
| 5815 commitBorderImageProperty(CSSPropertyWebkitMaskBoxImageOutset, parser, m _outset.get(), important); | |
| 5816 commitBorderImageProperty(CSSPropertyWebkitMaskBoxImageRepeat, parser, m _repeat.get(), important); | |
| 5817 } | |
| 5818 | |
| 5819 void commitBorderImage(CSSPropertyParser* parser, bool important) | |
| 5820 { | |
| 5821 commitBorderImageProperty(CSSPropertyBorderImageSource, parser, m_image, important); | |
| 5822 commitBorderImageProperty(CSSPropertyBorderImageSlice, parser, m_imageSl ice.get(), important); | |
| 5823 commitBorderImageProperty(CSSPropertyBorderImageWidth, parser, m_borderW idth.get(), important); | |
| 5824 commitBorderImageProperty(CSSPropertyBorderImageOutset, parser, m_outset .get(), important); | |
| 5825 commitBorderImageProperty(CSSPropertyBorderImageRepeat, parser, m_repeat , important); | |
| 5826 } | |
| 5827 | |
| 5828 void commitBorderImageProperty(CSSPropertyID propId, CSSPropertyParser* pars er, PassRefPtrWillBeRawPtr<CSSValue> value, bool important) | |
| 5829 { | |
| 5830 if (value) | |
| 5831 parser->addProperty(propId, value, important); | |
| 5832 else | |
| 5833 parser->addProperty(propId, cssValuePool().createImplicitInitialValu e(), important, true); | |
| 5834 } | |
| 5835 | |
| 5836 static bool buildFromParser(CSSPropertyParser&, CSSPropertyID, BorderImagePa rseContext&); | |
| 5837 | |
| 5838 bool m_canAdvance; | 5807 bool m_canAdvance; |
| 5839 | 5808 |
| 5840 bool m_allowCommit; | 5809 bool m_allowCommit; |
| 5841 bool m_allowImage; | 5810 bool m_allowImage; |
| 5842 bool m_allowImageSlice; | 5811 bool m_allowImageSlice; |
| 5843 bool m_allowRepeat; | 5812 bool m_allowRepeat; |
| 5844 bool m_allowForwardSlashOperator; | 5813 bool m_allowForwardSlashOperator; |
| 5845 | 5814 |
| 5846 bool m_allowWidth; | 5815 bool m_allowWidth; |
| 5847 bool m_requireOutset; | 5816 bool m_requireOutset; |
| 5848 | 5817 |
| 5849 RefPtrWillBeMember<CSSValue> m_image; | 5818 RefPtrWillBeMember<CSSValue> m_image; |
| 5850 RefPtrWillBeMember<CSSBorderImageSliceValue> m_imageSlice; | 5819 RefPtrWillBeMember<CSSBorderImageSliceValue> m_imageSlice; |
| 5851 RefPtrWillBeMember<CSSPrimitiveValue> m_borderWidth; | 5820 RefPtrWillBeMember<CSSPrimitiveValue> m_borderWidth; |
| 5852 RefPtrWillBeMember<CSSPrimitiveValue> m_outset; | 5821 RefPtrWillBeMember<CSSPrimitiveValue> m_outset; |
| 5853 | 5822 |
| 5854 RefPtrWillBeMember<CSSValue> m_repeat; | 5823 RefPtrWillBeMember<CSSValue> m_repeat; |
| 5855 }; | 5824 }; |
| 5856 | 5825 |
| 5857 bool BorderImageParseContext::buildFromParser(CSSPropertyParser& parser, CSSProp ertyID propId, BorderImageParseContext& context) | 5826 bool CSSPropertyParser::buildBorderImageParseContext(CSSPropertyID propId, Borde rImageParseContext& context) |
| 5858 { | 5827 { |
| 5859 CSSPropertyParser::ShorthandScope scope(&parser, propId); | 5828 CSSPropertyParser::ShorthandScope scope(this, propId); |
| 5860 while (CSSParserValue* val = parser.m_valueList->current()) { | 5829 while (CSSParserValue* val = m_valueList->current()) { |
| 5861 context.setCanAdvance(false); | 5830 context.setCanAdvance(false); |
| 5862 | 5831 |
| 5863 if (!context.canAdvance() && context.allowForwardSlashOperator() && isFo rwardSlashOperator(val)) | 5832 if (!context.canAdvance() && context.allowForwardSlashOperator() && isFo rwardSlashOperator(val)) |
| 5864 context.commitForwardSlashOperator(); | 5833 context.commitForwardSlashOperator(); |
| 5865 | 5834 |
| 5866 if (!context.canAdvance() && context.allowImage()) { | 5835 if (!context.canAdvance() && context.allowImage()) { |
| 5867 if (val->unit == CSSPrimitiveValue::CSS_URI) { | 5836 if (val->unit == CSSPrimitiveValue::CSS_URI) { |
| 5868 context.commitImage(parser.createCSSImageValueWithReferrer(val-> string, parser.m_context.completeURL(val->string))); | 5837 context.commitImage(createCSSImageValueWithReferrer(val->string, m_context.completeURL(val->string))); |
| 5869 } else if (isGeneratedImageValue(val)) { | 5838 } else if (isGeneratedImageValue(val)) { |
| 5870 RefPtrWillBeRawPtr<CSSValue> value = nullptr; | 5839 RefPtrWillBeRawPtr<CSSValue> value = nullptr; |
| 5871 if (parser.parseGeneratedImage(parser.m_valueList, value)) | 5840 if (parseGeneratedImage(m_valueList, value)) |
| 5872 context.commitImage(value.release()); | 5841 context.commitImage(value.release()); |
| 5873 else | 5842 else |
| 5874 return false; | 5843 return false; |
| 5875 } else if (val->unit == CSSParserValue::Function && val->function->i d == CSSValueWebkitImageSet) { | 5844 } else if (val->unit == CSSParserValue::Function && val->function->i d == CSSValueWebkitImageSet) { |
| 5876 RefPtrWillBeRawPtr<CSSValue> value = parser.parseImageSet(parser .m_valueList); | 5845 RefPtrWillBeRawPtr<CSSValue> value = parseImageSet(m_valueList); |
| 5877 if (value) | 5846 if (value) |
| 5878 context.commitImage(value.release()); | 5847 context.commitImage(value.release()); |
| 5879 else | 5848 else |
| 5880 return false; | 5849 return false; |
| 5881 } else if (val->id == CSSValueNone) | 5850 } else if (val->id == CSSValueNone) |
| 5882 context.commitImage(cssValuePool().createIdentifierValue(CSSValu eNone)); | 5851 context.commitImage(cssValuePool().createIdentifierValue(CSSValu eNone)); |
| 5883 } | 5852 } |
| 5884 | 5853 |
| 5885 if (!context.canAdvance() && context.allowImageSlice()) { | 5854 if (!context.canAdvance() && context.allowImageSlice()) { |
| 5886 RefPtrWillBeRawPtr<CSSBorderImageSliceValue> imageSlice = nullptr; | 5855 RefPtrWillBeRawPtr<CSSBorderImageSliceValue> imageSlice = nullptr; |
| 5887 if (parser.parseBorderImageSlice(propId, imageSlice)) | 5856 if (parseBorderImageSlice(propId, imageSlice)) |
| 5888 context.commitImageSlice(imageSlice.release()); | 5857 context.commitImageSlice(imageSlice.release()); |
| 5889 } | 5858 } |
| 5890 | 5859 |
| 5891 if (!context.canAdvance() && context.allowRepeat()) { | 5860 if (!context.canAdvance() && context.allowRepeat()) { |
| 5892 RefPtrWillBeRawPtr<CSSValue> repeat = nullptr; | 5861 RefPtrWillBeRawPtr<CSSValue> repeat = nullptr; |
| 5893 if (parser.parseBorderImageRepeat(repeat)) | 5862 if (parseBorderImageRepeat(repeat)) |
| 5894 context.commitRepeat(repeat.release()); | 5863 context.commitRepeat(repeat.release()); |
| 5895 } | 5864 } |
| 5896 | 5865 |
| 5897 if (!context.canAdvance() && context.allowWidth()) { | 5866 if (!context.canAdvance() && context.allowWidth()) { |
| 5898 RefPtrWillBeRawPtr<CSSPrimitiveValue> borderWidth = nullptr; | 5867 RefPtrWillBeRawPtr<CSSPrimitiveValue> borderWidth = nullptr; |
| 5899 if (parser.parseBorderImageWidth(borderWidth)) | 5868 if (parseBorderImageWidth(borderWidth)) |
| 5900 context.commitBorderWidth(borderWidth.release()); | 5869 context.commitBorderWidth(borderWidth.release()); |
| 5901 } | 5870 } |
| 5902 | 5871 |
| 5903 if (!context.canAdvance() && context.requireOutset()) { | 5872 if (!context.canAdvance() && context.requireOutset()) { |
| 5904 RefPtrWillBeRawPtr<CSSPrimitiveValue> borderOutset = nullptr; | 5873 RefPtrWillBeRawPtr<CSSPrimitiveValue> borderOutset = nullptr; |
| 5905 if (parser.parseBorderImageOutset(borderOutset)) | 5874 if (parseBorderImageOutset(borderOutset)) |
| 5906 context.commitBorderOutset(borderOutset.release()); | 5875 context.commitBorderOutset(borderOutset.release()); |
| 5907 } | 5876 } |
| 5908 | 5877 |
| 5909 if (!context.canAdvance()) | 5878 if (!context.canAdvance()) |
| 5910 return false; | 5879 return false; |
| 5911 | 5880 |
| 5912 parser.m_valueList->next(); | 5881 m_valueList->next(); |
| 5913 } | 5882 } |
| 5914 | 5883 |
| 5915 return context.allowCommit(); | 5884 return context.allowCommit(); |
| 5916 } | 5885 } |
| 5917 | 5886 |
| 5887 void CSSPropertyParser::commitBorderImageProperty(CSSPropertyID propId, PassRefP trWillBeRawPtr<CSSValue> value, bool important) | |
| 5888 { | |
| 5889 if (value) | |
| 5890 addProperty(propId, value, important); | |
| 5891 else | |
| 5892 addProperty(propId, cssValuePool().createImplicitInitialValue(), importa nt, true); | |
| 5893 } | |
| 5894 | |
| 5918 bool CSSPropertyParser::parseBorderImageShorthand(CSSPropertyID propId, bool imp ortant) | 5895 bool CSSPropertyParser::parseBorderImageShorthand(CSSPropertyID propId, bool imp ortant) |
| 5919 { | 5896 { |
| 5920 BorderImageParseContext context; | 5897 BorderImageParseContext context; |
| 5921 if (BorderImageParseContext::buildFromParser(*this, propId, context)) { | 5898 if (buildBorderImageParseContext(propId, context)) { |
| 5922 switch (propId) { | 5899 switch (propId) { |
| 5923 case CSSPropertyWebkitMaskBoxImage: | 5900 case CSSPropertyWebkitMaskBoxImage: |
| 5924 context.commitMaskBoxImage(this, important); | 5901 commitBorderImageProperty(CSSPropertyWebkitMaskBoxImageSource, conte xt.m_image, important); |
| 5902 commitBorderImageProperty(CSSPropertyWebkitMaskBoxImageSlice, contex t.m_imageSlice.get(), important); | |
| 5903 commitBorderImageProperty(CSSPropertyWebkitMaskBoxImageWidth, contex t.m_borderWidth.get(), important); | |
| 5904 commitBorderImageProperty(CSSPropertyWebkitMaskBoxImageOutset, conte xt.m_outset.get(), important); | |
| 5905 commitBorderImageProperty(CSSPropertyWebkitMaskBoxImageRepeat, conte xt.m_repeat.get(), important); | |
| 5925 return true; | 5906 return true; |
| 5926 case CSSPropertyBorderImage: | 5907 case CSSPropertyBorderImage: |
| 5927 context.commitBorderImage(this, important); | 5908 commitBorderImageProperty(CSSPropertyBorderImageSource, context.m_im age, important); |
| 5909 commitBorderImageProperty(CSSPropertyBorderImageSlice, context.m_ima geSlice.get(), important); | |
| 5910 commitBorderImageProperty(CSSPropertyBorderImageWidth, context.m_bor derWidth.get(), important); | |
| 5911 commitBorderImageProperty(CSSPropertyBorderImageOutset, context.m_ou tset.get(), important); | |
| 5912 commitBorderImageProperty(CSSPropertyBorderImageRepeat, context.m_re peat, important); | |
| 5928 return true; | 5913 return true; |
| 5929 default: | 5914 default: |
| 5930 ASSERT_NOT_REACHED(); | 5915 ASSERT_NOT_REACHED(); |
| 5931 return false; | 5916 return false; |
| 5932 } | 5917 } |
| 5933 } | 5918 } |
| 5934 return false; | 5919 return false; |
| 5935 } | 5920 } |
| 5936 | 5921 |
| 5937 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseBorderImage(CSSProperty ID propId) | 5922 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseBorderImage(CSSProperty ID propId) |
| 5938 { | 5923 { |
| 5939 BorderImageParseContext context; | 5924 BorderImageParseContext context; |
| 5940 if (BorderImageParseContext::buildFromParser(*this, propId, context)) { | 5925 if (buildBorderImageParseContext(propId, context)) { |
| 5941 return context.commitCSSValue(); | 5926 return context.commitCSSValue(); |
| 5942 } | 5927 } |
| 5943 return nullptr; | 5928 return nullptr; |
| 5944 } | 5929 } |
| 5945 | 5930 |
| 5946 static bool isBorderImageRepeatKeyword(int id) | 5931 static bool isBorderImageRepeatKeyword(int id) |
| 5947 { | 5932 { |
| 5948 return id == CSSValueStretch || id == CSSValueRepeat || id == CSSValueSpace || id == CSSValueRound; | 5933 return id == CSSValueStretch || id == CSSValueRepeat || id == CSSValueSpace || id == CSSValueRound; |
| 5949 } | 5934 } |
| 5950 | 5935 |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 5976 } else | 5961 } else |
| 5977 secondValue = firstValue; | 5962 secondValue = firstValue; |
| 5978 | 5963 |
| 5979 result = createPrimitiveValuePair(firstValue, secondValue); | 5964 result = createPrimitiveValuePair(firstValue, secondValue); |
| 5980 return true; | 5965 return true; |
| 5981 } | 5966 } |
| 5982 | 5967 |
| 5983 class BorderImageSliceParseContext { | 5968 class BorderImageSliceParseContext { |
| 5984 STACK_ALLOCATED(); | 5969 STACK_ALLOCATED(); |
| 5985 public: | 5970 public: |
| 5986 BorderImageSliceParseContext(CSSPropertyParser* parser) | 5971 BorderImageSliceParseContext() |
| 5987 : m_parser(parser) | 5972 : m_allowNumber(true) |
| 5988 , m_allowNumber(true) | |
| 5989 , m_allowFill(true) | 5973 , m_allowFill(true) |
| 5990 , m_allowFinalCommit(false) | 5974 , m_allowFinalCommit(false) |
| 5991 , m_fill(false) | 5975 , m_fill(false) |
| 5992 { } | 5976 { } |
| 5993 | 5977 |
| 5994 bool allowNumber() const { return m_allowNumber; } | 5978 bool allowNumber() const { return m_allowNumber; } |
| 5995 bool allowFill() const { return m_allowFill; } | 5979 bool allowFill() const { return m_allowFill; } |
| 5996 bool allowFinalCommit() const { return m_allowFinalCommit; } | 5980 bool allowFinalCommit() const { return m_allowFinalCommit; } |
| 5997 CSSPrimitiveValue* top() const { return m_top.get(); } | 5981 CSSPrimitiveValue* top() const { return m_top.get(); } |
| 5998 | 5982 |
| 5999 void commitNumber(CSSParserValue* v) | 5983 void commitNumber(PassRefPtrWillBeRawPtr<CSSPrimitiveValue> val) |
| 6000 { | 5984 { |
| 6001 RefPtrWillBeRawPtr<CSSPrimitiveValue> val = m_parser->createPrimitiveNum ericValue(v); | |
| 6002 if (!m_top) | 5985 if (!m_top) |
| 6003 m_top = val; | 5986 m_top = val; |
| 6004 else if (!m_right) | 5987 else if (!m_right) |
| 6005 m_right = val; | 5988 m_right = val; |
| 6006 else if (!m_bottom) | 5989 else if (!m_bottom) |
| 6007 m_bottom = val; | 5990 m_bottom = val; |
| 6008 else { | 5991 else { |
| 6009 ASSERT(!m_left); | 5992 ASSERT(!m_left); |
| 6010 m_left = val; | 5993 m_left = val; |
| 6011 } | 5994 } |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 6037 quad->setTop(m_top); | 6020 quad->setTop(m_top); |
| 6038 quad->setRight(m_right); | 6021 quad->setRight(m_right); |
| 6039 quad->setBottom(m_bottom); | 6022 quad->setBottom(m_bottom); |
| 6040 quad->setLeft(m_left); | 6023 quad->setLeft(m_left); |
| 6041 | 6024 |
| 6042 // Make our new border image value now. | 6025 // Make our new border image value now. |
| 6043 return CSSBorderImageSliceValue::create(cssValuePool().createValue(quad. release()), m_fill); | 6026 return CSSBorderImageSliceValue::create(cssValuePool().createValue(quad. release()), m_fill); |
| 6044 } | 6027 } |
| 6045 | 6028 |
| 6046 private: | 6029 private: |
| 6047 CSSPropertyParser* m_parser; | |
| 6048 | |
| 6049 bool m_allowNumber; | 6030 bool m_allowNumber; |
| 6050 bool m_allowFill; | 6031 bool m_allowFill; |
| 6051 bool m_allowFinalCommit; | 6032 bool m_allowFinalCommit; |
| 6052 | 6033 |
| 6053 RefPtrWillBeMember<CSSPrimitiveValue> m_top; | 6034 RefPtrWillBeMember<CSSPrimitiveValue> m_top; |
| 6054 RefPtrWillBeMember<CSSPrimitiveValue> m_right; | 6035 RefPtrWillBeMember<CSSPrimitiveValue> m_right; |
| 6055 RefPtrWillBeMember<CSSPrimitiveValue> m_bottom; | 6036 RefPtrWillBeMember<CSSPrimitiveValue> m_bottom; |
| 6056 RefPtrWillBeMember<CSSPrimitiveValue> m_left; | 6037 RefPtrWillBeMember<CSSPrimitiveValue> m_left; |
| 6057 | 6038 |
| 6058 bool m_fill; | 6039 bool m_fill; |
| 6059 }; | 6040 }; |
| 6060 | 6041 |
| 6061 bool CSSPropertyParser::parseBorderImageSlice(CSSPropertyID propId, RefPtrWillBe RawPtr<CSSBorderImageSliceValue>& result) | 6042 bool CSSPropertyParser::parseBorderImageSlice(CSSPropertyID propId, RefPtrWillBe RawPtr<CSSBorderImageSliceValue>& result) |
| 6062 { | 6043 { |
| 6063 BorderImageSliceParseContext context(this); | 6044 BorderImageSliceParseContext context; |
| 6064 for (CSSParserValue* val = m_valueList->current(); val; val = m_valueList->n ext()) { | 6045 for (CSSParserValue* val = m_valueList->current(); val; val = m_valueList->n ext()) { |
| 6065 // FIXME calc() http://webkit.org/b/16662 : calc is parsed but values ar e not created yet. | 6046 // FIXME calc() http://webkit.org/b/16662 : calc is parsed but values ar e not created yet. |
| 6066 if (context.allowNumber() && !isCalculation(val) && validUnit(val, FInte ger | FNonNeg | FPercent)) { | 6047 if (context.allowNumber() && !isCalculation(val) && validUnit(val, FInte ger | FNonNeg | FPercent)) { |
| 6067 context.commitNumber(val); | 6048 context.commitNumber(createPrimitiveNumericValue(val)); |
| 6068 } else if (context.allowFill() && val->id == CSSValueFill) { | 6049 } else if (context.allowFill() && val->id == CSSValueFill) { |
| 6069 context.commitFill(); | 6050 context.commitFill(); |
| 6070 } else if (!inShorthand()) { | 6051 } else if (!inShorthand()) { |
| 6071 // If we're not parsing a shorthand then we are invalid. | 6052 // If we're not parsing a shorthand then we are invalid. |
| 6072 return false; | 6053 return false; |
| 6073 } else { | 6054 } else { |
| 6074 if (context.allowFinalCommit()) { | 6055 if (context.allowFinalCommit()) { |
| 6075 // We're going to successfully parse, but we don't want to consu me this token. | 6056 // We're going to successfully parse, but we don't want to consu me this token. |
| 6076 m_valueList->previous(); | 6057 m_valueList->previous(); |
| 6077 } | 6058 } |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 6089 result = context.commitBorderImageSlice(); | 6070 result = context.commitBorderImageSlice(); |
| 6090 return true; | 6071 return true; |
| 6091 } | 6072 } |
| 6092 | 6073 |
| 6093 return false; | 6074 return false; |
| 6094 } | 6075 } |
| 6095 | 6076 |
| 6096 class BorderImageQuadParseContext { | 6077 class BorderImageQuadParseContext { |
| 6097 STACK_ALLOCATED(); | 6078 STACK_ALLOCATED(); |
| 6098 public: | 6079 public: |
| 6099 BorderImageQuadParseContext(CSSPropertyParser* parser) | 6080 BorderImageQuadParseContext() |
| 6100 : m_parser(parser) | 6081 : m_allowNumber(true) |
| 6101 , m_allowNumber(true) | |
| 6102 , m_allowFinalCommit(false) | 6082 , m_allowFinalCommit(false) |
| 6103 { } | 6083 { } |
| 6104 | 6084 |
| 6105 bool allowNumber() const { return m_allowNumber; } | 6085 bool allowNumber() const { return m_allowNumber; } |
| 6106 bool allowFinalCommit() const { return m_allowFinalCommit; } | 6086 bool allowFinalCommit() const { return m_allowFinalCommit; } |
| 6107 CSSPrimitiveValue* top() const { return m_top.get(); } | 6087 CSSPrimitiveValue* top() const { return m_top.get(); } |
| 6108 | 6088 |
| 6109 void commitNumber(CSSParserValue* v) | 6089 void commitNumber(PassRefPtrWillBeRawPtr<CSSPrimitiveValue> val) |
| 6110 { | 6090 { |
| 6111 RefPtrWillBeRawPtr<CSSPrimitiveValue> val = nullptr; | |
| 6112 if (v->id == CSSValueAuto) | |
| 6113 val = cssValuePool().createIdentifierValue(v->id); | |
| 6114 else | |
| 6115 val = m_parser->createPrimitiveNumericValue(v); | |
| 6116 | |
| 6117 if (!m_top) | 6091 if (!m_top) |
| 6118 m_top = val; | 6092 m_top = val; |
| 6119 else if (!m_right) | 6093 else if (!m_right) |
| 6120 m_right = val; | 6094 m_right = val; |
| 6121 else if (!m_bottom) | 6095 else if (!m_bottom) |
| 6122 m_bottom = val; | 6096 m_bottom = val; |
| 6123 else { | 6097 else { |
| 6124 ASSERT(!m_left); | 6098 ASSERT(!m_left); |
| 6125 m_left = val; | 6099 m_left = val; |
| 6126 } | 6100 } |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 6152 quad->setTop(m_top); | 6126 quad->setTop(m_top); |
| 6153 quad->setRight(m_right); | 6127 quad->setRight(m_right); |
| 6154 quad->setBottom(m_bottom); | 6128 quad->setBottom(m_bottom); |
| 6155 quad->setLeft(m_left); | 6129 quad->setLeft(m_left); |
| 6156 | 6130 |
| 6157 // Make our new value now. | 6131 // Make our new value now. |
| 6158 return cssValuePool().createValue(quad.release()); | 6132 return cssValuePool().createValue(quad.release()); |
| 6159 } | 6133 } |
| 6160 | 6134 |
| 6161 private: | 6135 private: |
| 6162 CSSPropertyParser* m_parser; | |
| 6163 | |
| 6164 bool m_allowNumber; | 6136 bool m_allowNumber; |
| 6165 bool m_allowFinalCommit; | 6137 bool m_allowFinalCommit; |
| 6166 | 6138 |
| 6167 RefPtrWillBeMember<CSSPrimitiveValue> m_top; | 6139 RefPtrWillBeMember<CSSPrimitiveValue> m_top; |
| 6168 RefPtrWillBeMember<CSSPrimitiveValue> m_right; | 6140 RefPtrWillBeMember<CSSPrimitiveValue> m_right; |
| 6169 RefPtrWillBeMember<CSSPrimitiveValue> m_bottom; | 6141 RefPtrWillBeMember<CSSPrimitiveValue> m_bottom; |
| 6170 RefPtrWillBeMember<CSSPrimitiveValue> m_left; | 6142 RefPtrWillBeMember<CSSPrimitiveValue> m_left; |
| 6171 }; | 6143 }; |
| 6172 | 6144 |
| 6173 bool CSSPropertyParser::parseBorderImageQuad(Units validUnits, RefPtrWillBeRawPt r<CSSPrimitiveValue>& result) | 6145 bool CSSPropertyParser::parseBorderImageQuad(Units validUnits, RefPtrWillBeRawPt r<CSSPrimitiveValue>& result) |
| 6174 { | 6146 { |
| 6175 BorderImageQuadParseContext context(this); | 6147 BorderImageQuadParseContext context; |
| 6176 for (CSSParserValue* val = m_valueList->current(); val; val = m_valueList->n ext()) { | 6148 for (CSSParserValue* val = m_valueList->current(); val; val = m_valueList->n ext()) { |
| 6177 if (context.allowNumber() && (validUnit(val, validUnits, HTMLStandardMod e) || val->id == CSSValueAuto)) { | 6149 if (context.allowNumber() && (validUnit(val, validUnits, HTMLStandardMod e) || val->id == CSSValueAuto)) { |
| 6178 context.commitNumber(val); | 6150 if (val->id == CSSValueAuto) |
| 6151 context.commitNumber(cssValuePool().createIdentifierValue(val->i d)); | |
| 6152 else | |
| 6153 context.commitNumber(createPrimitiveNumericValue(val)); | |
| 6179 } else if (!inShorthand()) { | 6154 } else if (!inShorthand()) { |
| 6180 // If we're not parsing a shorthand then we are invalid. | 6155 // If we're not parsing a shorthand then we are invalid. |
| 6181 return false; | 6156 return false; |
| 6182 } else { | 6157 } else { |
| 6183 if (context.allowFinalCommit()) | 6158 if (context.allowFinalCommit()) |
| 6184 m_valueList->previous(); // The shorthand loop will advance back to this point. | 6159 m_valueList->previous(); // The shorthand loop will advance back to this point. |
| 6185 break; | 6160 break; |
| 6186 } | 6161 } |
| 6187 } | 6162 } |
| 6188 | 6163 |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6306 || (a->id == CSSValueBottom && !horizontal)) | 6281 || (a->id == CSSValueBottom && !horizontal)) |
| 6307 result = cssValuePool().createValue(100., CSSPrimitiveValue::CSS_PER CENTAGE); | 6282 result = cssValuePool().createValue(100., CSSPrimitiveValue::CSS_PER CENTAGE); |
| 6308 else if (a->id == CSSValueCenter) | 6283 else if (a->id == CSSValueCenter) |
| 6309 result = cssValuePool().createValue(50., CSSPrimitiveValue::CSS_PERC ENTAGE); | 6284 result = cssValuePool().createValue(50., CSSPrimitiveValue::CSS_PERC ENTAGE); |
| 6310 } else if (a->unit == CSSPrimitiveValue::CSS_NUMBER || a->unit == CSSPrimiti veValue::CSS_PERCENTAGE) { | 6285 } else if (a->unit == CSSPrimitiveValue::CSS_NUMBER || a->unit == CSSPrimiti veValue::CSS_PERCENTAGE) { |
| 6311 result = cssValuePool().createValue(a->fValue, static_cast<CSSPrimitiveV alue::UnitType>(a->unit)); | 6286 result = cssValuePool().createValue(a->fValue, static_cast<CSSPrimitiveV alue::UnitType>(a->unit)); |
| 6312 } | 6287 } |
| 6313 return result; | 6288 return result; |
| 6314 } | 6289 } |
| 6315 | 6290 |
| 6316 bool parseDeprecatedGradientColorStop(CSSPropertyParser* p, CSSParserValue* a, C SSGradientColorStop& stop) | 6291 bool CSSPropertyParser::parseDeprecatedGradientColorStop(CSSParserValue* a, CSSG radientColorStop& stop) |
| 6317 { | 6292 { |
| 6318 if (a->unit != CSSParserValue::Function) | 6293 if (a->unit != CSSParserValue::Function) |
| 6319 return false; | 6294 return false; |
| 6320 | 6295 |
| 6321 if (a->function->id != CSSValueFrom | 6296 if (a->function->id != CSSValueFrom |
| 6322 && a->function->id != CSSValueTo | 6297 && a->function->id != CSSValueTo |
| 6323 && a->function->id != CSSValueColorStop) | 6298 && a->function->id != CSSValueColorStop) |
| 6324 return false; | 6299 return false; |
| 6325 | 6300 |
| 6326 CSSParserValueList* args = a->function->args.get(); | 6301 CSSParserValueList* args = a->function->args.get(); |
| 6327 if (!args) | 6302 if (!args) |
| 6328 return false; | 6303 return false; |
| 6329 | 6304 |
| 6330 if (a->function->id == CSSValueFrom || a->function->id == CSSValueTo) { | 6305 if (a->function->id == CSSValueFrom || a->function->id == CSSValueTo) { |
| 6331 // The "from" and "to" stops expect 1 argument. | 6306 // The "from" and "to" stops expect 1 argument. |
| 6332 if (args->size() != 1) | 6307 if (args->size() != 1) |
| 6333 return false; | 6308 return false; |
| 6334 | 6309 |
| 6335 if (a->function->id == CSSValueFrom) | 6310 if (a->function->id == CSSValueFrom) |
| 6336 stop.m_position = cssValuePool().createValue(0, CSSPrimitiveValue::C SS_NUMBER); | 6311 stop.m_position = cssValuePool().createValue(0, CSSPrimitiveValue::C SS_NUMBER); |
| 6337 else | 6312 else |
| 6338 stop.m_position = cssValuePool().createValue(1, CSSPrimitiveValue::C SS_NUMBER); | 6313 stop.m_position = cssValuePool().createValue(1, CSSPrimitiveValue::C SS_NUMBER); |
| 6339 | 6314 |
| 6340 CSSValueID id = args->current()->id; | 6315 CSSValueID id = args->current()->id; |
| 6341 if (id == CSSValueWebkitText || (id >= CSSValueAqua && id <= CSSValueWin dowtext) || id == CSSValueMenu) | 6316 if (id == CSSValueWebkitText || (id >= CSSValueAqua && id <= CSSValueWin dowtext) || id == CSSValueMenu) |
| 6342 stop.m_color = cssValuePool().createIdentifierValue(id); | 6317 stop.m_color = cssValuePool().createIdentifierValue(id); |
| 6343 else | 6318 else |
| 6344 stop.m_color = p->parseColor(args->current()); | 6319 stop.m_color = parseColor(args->current()); |
| 6345 if (!stop.m_color) | 6320 if (!stop.m_color) |
| 6346 return false; | 6321 return false; |
| 6347 } | 6322 } |
| 6348 | 6323 |
| 6349 // The "color-stop" function expects 3 arguments. | 6324 // The "color-stop" function expects 3 arguments. |
| 6350 if (a->function->id == CSSValueColorStop) { | 6325 if (a->function->id == CSSValueColorStop) { |
| 6351 if (args->size() != 3) | 6326 if (args->size() != 3) |
| 6352 return false; | 6327 return false; |
| 6353 | 6328 |
| 6354 CSSParserValue* stopArg = args->current(); | 6329 CSSParserValue* stopArg = args->current(); |
| 6355 if (stopArg->unit == CSSPrimitiveValue::CSS_PERCENTAGE) | 6330 if (stopArg->unit == CSSPrimitiveValue::CSS_PERCENTAGE) |
| 6356 stop.m_position = cssValuePool().createValue(stopArg->fValue / 100, CSSPrimitiveValue::CSS_NUMBER); | 6331 stop.m_position = cssValuePool().createValue(stopArg->fValue / 100, CSSPrimitiveValue::CSS_NUMBER); |
| 6357 else if (stopArg->unit == CSSPrimitiveValue::CSS_NUMBER) | 6332 else if (stopArg->unit == CSSPrimitiveValue::CSS_NUMBER) |
| 6358 stop.m_position = cssValuePool().createValue(stopArg->fValue, CSSPri mitiveValue::CSS_NUMBER); | 6333 stop.m_position = cssValuePool().createValue(stopArg->fValue, CSSPri mitiveValue::CSS_NUMBER); |
| 6359 else | 6334 else |
| 6360 return false; | 6335 return false; |
| 6361 | 6336 |
| 6362 args->next(); | 6337 args->next(); |
| 6363 if (!consumeComma(args)) | 6338 if (!consumeComma(args)) |
| 6364 return false; | 6339 return false; |
| 6365 | 6340 |
| 6366 stopArg = args->current(); | 6341 stopArg = args->current(); |
| 6367 CSSValueID id = stopArg->id; | 6342 CSSValueID id = stopArg->id; |
| 6368 if (id == CSSValueWebkitText || (id >= CSSValueAqua && id <= CSSValueWin dowtext) || id == CSSValueMenu) | 6343 if (id == CSSValueWebkitText || (id >= CSSValueAqua && id <= CSSValueWin dowtext) || id == CSSValueMenu) |
| 6369 stop.m_color = cssValuePool().createIdentifierValue(id); | 6344 stop.m_color = cssValuePool().createIdentifierValue(id); |
| 6370 else | 6345 else |
| 6371 stop.m_color = p->parseColor(stopArg); | 6346 stop.m_color = parseColor(stopArg); |
| 6372 if (!stop.m_color) | 6347 if (!stop.m_color) |
| 6373 return false; | 6348 return false; |
| 6374 } | 6349 } |
| 6375 | 6350 |
| 6376 return true; | 6351 return true; |
| 6377 } | 6352 } |
| 6378 | 6353 |
| 6379 bool CSSPropertyParser::parseDeprecatedGradient(CSSParserValueList* valueList, R efPtrWillBeRawPtr<CSSValue>& gradient) | 6354 bool CSSPropertyParser::parseDeprecatedGradient(CSSParserValueList* valueList, R efPtrWillBeRawPtr<CSSValue>& gradient) |
| 6380 { | 6355 { |
| 6381 // Walk the arguments. | 6356 // Walk the arguments. |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6490 if (!consumeComma(args)) | 6465 if (!consumeComma(args)) |
| 6491 return false; | 6466 return false; |
| 6492 | 6467 |
| 6493 // Now examine the stop itself. | 6468 // Now examine the stop itself. |
| 6494 a = args->current(); | 6469 a = args->current(); |
| 6495 if (!a) | 6470 if (!a) |
| 6496 return false; | 6471 return false; |
| 6497 | 6472 |
| 6498 // The function name needs to be one of "from", "to", or "color-stop." | 6473 // The function name needs to be one of "from", "to", or "color-stop." |
| 6499 CSSGradientColorStop stop; | 6474 CSSGradientColorStop stop; |
| 6500 if (!parseDeprecatedGradientColorStop(this, a, stop)) | 6475 if (!parseDeprecatedGradientColorStop(a, stop)) |
| 6501 return false; | 6476 return false; |
| 6502 result->addStop(stop); | 6477 result->addStop(stop); |
| 6503 | 6478 |
| 6504 // Advance | 6479 // Advance |
| 6505 a = args->next(); | 6480 a = args->next(); |
| 6506 } | 6481 } |
| 6507 | 6482 |
| 6508 gradient = result.release(); | 6483 gradient = result.release(); |
| 6509 return true; | 6484 return true; |
| 6510 } | 6485 } |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 6522 case CSSValueTop: | 6497 case CSSValueTop: |
| 6523 case CSSValueBottom: | 6498 case CSSValueBottom: |
| 6524 isHorizontal = false; | 6499 isHorizontal = false; |
| 6525 break; | 6500 break; |
| 6526 default: | 6501 default: |
| 6527 return nullptr; | 6502 return nullptr; |
| 6528 } | 6503 } |
| 6529 return cssValuePool().createIdentifierValue(a->id); | 6504 return cssValuePool().createIdentifierValue(a->id); |
| 6530 } | 6505 } |
| 6531 | 6506 |
| 6532 PassRefPtrWillBeRawPtr<CSSPrimitiveValue> parseGradientColorOrKeyword(CSSPropert yParser* p, CSSParserValue* value) | |
| 6533 { | |
| 6534 CSSValueID id = value->id; | |
| 6535 if (id == CSSValueWebkitText || (id >= CSSValueAqua && id <= CSSValueWindowt ext) || id == CSSValueMenu || id == CSSValueCurrentcolor) | |
| 6536 return cssValuePool().createIdentifierValue(id); | |
| 6537 | |
| 6538 return p->parseColor(value); | |
| 6539 } | |
| 6540 | |
| 6541 bool CSSPropertyParser::parseDeprecatedLinearGradient(CSSParserValueList* valueL ist, RefPtrWillBeRawPtr<CSSValue>& gradient, CSSGradientRepeat repeating) | 6507 bool CSSPropertyParser::parseDeprecatedLinearGradient(CSSParserValueList* valueL ist, RefPtrWillBeRawPtr<CSSValue>& gradient, CSSGradientRepeat repeating) |
| 6542 { | 6508 { |
| 6543 RefPtrWillBeRawPtr<CSSLinearGradientValue> result = CSSLinearGradientValue:: create(repeating, CSSPrefixedLinearGradient); | 6509 RefPtrWillBeRawPtr<CSSLinearGradientValue> result = CSSLinearGradientValue:: create(repeating, CSSPrefixedLinearGradient); |
| 6544 | 6510 |
| 6545 // Walk the arguments. | 6511 // Walk the arguments. |
| 6546 CSSParserValueList* args = valueList->current()->function->args.get(); | 6512 CSSParserValueList* args = valueList->current()->function->args.get(); |
| 6547 if (!args || !args->size()) | 6513 if (!args || !args->size()) |
| 6548 return false; | 6514 return false; |
| 6549 | 6515 |
| 6550 CSSParserValue* a = args->current(); | 6516 CSSParserValue* a = args->current(); |
| (...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6935 return false; | 6901 return false; |
| 6936 | 6902 |
| 6937 a = valueList->next(); | 6903 a = valueList->next(); |
| 6938 if (!a) | 6904 if (!a) |
| 6939 return false; | 6905 return false; |
| 6940 } | 6906 } |
| 6941 | 6907 |
| 6942 // <color-stop> = <color> [ <percentage> | <length> ]? | 6908 // <color-stop> = <color> [ <percentage> | <length> ]? |
| 6943 // <color-hint> = <length> | <percentage> | 6909 // <color-hint> = <length> | <percentage> |
| 6944 CSSGradientColorStop stop; | 6910 CSSGradientColorStop stop; |
| 6945 stop.m_color = parseGradientColorOrKeyword(this, a); | 6911 CSSValueID id = a->id; |
| 6912 if (id == CSSValueWebkitText || (id >= CSSValueAqua && id <= CSSValueWin dowtext) || id == CSSValueMenu || id == CSSValueCurrentcolor) | |
| 6913 stop.m_color = cssValuePool().createIdentifierValue(id); | |
| 6914 else | |
| 6915 stop.m_color = parseColor(a); | |
| 6916 | |
| 6946 | 6917 |
| 6947 // Two hints in a row are not allowed. | 6918 // Two hints in a row are not allowed. |
| 6948 if (!stop.m_color && (!supportsColorHints || previousStopWasColorHint)) | 6919 if (!stop.m_color && (!supportsColorHints || previousStopWasColorHint)) |
| 6949 return false; | 6920 return false; |
| 6950 previousStopWasColorHint = !stop.m_color; | 6921 previousStopWasColorHint = !stop.m_color; |
| 6951 | 6922 |
| 6952 if (stop.m_color) | 6923 if (stop.m_color) |
| 6953 a = valueList->next(); | 6924 a = valueList->next(); |
| 6954 | 6925 |
| 6955 if (a) { | 6926 if (a) { |
| (...skipping 1591 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 8547 } | 8518 } |
| 8548 } | 8519 } |
| 8549 | 8520 |
| 8550 if (!list->length()) | 8521 if (!list->length()) |
| 8551 return nullptr; | 8522 return nullptr; |
| 8552 | 8523 |
| 8553 return list.release(); | 8524 return list.release(); |
| 8554 } | 8525 } |
| 8555 | 8526 |
| 8556 } // namespace blink | 8527 } // namespace blink |
| OLD | NEW |