| 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 488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 499 return false; | 499 return false; |
| 500 parsedValue2 = createPrimitiveNumericValue(value); | 500 parsedValue2 = createPrimitiveNumericValue(value); |
| 501 } else | 501 } else |
| 502 parsedValue2 = parsedValue1; | 502 parsedValue2 = parsedValue1; |
| 503 | 503 |
| 504 if (m_valueList->next()) | 504 if (m_valueList->next()) |
| 505 return false; | 505 return false; |
| 506 addProperty(propId, CSSValuePair::create(parsedValue1.release(), parsedV
alue2.release(), CSSValuePair::DropIdenticalValues), important); | 506 addProperty(propId, CSSValuePair::create(parsedValue1.release(), parsedV
alue2.release(), CSSValuePair::DropIdenticalValues), important); |
| 507 return true; | 507 return true; |
| 508 } | 508 } |
| 509 case CSSPropertyBorderRadius: | 509 case CSSPropertyBorderRadius: { |
| 510 case CSSPropertyAliasWebkitBorderRadius: | 510 ShorthandScope scope(this, unresolvedProperty); |
| 511 return parseBorderRadius(unresolvedProperty, important); | 511 RefPtrWillBeRawPtr<CSSPrimitiveValue> radii[4]; |
| 512 RefPtrWillBeRawPtr<CSSPrimitiveValue> radii2[4]; |
| 513 if (!parseRadii(radii, radii2, m_valueList, unresolvedProperty)) |
| 514 return false; |
| 515 ImplicitScope implicitScope(this); |
| 516 addProperty(CSSPropertyBorderTopLeftRadius, CSSValuePair::create(radii[0
].release(), radii2[0].release(), CSSValuePair::DropIdenticalValues), important)
; |
| 517 addProperty(CSSPropertyBorderTopRightRadius, CSSValuePair::create(radii[
1].release(), radii2[1].release(), CSSValuePair::DropIdenticalValues), important
); |
| 518 addProperty(CSSPropertyBorderBottomRightRadius, CSSValuePair::create(rad
ii[2].release(), radii2[2].release(), CSSValuePair::DropIdenticalValues), import
ant); |
| 519 addProperty(CSSPropertyBorderBottomLeftRadius, CSSValuePair::create(radi
i[3].release(), radii2[3].release(), CSSValuePair::DropIdenticalValues), importa
nt); |
| 520 return true; |
| 521 } |
| 512 case CSSPropertyWebkitBoxReflect: | 522 case CSSPropertyWebkitBoxReflect: |
| 513 if (id == CSSValueNone) | 523 if (id == CSSValueNone) |
| 514 validPrimitive = true; | 524 validPrimitive = true; |
| 515 else | 525 else |
| 516 parsedValue = parseReflect(); | 526 parsedValue = parseReflect(); |
| 517 break; | 527 break; |
| 518 case CSSPropertyFontSizeAdjust: // none | <number> | 528 case CSSPropertyFontSizeAdjust: // none | <number> |
| 519 ASSERT(RuntimeEnabledFeatures::cssFontSizeAdjustEnabled()); | 529 ASSERT(RuntimeEnabledFeatures::cssFontSizeAdjustEnabled()); |
| 520 validPrimitive = (id == CSSValueNone) ? true : validUnit(value, FNumber
| FNonNeg); | 530 validPrimitive = (id == CSSValueNone) ? true : validUnit(value, FNumber
| FNonNeg); |
| 521 break; | 531 break; |
| (...skipping 2107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2629 if (radii[3]) | 2639 if (radii[3]) |
| 2630 return; | 2640 return; |
| 2631 if (!radii[2]) { | 2641 if (!radii[2]) { |
| 2632 if (!radii[1]) | 2642 if (!radii[1]) |
| 2633 radii[1] = radii[0]; | 2643 radii[1] = radii[0]; |
| 2634 radii[2] = radii[0]; | 2644 radii[2] = radii[0]; |
| 2635 } | 2645 } |
| 2636 radii[3] = radii[1]; | 2646 radii[3] = radii[1]; |
| 2637 } | 2647 } |
| 2638 | 2648 |
| 2639 // FIXME: This should be refactored with parseBorderRadius. | |
| 2640 // parseBorderRadius contains support for some legacy radius construction. | |
| 2641 PassRefPtrWillBeRawPtr<CSSBasicShapeInsetValue> CSSPropertyParser::parseInsetRou
ndedCorners(PassRefPtrWillBeRawPtr<CSSBasicShapeInsetValue> shape, CSSParserValu
eList* args) | |
| 2642 { | |
| 2643 CSSParserValue* argument = args->next(); | |
| 2644 | |
| 2645 if (!argument) | |
| 2646 return nullptr; | |
| 2647 | |
| 2648 Vector<CSSParserValue*> radiusArguments; | |
| 2649 while (argument) { | |
| 2650 radiusArguments.append(argument); | |
| 2651 argument = args->next(); | |
| 2652 } | |
| 2653 | |
| 2654 unsigned num = radiusArguments.size(); | |
| 2655 if (!num || num > 9) | |
| 2656 return nullptr; | |
| 2657 | |
| 2658 // FIXME: Refactor completeBorderRadii and the array | |
| 2659 RefPtrWillBeRawPtr<CSSPrimitiveValue> radii[2][4]; | |
| 2660 #if ENABLE(OILPAN) | |
| 2661 // Zero initialize the array of raw pointers. | |
| 2662 memset(&radii, 0, sizeof(radii)); | |
| 2663 #endif | |
| 2664 | |
| 2665 unsigned indexAfterSlash = 0; | |
| 2666 for (unsigned i = 0; i < num; ++i) { | |
| 2667 CSSParserValue* value = radiusArguments.at(i); | |
| 2668 if (value->m_unit == CSSParserValue::Operator) { | |
| 2669 if (value->iValue != '/') | |
| 2670 return nullptr; | |
| 2671 | |
| 2672 if (!i || indexAfterSlash || i + 1 == num) | |
| 2673 return nullptr; | |
| 2674 | |
| 2675 indexAfterSlash = i + 1; | |
| 2676 completeBorderRadii(radii[0]); | |
| 2677 continue; | |
| 2678 } | |
| 2679 | |
| 2680 if (i - indexAfterSlash >= 4) | |
| 2681 return nullptr; | |
| 2682 | |
| 2683 if (!validUnit(value, FLength | FPercent | FNonNeg)) | |
| 2684 return nullptr; | |
| 2685 | |
| 2686 RefPtrWillBeRawPtr<CSSPrimitiveValue> radius = createPrimitiveNumericVal
ue(value); | |
| 2687 | |
| 2688 if (!indexAfterSlash) | |
| 2689 radii[0][i] = radius; | |
| 2690 else | |
| 2691 radii[1][i - indexAfterSlash] = radius.release(); | |
| 2692 } | |
| 2693 | |
| 2694 if (!indexAfterSlash) { | |
| 2695 completeBorderRadii(radii[0]); | |
| 2696 for (unsigned i = 0; i < 4; ++i) | |
| 2697 radii[1][i] = radii[0][i]; | |
| 2698 } else { | |
| 2699 completeBorderRadii(radii[1]); | |
| 2700 } | |
| 2701 shape->setTopLeftRadius(CSSValuePair::create(radii[0][0].release(), radii[1]
[0].release(), CSSValuePair::DropIdenticalValues)); | |
| 2702 shape->setTopRightRadius(CSSValuePair::create(radii[0][1].release(), radii[1
][1].release(), CSSValuePair::DropIdenticalValues)); | |
| 2703 shape->setBottomRightRadius(CSSValuePair::create(radii[0][2].release(), radi
i[1][2].release(), CSSValuePair::DropIdenticalValues)); | |
| 2704 shape->setBottomLeftRadius(CSSValuePair::create(radii[0][3].release(), radii
[1][3].release(), CSSValuePair::DropIdenticalValues)); | |
| 2705 | |
| 2706 return shape; | |
| 2707 } | |
| 2708 | |
| 2709 PassRefPtrWillBeRawPtr<CSSBasicShapeInsetValue> CSSPropertyParser::parseBasicSha
peInset(CSSParserValueList* args) | 2649 PassRefPtrWillBeRawPtr<CSSBasicShapeInsetValue> CSSPropertyParser::parseBasicSha
peInset(CSSParserValueList* args) |
| 2710 { | 2650 { |
| 2711 ASSERT(args); | 2651 ASSERT(args); |
| 2712 | 2652 |
| 2713 RefPtrWillBeRawPtr<CSSBasicShapeInsetValue> shape = CSSBasicShapeInsetValue:
:create(); | 2653 RefPtrWillBeRawPtr<CSSBasicShapeInsetValue> shape = CSSBasicShapeInsetValue:
:create(); |
| 2714 | 2654 |
| 2715 CSSParserValue* argument = args->current(); | 2655 CSSParserValue* argument = args->current(); |
| 2716 WillBeHeapVector<RefPtrWillBeMember<CSSPrimitiveValue>> widthArguments; | 2656 WillBeHeapVector<RefPtrWillBeMember<CSSPrimitiveValue>> widthArguments; |
| 2717 bool hasRoundedInset = false; | 2657 bool hasRoundedInset = false; |
| 2718 | 2658 |
| 2719 while (argument) { | 2659 while (argument) { |
| 2720 if (argument->m_unit == CSSParserValue::Identifier && argument->id == CS
SValueRound) { | 2660 if (argument->m_unit == CSSParserValue::Identifier && argument->id == CS
SValueRound) { |
| 2661 if (!args->next()) |
| 2662 return nullptr; |
| 2721 hasRoundedInset = true; | 2663 hasRoundedInset = true; |
| 2722 break; | 2664 break; |
| 2723 } | 2665 } |
| 2724 | 2666 |
| 2725 Units unitFlags = FLength | FPercent; | 2667 Units unitFlags = FLength | FPercent; |
| 2726 if (!validUnit(argument, unitFlags) || widthArguments.size() > 4) | 2668 if (!validUnit(argument, unitFlags) || widthArguments.size() > 4) |
| 2727 return nullptr; | 2669 return nullptr; |
| 2728 | 2670 |
| 2729 widthArguments.append(createPrimitiveNumericValue(argument)); | 2671 widthArguments.append(createPrimitiveNumericValue(argument)); |
| 2730 argument = args->next(); | 2672 argument = args->next(); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 2744 break; | 2686 break; |
| 2745 } | 2687 } |
| 2746 case 4: { | 2688 case 4: { |
| 2747 shape->updateShapeSize4Values(widthArguments[0].get(), widthArguments[1]
.get(), widthArguments[2].get(), widthArguments[3].get()); | 2689 shape->updateShapeSize4Values(widthArguments[0].get(), widthArguments[1]
.get(), widthArguments[2].get(), widthArguments[3].get()); |
| 2748 break; | 2690 break; |
| 2749 } | 2691 } |
| 2750 default: | 2692 default: |
| 2751 return nullptr; | 2693 return nullptr; |
| 2752 } | 2694 } |
| 2753 | 2695 |
| 2754 if (hasRoundedInset) | 2696 if (hasRoundedInset) { |
| 2755 return parseInsetRoundedCorners(shape.release(), args); | 2697 // FIXME: Refactor completeBorderRadii and the array |
| 2698 RefPtrWillBeRawPtr<CSSPrimitiveValue> radii[4]; |
| 2699 RefPtrWillBeRawPtr<CSSPrimitiveValue> radii2[4]; |
| 2700 if (!parseRadii(radii, radii2, args)) |
| 2701 return nullptr; |
| 2702 shape->setTopLeftRadius(CSSValuePair::create(radii[0].release(), radii2[
0].release(), CSSValuePair::DropIdenticalValues)); |
| 2703 shape->setTopRightRadius(CSSValuePair::create(radii[1].release(), radii2
[1].release(), CSSValuePair::DropIdenticalValues)); |
| 2704 shape->setBottomRightRadius(CSSValuePair::create(radii[2].release(), rad
ii2[2].release(), CSSValuePair::DropIdenticalValues)); |
| 2705 shape->setBottomLeftRadius(CSSValuePair::create(radii[3].release(), radi
i2[3].release(), CSSValuePair::DropIdenticalValues)); |
| 2706 } |
| 2707 |
| 2756 return shape.release(); | 2708 return shape.release(); |
| 2757 } | 2709 } |
| 2758 | 2710 |
| 2759 static bool isContentDistributionKeyword(CSSValueID id) | 2711 static bool isContentDistributionKeyword(CSSValueID id) |
| 2760 { | 2712 { |
| 2761 return id == CSSValueSpaceBetween || id == CSSValueSpaceAround | 2713 return id == CSSValueSpaceBetween || id == CSSValueSpaceAround |
| 2762 || id == CSSValueSpaceEvenly || id == CSSValueStretch; | 2714 || id == CSSValueSpaceEvenly || id == CSSValueStretch; |
| 2763 } | 2715 } |
| 2764 | 2716 |
| 2765 static bool isContentPositionKeyword(CSSValueID id) | 2717 static bool isContentPositionKeyword(CSSValueID id) |
| (...skipping 1094 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3860 bool CSSPropertyParser::parseBorderImageWidth(RefPtrWillBeRawPtr<CSSQuadValue>&
result) | 3812 bool CSSPropertyParser::parseBorderImageWidth(RefPtrWillBeRawPtr<CSSQuadValue>&
result) |
| 3861 { | 3813 { |
| 3862 return parseBorderImageQuad(FLength | FNumber | FNonNeg | FPercent, result); | 3814 return parseBorderImageQuad(FLength | FNumber | FNonNeg | FPercent, result); |
| 3863 } | 3815 } |
| 3864 | 3816 |
| 3865 bool CSSPropertyParser::parseBorderImageOutset(RefPtrWillBeRawPtr<CSSQuadValue>&
result) | 3817 bool CSSPropertyParser::parseBorderImageOutset(RefPtrWillBeRawPtr<CSSQuadValue>&
result) |
| 3866 { | 3818 { |
| 3867 return parseBorderImageQuad(FLength | FNumber | FNonNeg, result); | 3819 return parseBorderImageQuad(FLength | FNumber | FNonNeg, result); |
| 3868 } | 3820 } |
| 3869 | 3821 |
| 3870 bool CSSPropertyParser::parseBorderRadius(CSSPropertyID unresolvedProperty, bool
important) | 3822 bool CSSPropertyParser::parseRadii(RefPtrWillBeRawPtr<CSSPrimitiveValue> radii[4
], RefPtrWillBeRawPtr<CSSPrimitiveValue> radii2[4], CSSParserValueList* args, CS
SPropertyID unresolvedProperty) |
| 3871 { | 3823 { |
| 3872 unsigned num = m_valueList->size(); | 3824 CSSParserValue* value = args->current(); |
| 3873 if (num > 9) | 3825 int i; |
| 3874 return false; | 3826 for (i = 0; i < 4 && value && value->m_unit != CSSParserValue::Operator;++i,
value = args->next()) { |
| 3875 | |
| 3876 ShorthandScope scope(this, unresolvedProperty); | |
| 3877 RefPtrWillBeRawPtr<CSSPrimitiveValue> radii[2][4]; | |
| 3878 #if ENABLE(OILPAN) | |
| 3879 // Zero initialize the array of raw pointers. | |
| 3880 memset(&radii, 0, sizeof(radii)); | |
| 3881 #endif | |
| 3882 | |
| 3883 unsigned indexAfterSlash = 0; | |
| 3884 for (unsigned i = 0; i < num; ++i) { | |
| 3885 CSSParserValue* value = m_valueList->valueAt(i); | |
| 3886 if (value->m_unit == CSSParserValue::Operator) { | |
| 3887 if (value->iValue != '/') | |
| 3888 return false; | |
| 3889 | |
| 3890 if (!i || indexAfterSlash || i + 1 == num || num > i + 5) | |
| 3891 return false; | |
| 3892 | |
| 3893 indexAfterSlash = i + 1; | |
| 3894 completeBorderRadii(radii[0]); | |
| 3895 continue; | |
| 3896 } | |
| 3897 | |
| 3898 if (i - indexAfterSlash >= 4) | |
| 3899 return false; | |
| 3900 | |
| 3901 if (!validUnit(value, FLength | FPercent | FNonNeg)) | 3827 if (!validUnit(value, FLength | FPercent | FNonNeg)) |
| 3902 return false; | 3828 return false; |
| 3903 | 3829 |
| 3904 RefPtrWillBeRawPtr<CSSPrimitiveValue> radius = createPrimitiveNumericVal
ue(value); | 3830 radii[i] = createPrimitiveNumericValue(value); |
| 3905 | |
| 3906 if (!indexAfterSlash) { | |
| 3907 radii[0][i] = radius; | |
| 3908 | |
| 3909 // Legacy syntax: -webkit-border-radius: l1 l2; is equivalent to bor
der-radius: l1 / l2; | |
| 3910 if (num == 2 && unresolvedProperty == CSSPropertyAliasWebkitBorderRa
dius) { | |
| 3911 indexAfterSlash = 1; | |
| 3912 completeBorderRadii(radii[0]); | |
| 3913 } | |
| 3914 } else | |
| 3915 radii[1][i - indexAfterSlash] = radius.release(); | |
| 3916 } | 3831 } |
| 3917 | 3832 |
| 3918 if (!indexAfterSlash) { | 3833 if (!i || (value && value->m_unit == CSSParserValue::Operator && value->iVal
ue != '/')) |
| 3919 completeBorderRadii(radii[0]); | 3834 return false; |
| 3835 // Legacy syntax: -webkit-border-radius: l1 l2; is equivalent to border-radi
us: l1 / l2; |
| 3836 if (!value && i == 2 && unresolvedProperty == CSSPropertyAliasWebkitBorderRa
dius) { |
| 3837 radii2[0] = radii[1]; |
| 3838 radii[1] = nullptr; |
| 3839 completeBorderRadii(radii); |
| 3840 completeBorderRadii(radii2); |
| 3841 return true; |
| 3842 } |
| 3843 completeBorderRadii(radii); |
| 3844 if (value) { |
| 3845 value = args->next(); |
| 3846 for (i = 0; i < 4 && value && validUnit(value, FLength | FPercent | FNon
Neg); ++i, value = args->next()) |
| 3847 radii2[i] = createPrimitiveNumericValue(value); |
| 3848 if (!i || value) |
| 3849 return false; |
| 3850 completeBorderRadii(radii2); |
| 3851 } else { |
| 3920 for (unsigned i = 0; i < 4; ++i) | 3852 for (unsigned i = 0; i < 4; ++i) |
| 3921 radii[1][i] = radii[0][i]; | 3853 radii2[i] = radii[i]; |
| 3922 } else | 3854 } |
| 3923 completeBorderRadii(radii[1]); | |
| 3924 | 3855 |
| 3925 ImplicitScope implicitScope(this); | |
| 3926 addProperty(CSSPropertyBorderTopLeftRadius, CSSValuePair::create(radii[0][0]
.release(), radii[1][0].release(), CSSValuePair::DropIdenticalValues), important
); | |
| 3927 addProperty(CSSPropertyBorderTopRightRadius, CSSValuePair::create(radii[0][1
].release(), radii[1][1].release(), CSSValuePair::DropIdenticalValues), importan
t); | |
| 3928 addProperty(CSSPropertyBorderBottomRightRadius, CSSValuePair::create(radii[0
][2].release(), radii[1][2].release(), CSSValuePair::DropIdenticalValues), impor
tant); | |
| 3929 addProperty(CSSPropertyBorderBottomLeftRadius, CSSValuePair::create(radii[0]
[3].release(), radii[1][3].release(), CSSValuePair::DropIdenticalValues), import
ant); | |
| 3930 return true; | 3856 return true; |
| 3931 } | 3857 } |
| 3932 | 3858 |
| 3933 // This should go away once we drop support for -webkit-gradient | 3859 // This should go away once we drop support for -webkit-gradient |
| 3934 static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> parseDeprecatedGradientPoint(CS
SParserValue* a, bool horizontal) | 3860 static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> parseDeprecatedGradientPoint(CS
SParserValue* a, bool horizontal) |
| 3935 { | 3861 { |
| 3936 RefPtrWillBeRawPtr<CSSPrimitiveValue> result = nullptr; | 3862 RefPtrWillBeRawPtr<CSSPrimitiveValue> result = nullptr; |
| 3937 if (a->m_unit == CSSParserValue::Identifier) { | 3863 if (a->m_unit == CSSParserValue::Identifier) { |
| 3938 if ((a->id == CSSValueLeft && horizontal) | 3864 if ((a->id == CSSValueLeft && horizontal) |
| 3939 || (a->id == CSSValueTop && !horizontal)) | 3865 || (a->id == CSSValueTop && !horizontal)) |
| (...skipping 821 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4761 ASSERT(!m_parsedCalculation); | 4687 ASSERT(!m_parsedCalculation); |
| 4762 m_parsedCalculation = CSSCalcValue::create(args, range); | 4688 m_parsedCalculation = CSSCalcValue::create(args, range); |
| 4763 | 4689 |
| 4764 if (!m_parsedCalculation) | 4690 if (!m_parsedCalculation) |
| 4765 return false; | 4691 return false; |
| 4766 | 4692 |
| 4767 return true; | 4693 return true; |
| 4768 } | 4694 } |
| 4769 | 4695 |
| 4770 } // namespace blink | 4696 } // namespace blink |
| OLD | NEW |