| 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 917 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 928 | 928 |
| 929 CSSValueList* valueList = toCSSValueList(value); | 929 CSSValueList* valueList = toCSSValueList(value); |
| 930 coordinates.reserveInitialCapacity(valueList->length()); | 930 coordinates.reserveInitialCapacity(valueList->length()); |
| 931 for (auto& snapCoordinate : *valueList) { | 931 for (auto& snapCoordinate : *valueList) { |
| 932 coordinates.uncheckedAppend(convertPosition(state, snapCoordinate.get())
); | 932 coordinates.uncheckedAppend(convertPosition(state, snapCoordinate.get())
); |
| 933 } | 933 } |
| 934 | 934 |
| 935 return coordinates; | 935 return coordinates; |
| 936 } | 936 } |
| 937 | 937 |
| 938 PassRefPtr<TranslateTransformOperation> StyleBuilderConverter::convertTranslate(
StyleResolverState& state, CSSValue* value) |
| 939 { |
| 940 CSSValueList* list = toCSSValueList(value); |
| 941 ASSERT(list->length() >= 1 && list->length() <= 3); |
| 942 Length tx = toCSSPrimitiveValue(list->item(0))->convertToLength(state.cssToL
engthConversionData()); |
| 943 Length ty(0, Fixed); |
| 944 double tz = 0; |
| 945 TransformOperation::OperationType type = TransformOperation::TranslateX; |
| 946 |
| 947 if (list->length() >= 2) { |
| 948 ty = toCSSPrimitiveValue(list->item(1))->convertToLength(state.cssToLeng
thConversionData()); |
| 949 type = TransformOperation::Translate; |
| 950 } |
| 951 if (list->length() == 3) { |
| 952 tz = toCSSPrimitiveValue(list->item(2))->getDoubleValue(); |
| 953 type = TransformOperation::Translate3D; |
| 954 } |
| 955 return TranslateTransformOperation::create(tx, ty, tz, type); |
| 956 } |
| 957 |
| 958 PassRefPtr<RotateTransformOperation> StyleBuilderConverter::convertRotate(StyleR
esolverState& state, CSSValue* value) |
| 959 { |
| 960 CSSValueList* list = toCSSValueList(value); |
| 961 ASSERT(list->length() == 1 || list->length() == 4); |
| 962 double angle = toCSSPrimitiveValue(list->item(0))->computeDegrees(); |
| 963 double x = 0; |
| 964 double y = 0; |
| 965 double z = 1; |
| 966 if (list->length() == 4) { |
| 967 x = toCSSPrimitiveValue(list->item(1))->getDoubleValue(); |
| 968 y = toCSSPrimitiveValue(list->item(2))->getDoubleValue(); |
| 969 z = toCSSPrimitiveValue(list->item(3))->getDoubleValue(); |
| 970 } |
| 971 |
| 972 TransformOperation::OperationType type = (x == 0 && y == 0 && z == 1) ? Tran
sformOperation::Rotate : TransformOperation::Rotate3D; |
| 973 |
| 974 return RotateTransformOperation::create(x, y, z, angle, type); |
| 975 } |
| 976 |
| 977 PassRefPtr<ScaleTransformOperation> StyleBuilderConverter::convertScale(StyleRes
olverState& state, CSSValue* value) |
| 978 { |
| 979 CSSValueList* list = toCSSValueList(value); |
| 980 ASSERT(list->length() >= 1 && list->length() <= 3); |
| 981 double sx = toCSSPrimitiveValue(list->item(0))->getDoubleValue(); |
| 982 double sy = 1; |
| 983 double sz = 1; |
| 984 if (list->length() >= 2 && list->length() <= 3) |
| 985 sy = toCSSPrimitiveValue(list->item(1))->getDoubleValue(); |
| 986 if (list->length() == 3) |
| 987 sz = toCSSPrimitiveValue(list->item(2))->getDoubleValue(); |
| 988 |
| 989 TransformOperation::OperationType type; |
| 990 if (sz == 1) { |
| 991 if (sy == 1) |
| 992 type = TransformOperation::ScaleX; |
| 993 else |
| 994 type = TransformOperation::Scale; |
| 995 } else { |
| 996 type = TransformOperation::Scale3D; |
| 997 } |
| 998 return ScaleTransformOperation::create(sx, sy, sz, type); |
| 999 } |
| 1000 |
| 938 } // namespace blink | 1001 } // namespace blink |
| OLD | NEW |