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 514 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
525 parsedValue2 = createPrimitiveNumericValue(value); | 525 parsedValue2 = createPrimitiveNumericValue(value); |
526 } else | 526 } else |
527 parsedValue2 = parsedValue1; | 527 parsedValue2 = parsedValue1; |
528 | 528 |
529 if (m_valueList->next()) | 529 if (m_valueList->next()) |
530 return false; | 530 return false; |
531 addProperty(propId, CSSValuePair::create(parsedValue1.release(), parsedV alue2.release(), CSSValuePair::DropIdenticalValues), important); | 531 addProperty(propId, CSSValuePair::create(parsedValue1.release(), parsedV alue2.release(), CSSValuePair::DropIdenticalValues), important); |
532 return true; | 532 return true; |
533 } | 533 } |
534 case CSSPropertyBorderRadius: | 534 case CSSPropertyBorderRadius: |
535 case CSSPropertyAliasWebkitBorderRadius: | 535 case CSSPropertyAliasWebkitBorderRadius: { |
Timothy Loh
2016/01/11 02:01:46
btw the switch is on a resolved property so the al
rwlbuis
2016/01/11 14:46:18
Done.
| |
536 return parseBorderRadius(unresolvedProperty, important); | 536 ShorthandScope scope(this, unresolvedProperty); |
537 RefPtrWillBeRawPtr<CSSPrimitiveValue> radii[4]; | |
538 RefPtrWillBeRawPtr<CSSPrimitiveValue> radii2[4]; | |
539 if (!parseRadii(radii, radii2, m_valueList, unresolvedProperty)) | |
540 return false; | |
541 ImplicitScope implicitScope(this); | |
542 addProperty(CSSPropertyBorderTopLeftRadius, CSSValuePair::create(radii[0 ].release(), radii2[0].release(), CSSValuePair::DropIdenticalValues), important) ; | |
543 addProperty(CSSPropertyBorderTopRightRadius, CSSValuePair::create(radii[ 1].release(), radii2[1].release(), CSSValuePair::DropIdenticalValues), important ); | |
544 addProperty(CSSPropertyBorderBottomRightRadius, CSSValuePair::create(rad ii[2].release(), radii2[2].release(), CSSValuePair::DropIdenticalValues), import ant); | |
545 addProperty(CSSPropertyBorderBottomLeftRadius, CSSValuePair::create(radi i[3].release(), radii2[3].release(), CSSValuePair::DropIdenticalValues), importa nt); | |
546 return true; | |
547 } | |
537 case CSSPropertyWebkitBoxReflect: | 548 case CSSPropertyWebkitBoxReflect: |
538 if (id == CSSValueNone) | 549 if (id == CSSValueNone) |
539 validPrimitive = true; | 550 validPrimitive = true; |
540 else | 551 else |
541 parsedValue = parseReflect(); | 552 parsedValue = parseReflect(); |
542 break; | 553 break; |
543 case CSSPropertyFontSizeAdjust: // none | <number> | 554 case CSSPropertyFontSizeAdjust: // none | <number> |
544 ASSERT(RuntimeEnabledFeatures::cssFontSizeAdjustEnabled()); | 555 ASSERT(RuntimeEnabledFeatures::cssFontSizeAdjustEnabled()); |
545 validPrimitive = (id == CSSValueNone) ? true : validUnit(value, FNumber | FNonNeg); | 556 validPrimitive = (id == CSSValueNone) ? true : validUnit(value, FNumber | FNonNeg); |
546 break; | 557 break; |
(...skipping 2247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2794 if (radii[3]) | 2805 if (radii[3]) |
2795 return; | 2806 return; |
2796 if (!radii[2]) { | 2807 if (!radii[2]) { |
2797 if (!radii[1]) | 2808 if (!radii[1]) |
2798 radii[1] = radii[0]; | 2809 radii[1] = radii[0]; |
2799 radii[2] = radii[0]; | 2810 radii[2] = radii[0]; |
2800 } | 2811 } |
2801 radii[3] = radii[1]; | 2812 radii[3] = radii[1]; |
2802 } | 2813 } |
2803 | 2814 |
2804 // FIXME: This should be refactored with parseBorderRadius. | |
2805 // parseBorderRadius contains support for some legacy radius construction. | |
2806 PassRefPtrWillBeRawPtr<CSSBasicShapeInsetValue> CSSPropertyParser::parseInsetRou ndedCorners(PassRefPtrWillBeRawPtr<CSSBasicShapeInsetValue> shape, CSSParserValu eList* args) | |
2807 { | |
2808 CSSParserValue* argument = args->next(); | |
2809 | |
2810 if (!argument) | |
2811 return nullptr; | |
2812 | |
2813 Vector<CSSParserValue*> radiusArguments; | |
2814 while (argument) { | |
2815 radiusArguments.append(argument); | |
2816 argument = args->next(); | |
2817 } | |
2818 | |
2819 unsigned num = radiusArguments.size(); | |
2820 if (!num || num > 9) | |
2821 return nullptr; | |
2822 | |
2823 // FIXME: Refactor completeBorderRadii and the array | |
2824 RefPtrWillBeRawPtr<CSSPrimitiveValue> radii[2][4]; | |
2825 #if ENABLE(OILPAN) | |
2826 // Zero initialize the array of raw pointers. | |
2827 memset(&radii, 0, sizeof(radii)); | |
2828 #endif | |
2829 | |
2830 unsigned indexAfterSlash = 0; | |
2831 for (unsigned i = 0; i < num; ++i) { | |
2832 CSSParserValue* value = radiusArguments.at(i); | |
2833 if (value->m_unit == CSSParserValue::Operator) { | |
2834 if (value->iValue != '/') | |
2835 return nullptr; | |
2836 | |
2837 if (!i || indexAfterSlash || i + 1 == num) | |
2838 return nullptr; | |
2839 | |
2840 indexAfterSlash = i + 1; | |
2841 completeBorderRadii(radii[0]); | |
2842 continue; | |
2843 } | |
2844 | |
2845 if (i - indexAfterSlash >= 4) | |
2846 return nullptr; | |
2847 | |
2848 if (!validUnit(value, FLength | FPercent | FNonNeg)) | |
2849 return nullptr; | |
2850 | |
2851 RefPtrWillBeRawPtr<CSSPrimitiveValue> radius = createPrimitiveNumericVal ue(value); | |
2852 | |
2853 if (!indexAfterSlash) | |
2854 radii[0][i] = radius; | |
2855 else | |
2856 radii[1][i - indexAfterSlash] = radius.release(); | |
2857 } | |
2858 | |
2859 if (!indexAfterSlash) { | |
2860 completeBorderRadii(radii[0]); | |
2861 for (unsigned i = 0; i < 4; ++i) | |
2862 radii[1][i] = radii[0][i]; | |
2863 } else { | |
2864 completeBorderRadii(radii[1]); | |
2865 } | |
2866 shape->setTopLeftRadius(CSSValuePair::create(radii[0][0].release(), radii[1] [0].release(), CSSValuePair::DropIdenticalValues)); | |
2867 shape->setTopRightRadius(CSSValuePair::create(radii[0][1].release(), radii[1 ][1].release(), CSSValuePair::DropIdenticalValues)); | |
2868 shape->setBottomRightRadius(CSSValuePair::create(radii[0][2].release(), radi i[1][2].release(), CSSValuePair::DropIdenticalValues)); | |
2869 shape->setBottomLeftRadius(CSSValuePair::create(radii[0][3].release(), radii [1][3].release(), CSSValuePair::DropIdenticalValues)); | |
2870 | |
2871 return shape; | |
2872 } | |
2873 | |
2874 PassRefPtrWillBeRawPtr<CSSBasicShapeInsetValue> CSSPropertyParser::parseBasicSha peInset(CSSParserValueList* args) | 2815 PassRefPtrWillBeRawPtr<CSSBasicShapeInsetValue> CSSPropertyParser::parseBasicSha peInset(CSSParserValueList* args) |
2875 { | 2816 { |
2876 ASSERT(args); | 2817 ASSERT(args); |
2877 | 2818 |
2878 RefPtrWillBeRawPtr<CSSBasicShapeInsetValue> shape = CSSBasicShapeInsetValue: :create(); | 2819 RefPtrWillBeRawPtr<CSSBasicShapeInsetValue> shape = CSSBasicShapeInsetValue: :create(); |
2879 | 2820 |
2880 CSSParserValue* argument = args->current(); | 2821 CSSParserValue* argument = args->current(); |
2881 WillBeHeapVector<RefPtrWillBeMember<CSSPrimitiveValue>> widthArguments; | 2822 WillBeHeapVector<RefPtrWillBeMember<CSSPrimitiveValue>> widthArguments; |
2882 bool hasRoundedInset = false; | 2823 bool hasRoundedInset = false; |
2883 | 2824 |
2884 while (argument) { | 2825 while (argument) { |
2885 if (argument->m_unit == CSSParserValue::Identifier && argument->id == CS SValueRound) { | 2826 if (argument->m_unit == CSSParserValue::Identifier && argument->id == CS SValueRound) { |
2827 if (!args->next()) | |
2828 return nullptr; | |
2886 hasRoundedInset = true; | 2829 hasRoundedInset = true; |
2887 break; | 2830 break; |
2888 } | 2831 } |
2889 | 2832 |
2890 Units unitFlags = FLength | FPercent; | 2833 Units unitFlags = FLength | FPercent; |
2891 if (!validUnit(argument, unitFlags) || widthArguments.size() > 4) | 2834 if (!validUnit(argument, unitFlags) || widthArguments.size() > 4) |
2892 return nullptr; | 2835 return nullptr; |
2893 | 2836 |
2894 widthArguments.append(createPrimitiveNumericValue(argument)); | 2837 widthArguments.append(createPrimitiveNumericValue(argument)); |
2895 argument = args->next(); | 2838 argument = args->next(); |
(...skipping 13 matching lines...) Expand all Loading... | |
2909 break; | 2852 break; |
2910 } | 2853 } |
2911 case 4: { | 2854 case 4: { |
2912 shape->updateShapeSize4Values(widthArguments[0].get(), widthArguments[1] .get(), widthArguments[2].get(), widthArguments[3].get()); | 2855 shape->updateShapeSize4Values(widthArguments[0].get(), widthArguments[1] .get(), widthArguments[2].get(), widthArguments[3].get()); |
2913 break; | 2856 break; |
2914 } | 2857 } |
2915 default: | 2858 default: |
2916 return nullptr; | 2859 return nullptr; |
2917 } | 2860 } |
2918 | 2861 |
2919 if (hasRoundedInset) | 2862 if (hasRoundedInset) { |
2920 return parseInsetRoundedCorners(shape.release(), args); | 2863 // FIXME: Refactor completeBorderRadii and the array |
Timothy Loh
2016/01/11 02:01:46
What did you have in mind? Or is this just a legac
rwlbuis
2016/01/11 14:46:18
Well I am still not completely sure the array is t
| |
2864 RefPtrWillBeRawPtr<CSSPrimitiveValue> radii[4]; | |
2865 RefPtrWillBeRawPtr<CSSPrimitiveValue> radii2[4]; | |
2866 if (!parseRadii(radii, radii2, args)) | |
2867 return nullptr; | |
2868 shape->setTopLeftRadius(CSSValuePair::create(radii[0].release(), radii2[ 0].release(), CSSValuePair::DropIdenticalValues)); | |
2869 shape->setTopRightRadius(CSSValuePair::create(radii[1].release(), radii2 [1].release(), CSSValuePair::DropIdenticalValues)); | |
2870 shape->setBottomRightRadius(CSSValuePair::create(radii[2].release(), rad ii2[2].release(), CSSValuePair::DropIdenticalValues)); | |
2871 shape->setBottomLeftRadius(CSSValuePair::create(radii[3].release(), radi i2[3].release(), CSSValuePair::DropIdenticalValues)); | |
2872 } | |
2873 | |
2921 return shape.release(); | 2874 return shape.release(); |
2922 } | 2875 } |
2923 | 2876 |
2924 static bool isContentDistributionKeyword(CSSValueID id) | 2877 static bool isContentDistributionKeyword(CSSValueID id) |
2925 { | 2878 { |
2926 return id == CSSValueSpaceBetween || id == CSSValueSpaceAround | 2879 return id == CSSValueSpaceBetween || id == CSSValueSpaceAround |
2927 || id == CSSValueSpaceEvenly || id == CSSValueStretch; | 2880 || id == CSSValueSpaceEvenly || id == CSSValueStretch; |
2928 } | 2881 } |
2929 | 2882 |
2930 static bool isContentPositionKeyword(CSSValueID id) | 2883 static bool isContentPositionKeyword(CSSValueID id) |
(...skipping 1094 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4025 bool CSSPropertyParser::parseBorderImageWidth(RefPtrWillBeRawPtr<CSSQuadValue>& result) | 3978 bool CSSPropertyParser::parseBorderImageWidth(RefPtrWillBeRawPtr<CSSQuadValue>& result) |
4026 { | 3979 { |
4027 return parseBorderImageQuad(FLength | FNumber | FNonNeg | FPercent, result); | 3980 return parseBorderImageQuad(FLength | FNumber | FNonNeg | FPercent, result); |
4028 } | 3981 } |
4029 | 3982 |
4030 bool CSSPropertyParser::parseBorderImageOutset(RefPtrWillBeRawPtr<CSSQuadValue>& result) | 3983 bool CSSPropertyParser::parseBorderImageOutset(RefPtrWillBeRawPtr<CSSQuadValue>& result) |
4031 { | 3984 { |
4032 return parseBorderImageQuad(FLength | FNumber | FNonNeg, result); | 3985 return parseBorderImageQuad(FLength | FNumber | FNonNeg, result); |
4033 } | 3986 } |
4034 | 3987 |
4035 bool CSSPropertyParser::parseBorderRadius(CSSPropertyID unresolvedProperty, bool important) | 3988 bool CSSPropertyParser::parseRadii(RefPtrWillBeRawPtr<CSSPrimitiveValue> radii[4 ], RefPtrWillBeRawPtr<CSSPrimitiveValue> radii2[4], CSSParserValueList* args, CS SPropertyID unresolvedProperty) |
4036 { | 3989 { |
4037 unsigned num = m_valueList->size(); | 3990 CSSParserValue* value = args->current(); |
4038 if (num > 9) | 3991 int i; |
4039 return false; | 3992 for (i = 0; i < 4 && value && value->m_unit != CSSParserValue::Operator;++i, value = args->next()) { |
4040 | |
4041 ShorthandScope scope(this, unresolvedProperty); | |
4042 RefPtrWillBeRawPtr<CSSPrimitiveValue> radii[2][4]; | |
4043 #if ENABLE(OILPAN) | |
4044 // Zero initialize the array of raw pointers. | |
4045 memset(&radii, 0, sizeof(radii)); | |
4046 #endif | |
4047 | |
4048 unsigned indexAfterSlash = 0; | |
4049 for (unsigned i = 0; i < num; ++i) { | |
4050 CSSParserValue* value = m_valueList->valueAt(i); | |
4051 if (value->m_unit == CSSParserValue::Operator) { | |
4052 if (value->iValue != '/') | |
4053 return false; | |
4054 | |
4055 if (!i || indexAfterSlash || i + 1 == num || num > i + 5) | |
4056 return false; | |
4057 | |
4058 indexAfterSlash = i + 1; | |
4059 completeBorderRadii(radii[0]); | |
4060 continue; | |
4061 } | |
4062 | |
4063 if (i - indexAfterSlash >= 4) | |
4064 return false; | |
4065 | |
4066 if (!validUnit(value, FLength | FPercent | FNonNeg)) | 3993 if (!validUnit(value, FLength | FPercent | FNonNeg)) |
4067 return false; | 3994 return false; |
4068 | 3995 |
4069 RefPtrWillBeRawPtr<CSSPrimitiveValue> radius = createPrimitiveNumericVal ue(value); | 3996 radii[i] = createPrimitiveNumericValue(value); |
4070 | |
4071 if (!indexAfterSlash) { | |
4072 radii[0][i] = radius; | |
4073 | |
4074 // Legacy syntax: -webkit-border-radius: l1 l2; is equivalent to bor der-radius: l1 / l2; | |
4075 if (num == 2 && unresolvedProperty == CSSPropertyAliasWebkitBorderRa dius) { | |
4076 indexAfterSlash = 1; | |
4077 completeBorderRadii(radii[0]); | |
4078 } | |
4079 } else | |
4080 radii[1][i - indexAfterSlash] = radius.release(); | |
4081 } | 3997 } |
4082 | 3998 |
4083 if (!indexAfterSlash) { | 3999 if (!i || (value && value->iValue != '/')) |
Timothy Loh
2016/01/11 02:01:46
probably need to check that m_unit is Operator
rwlbuis
2016/01/11 14:46:18
Done.
| |
4084 completeBorderRadii(radii[0]); | 4000 return false; |
4001 // Legacy syntax: -webkit-border-radius: l1 l2; is equivalent to border-radi us: l1 / l2; | |
4002 if (!value && i == 2 && unresolvedProperty == CSSPropertyAliasWebkitBorderRa dius) { | |
4003 radii2[0] = radii[1]; | |
4004 radii[1] = nullptr; | |
4005 completeBorderRadii(radii); | |
4006 completeBorderRadii(radii2); | |
4007 return true; | |
4008 } | |
4009 completeBorderRadii(radii); | |
4010 if (value) { | |
4011 value = args->next(); | |
4012 for (i = 0; i < 4 && value && validUnit(value, FLength | FPercent | FNon Neg); ++i, value = args->next()) | |
Timothy Loh
2016/01/11 02:01:46
I don't like having so much logic inside a for-loo
rwlbuis
2016/01/11 14:46:18
Acknowledged.
| |
4013 radii2[i] = createPrimitiveNumericValue(value); | |
4014 if (!i || value) | |
4015 return false; | |
4016 completeBorderRadii(radii2); | |
4017 } else { | |
4085 for (unsigned i = 0; i < 4; ++i) | 4018 for (unsigned i = 0; i < 4; ++i) |
4086 radii[1][i] = radii[0][i]; | 4019 radii2[i] = radii[i]; |
4087 } else | 4020 } |
4088 completeBorderRadii(radii[1]); | |
4089 | 4021 |
4090 ImplicitScope implicitScope(this); | |
4091 addProperty(CSSPropertyBorderTopLeftRadius, CSSValuePair::create(radii[0][0] .release(), radii[1][0].release(), CSSValuePair::DropIdenticalValues), important ); | |
4092 addProperty(CSSPropertyBorderTopRightRadius, CSSValuePair::create(radii[0][1 ].release(), radii[1][1].release(), CSSValuePair::DropIdenticalValues), importan t); | |
4093 addProperty(CSSPropertyBorderBottomRightRadius, CSSValuePair::create(radii[0 ][2].release(), radii[1][2].release(), CSSValuePair::DropIdenticalValues), impor tant); | |
4094 addProperty(CSSPropertyBorderBottomLeftRadius, CSSValuePair::create(radii[0] [3].release(), radii[1][3].release(), CSSValuePair::DropIdenticalValues), import ant); | |
4095 return true; | 4022 return true; |
4096 } | 4023 } |
4097 | 4024 |
4098 // This should go away once we drop support for -webkit-gradient | 4025 // This should go away once we drop support for -webkit-gradient |
4099 static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> parseDeprecatedGradientPoint(CS SParserValue* a, bool horizontal) | 4026 static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> parseDeprecatedGradientPoint(CS SParserValue* a, bool horizontal) |
4100 { | 4027 { |
4101 RefPtrWillBeRawPtr<CSSPrimitiveValue> result = nullptr; | 4028 RefPtrWillBeRawPtr<CSSPrimitiveValue> result = nullptr; |
4102 if (a->m_unit == CSSParserValue::Identifier) { | 4029 if (a->m_unit == CSSParserValue::Identifier) { |
4103 if ((a->id == CSSValueLeft && horizontal) | 4030 if ((a->id == CSSValueLeft && horizontal) |
4104 || (a->id == CSSValueTop && !horizontal)) | 4031 || (a->id == CSSValueTop && !horizontal)) |
(...skipping 821 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4926 ASSERT(!m_parsedCalculation); | 4853 ASSERT(!m_parsedCalculation); |
4927 m_parsedCalculation = CSSCalcValue::create(args, range); | 4854 m_parsedCalculation = CSSCalcValue::create(args, range); |
4928 | 4855 |
4929 if (!m_parsedCalculation) | 4856 if (!m_parsedCalculation) |
4930 return false; | 4857 return false; |
4931 | 4858 |
4932 return true; | 4859 return true; |
4933 } | 4860 } |
4934 | 4861 |
4935 } // namespace blink | 4862 } // namespace blink |
OLD | NEW |