Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * * Redistributions of source code must retain the above copyright | 4 * * Redistributions of source code must retain the above copyright |
| 5 * notice, this list of conditions and the following disclaimer. | 5 * notice, this list of conditions and the following disclaimer. |
| 6 * * Redistributions in binary form must reproduce the above | 6 * * Redistributions in binary form must reproduce the above |
| 7 * copyright notice, this list of conditions and the following disclaimer | 7 * copyright notice, this list of conditions and the following disclaimer |
| 8 * in the documentation and/or other materials provided with the | 8 * in the documentation and/or other materials provided with the |
| 9 * distribution. | 9 * distribution. |
| 10 * * Neither the name of Google Inc. nor the names of its | 10 * * Neither the name of Google Inc. nor the names of its |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 52 if (primitiveValue->getValueID() == CSSValueMaxContent) | 52 if (primitiveValue->getValueID() == CSSValueMaxContent) |
| 53 return Length(MaxContent); | 53 return Length(MaxContent); |
| 54 | 54 |
| 55 // Fractional unit. | 55 // Fractional unit. |
| 56 if (primitiveValue->isFlex()) | 56 if (primitiveValue->isFlex()) |
| 57 return GridLength(primitiveValue->getDoubleValue()); | 57 return GridLength(primitiveValue->getDoubleValue()); |
| 58 | 58 |
| 59 return StyleBuilderConverter::convertLengthOrAuto(state, primitiveValue); | 59 return StyleBuilderConverter::convertLengthOrAuto(state, primitiveValue); |
| 60 } | 60 } |
| 61 | 61 |
| 62 template <CSSValueID cssValueFor0, CSSValueID cssValueFor100> | |
|
Timothy Loh
2015/06/04 03:58:26
Should just leave this function where it is
majidvp
2015/06/04 22:41:40
Done.
| |
| 63 static Length convertPositionLength(StyleResolverState& state, CSSPrimitiveValue * primitiveValue) | |
| 64 { | |
| 65 if (Pair* pair = primitiveValue->getPairValue()) { | |
| 66 Length length = StyleBuilderConverter::convertLength(state, pair->second ()); | |
| 67 if (pair->first()->getValueID() == cssValueFor0) | |
| 68 return length; | |
| 69 ASSERT(pair->first()->getValueID() == cssValueFor100); | |
| 70 return length.subtractFromOneHundredPercent(); | |
| 71 } | |
| 72 | |
| 73 return StyleBuilderConverter::convertLength(state, primitiveValue); | |
| 74 } | |
| 75 | |
| 62 } // namespace | 76 } // namespace |
| 63 | 77 |
| 64 PassRefPtr<StyleReflection> StyleBuilderConverter::convertBoxReflect(StyleResolv erState& state, CSSValue* value) | 78 PassRefPtr<StyleReflection> StyleBuilderConverter::convertBoxReflect(StyleResolv erState& state, CSSValue* value) |
| 65 { | 79 { |
| 66 if (value->isPrimitiveValue()) { | 80 if (value->isPrimitiveValue()) { |
| 67 ASSERT(toCSSPrimitiveValue(value)->getValueID() == CSSValueNone); | 81 ASSERT(toCSSPrimitiveValue(value)->getValueID() == CSSValueNone); |
| 68 return ComputedStyle::initialBoxReflect(); | 82 return ComputedStyle::initialBoxReflect(); |
| 69 } | 83 } |
| 70 | 84 |
| 71 CSSReflectValue* reflectValue = toCSSReflectValue(value); | 85 CSSReflectValue* reflectValue = toCSSReflectValue(value); |
| (...skipping 556 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 628 | 642 |
| 629 float StyleBuilderConverter::convertNumberOrPercentage(StyleResolverState& state , CSSValue* value) | 643 float StyleBuilderConverter::convertNumberOrPercentage(StyleResolverState& state , CSSValue* value) |
| 630 { | 644 { |
| 631 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); | 645 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); |
| 632 ASSERT(primitiveValue->isNumber() || primitiveValue->isPercentage()); | 646 ASSERT(primitiveValue->isNumber() || primitiveValue->isPercentage()); |
| 633 if (primitiveValue->isNumber()) | 647 if (primitiveValue->isNumber()) |
| 634 return primitiveValue->getFloatValue(); | 648 return primitiveValue->getFloatValue(); |
| 635 return primitiveValue->getFloatValue() / 100.0f; | 649 return primitiveValue->getFloatValue() / 100.0f; |
| 636 } | 650 } |
| 637 | 651 |
| 638 template <CSSValueID cssValueFor0, CSSValueID cssValueFor100> | 652 LengthPoint StyleBuilderConverter::convertPosition(StyleResolverState& state, CS SValue* value) |
| 639 static Length convertPositionLength(StyleResolverState& state, CSSPrimitiveValue * primitiveValue) | |
| 640 { | |
| 641 if (Pair* pair = primitiveValue->getPairValue()) { | |
| 642 Length length = StyleBuilderConverter::convertLength(state, pair->second ()); | |
| 643 if (pair->first()->getValueID() == cssValueFor0) | |
| 644 return length; | |
| 645 ASSERT(pair->first()->getValueID() == cssValueFor100); | |
| 646 return length.subtractFromOneHundredPercent(); | |
| 647 } | |
| 648 | |
| 649 return StyleBuilderConverter::convertLength(state, primitiveValue); | |
| 650 } | |
| 651 | |
| 652 LengthPoint StyleBuilderConverter::convertObjectPosition(StyleResolverState& sta te, CSSValue* value) | |
| 653 { | 653 { |
| 654 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); | 654 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); |
| 655 Pair* pair = primitiveValue->getPairValue(); | 655 Pair* pair = primitiveValue->getPairValue(); |
| 656 return LengthPoint( | 656 return LengthPoint( |
| 657 convertPositionLength<CSSValueLeft, CSSValueRight>(state, pair->first()) , | 657 convertPositionLength<CSSValueLeft, CSSValueRight>(state, pair->first()) , |
| 658 convertPositionLength<CSSValueTop, CSSValueBottom>(state, pair->second() ) | 658 convertPositionLength<CSSValueTop, CSSValueBottom>(state, pair->second() ) |
| 659 ); | 659 ); |
| 660 } | 660 } |
| 661 | 661 |
| 662 static float convertPerspectiveLength(StyleResolverState& state, CSSPrimitiveVal ue* primitiveValue) | 662 static float convertPerspectiveLength(StyleResolverState& state, CSSPrimitiveVal ue* primitiveValue) |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 894 CSSPrimitiveValue* primitiveValueY = toCSSPrimitiveValue(list->item(1)); | 894 CSSPrimitiveValue* primitiveValueY = toCSSPrimitiveValue(list->item(1)); |
| 895 CSSPrimitiveValue* primitiveValueZ = toCSSPrimitiveValue(list->item(2)); | 895 CSSPrimitiveValue* primitiveValueZ = toCSSPrimitiveValue(list->item(2)); |
| 896 | 896 |
| 897 return TransformOrigin( | 897 return TransformOrigin( |
| 898 convertOriginLength<CSSValueLeft, CSSValueRight>(state, primitiveValueX) , | 898 convertOriginLength<CSSValueLeft, CSSValueRight>(state, primitiveValueX) , |
| 899 convertOriginLength<CSSValueTop, CSSValueBottom>(state, primitiveValueY) , | 899 convertOriginLength<CSSValueTop, CSSValueBottom>(state, primitiveValueY) , |
| 900 StyleBuilderConverter::convertComputedLength<float>(state, primitiveValu eZ) | 900 StyleBuilderConverter::convertComputedLength<float>(state, primitiveValu eZ) |
| 901 ); | 901 ); |
| 902 } | 902 } |
| 903 | 903 |
| 904 ScrollSnapPoints StyleBuilderConverter::convertSnapPoints(StyleResolverState& st ate, CSSValue* value) | |
| 905 { | |
| 906 // Handles: none | repeat(<length>) | |
| 907 ScrollSnapPoints points; | |
| 908 points.hasRepeat = false; | |
| 909 | |
| 910 if (!value->isFunctionValue()) | |
| 911 return points; | |
| 912 | |
| 913 CSSFunctionValue* repeatFunction = toCSSFunctionValue(value); | |
| 914 ASSERT_WITH_SECURITY_IMPLICATION(repeatFunction->length() == 1); | |
| 915 points.repeatOffset = convertLength(state, toCSSPrimitiveValue(repeatFunctio n->item(0))); | |
| 916 points.hasRepeat = true; | |
| 917 | |
| 918 return points; | |
| 919 } | |
| 920 | |
| 921 Vector<LengthPoint> StyleBuilderConverter::convertSnapCoordinates(StyleResolverS tate& state, CSSValue* value) | |
| 922 { | |
| 923 // Handles: none | <position># | |
| 924 Vector<LengthPoint> coordinates; | |
| 925 | |
| 926 if (!value->isValueList()) | |
| 927 return coordinates; | |
| 928 | |
| 929 CSSValueList* valueList = toCSSValueList(value); | |
| 930 coordinates.reserveInitialCapacity(valueList->length()); | |
| 931 for (auto& snapCoordinate : *valueList) { | |
| 932 coordinates.uncheckedAppend(convertPosition(state, snapCoordinate.get()) ); | |
| 933 } | |
| 934 | |
| 935 return coordinates; | |
| 936 } | |
| 937 | |
| 904 } // namespace blink | 938 } // namespace blink |
| OLD | NEW |