| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
| 3 * (C) 2004-2005 Allan Sandfeld Jensen (kde@carewolf.com) | 3 * (C) 2004-2005 Allan Sandfeld Jensen (kde@carewolf.com) |
| 4 * Copyright (C) 2006, 2007 Nicholas Shanks (webkit@nickshanks.com) | 4 * Copyright (C) 2006, 2007 Nicholas Shanks (webkit@nickshanks.com) |
| 5 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc.
All rights reserved. | 5 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc.
All rights reserved. |
| 6 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> | 6 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> |
| 7 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org> | 7 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org> |
| 8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t
orchmobile.com/) | 8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t
orchmobile.com/) |
| 9 * Copyright (c) 2011, Code Aurora Forum. All rights reserved. | 9 * Copyright (c) 2011, Code Aurora Forum. All rights reserved. |
| 10 * Copyright (C) Research In Motion Limited 2011. All rights reserved. | 10 * Copyright (C) Research In Motion Limited 2011. All rights reserved. |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 #include "platform/transforms/MatrixTransformOperation.h" | 36 #include "platform/transforms/MatrixTransformOperation.h" |
| 37 #include "platform/transforms/PerspectiveTransformOperation.h" | 37 #include "platform/transforms/PerspectiveTransformOperation.h" |
| 38 #include "platform/transforms/RotateTransformOperation.h" | 38 #include "platform/transforms/RotateTransformOperation.h" |
| 39 #include "platform/transforms/ScaleTransformOperation.h" | 39 #include "platform/transforms/ScaleTransformOperation.h" |
| 40 #include "platform/transforms/SkewTransformOperation.h" | 40 #include "platform/transforms/SkewTransformOperation.h" |
| 41 #include "platform/transforms/TransformationMatrix.h" | 41 #include "platform/transforms/TransformationMatrix.h" |
| 42 #include "platform/transforms/TranslateTransformOperation.h" | 42 #include "platform/transforms/TranslateTransformOperation.h" |
| 43 | 43 |
| 44 namespace blink { | 44 namespace blink { |
| 45 | 45 |
| 46 static Length convertToFloatLength(CSSPrimitiveValue& primitiveValue, const CSST
oLengthConversionData& conversionData) | 46 static Length convertToFloatLength(CSSPrimitiveValue primitiveValue, const CSSTo
LengthConversionData& conversionData) |
| 47 { | 47 { |
| 48 return primitiveValue.convertToLength(conversionData); | 48 return primitiveValue.convertToLength(conversionData); |
| 49 } | 49 } |
| 50 | 50 |
| 51 static TransformOperation::OperationType getTransformOperationType(CSSValueID ty
pe) | 51 static TransformOperation::OperationType getTransformOperationType(CSSValueID ty
pe) |
| 52 { | 52 { |
| 53 switch (type) { | 53 switch (type) { |
| 54 case CSSValueScale: return TransformOperation::Scale; | 54 case CSSValueScale: return TransformOperation::Scale; |
| 55 case CSSValueScaleX: return TransformOperation::ScaleX; | 55 case CSSValueScaleX: return TransformOperation::ScaleX; |
| 56 case CSSValueScaleY: return TransformOperation::ScaleY; | 56 case CSSValueScaleY: return TransformOperation::ScaleY; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 85 if (!inValue.isValueList()) { | 85 if (!inValue.isValueList()) { |
| 86 ASSERT(inValue.isPrimitiveValue() && toCSSPrimitiveValue(inValue).getVal
ueID() == CSSValueNone); | 86 ASSERT(inValue.isPrimitiveValue() && toCSSPrimitiveValue(inValue).getVal
ueID() == CSSValueNone); |
| 87 return; | 87 return; |
| 88 } | 88 } |
| 89 | 89 |
| 90 float zoomFactor = conversionData.zoom(); | 90 float zoomFactor = conversionData.zoom(); |
| 91 for (auto& value : toCSSValueList(inValue)) { | 91 for (auto& value : toCSSValueList(inValue)) { |
| 92 CSSFunctionValue& transformValue = toCSSFunctionValue(value); | 92 CSSFunctionValue& transformValue = toCSSFunctionValue(value); |
| 93 TransformOperation::OperationType transformType = getTransformOperationT
ype(transformValue.functionType()); | 93 TransformOperation::OperationType transformType = getTransformOperationT
ype(transformValue.functionType()); |
| 94 | 94 |
| 95 CSSPrimitiveValue& firstValue = toCSSPrimitiveValue(transformValue.item(
0)); | 95 const CSSPrimitiveValue& firstValue = toCSSPrimitiveValue(transformValue
.item(0)); |
| 96 | 96 |
| 97 switch (transformType) { | 97 switch (transformType) { |
| 98 case TransformOperation::Scale: | 98 case TransformOperation::Scale: |
| 99 case TransformOperation::ScaleX: | 99 case TransformOperation::ScaleX: |
| 100 case TransformOperation::ScaleY: { | 100 case TransformOperation::ScaleY: { |
| 101 double sx = 1.0; | 101 double sx = 1.0; |
| 102 double sy = 1.0; | 102 double sy = 1.0; |
| 103 if (transformType == TransformOperation::ScaleY) { | 103 if (transformType == TransformOperation::ScaleY) { |
| 104 sy = firstValue.getDoubleValue(); | 104 sy = firstValue.getDoubleValue(); |
| 105 } else { | 105 } else { |
| 106 sx = firstValue.getDoubleValue(); | 106 sx = firstValue.getDoubleValue(); |
| 107 if (transformType != TransformOperation::ScaleX) { | 107 if (transformType != TransformOperation::ScaleX) { |
| 108 if (transformValue.length() > 1) { | 108 if (transformValue.length() > 1) { |
| 109 CSSPrimitiveValue& secondValue = toCSSPrimitiveValue(tra
nsformValue.item(1)); | 109 const CSSPrimitiveValue& secondValue = toCSSPrimitiveVal
ue(transformValue.item(1)); |
| 110 sy = secondValue.getDoubleValue(); | 110 sy = secondValue.getDoubleValue(); |
| 111 } else { | 111 } else { |
| 112 sy = sx; | 112 sy = sx; |
| 113 } | 113 } |
| 114 } | 114 } |
| 115 } | 115 } |
| 116 outOperations.operations().append(ScaleTransformOperation::create(sx
, sy, 1.0, transformType)); | 116 outOperations.operations().append(ScaleTransformOperation::create(sx
, sy, 1.0, transformType)); |
| 117 break; | 117 break; |
| 118 } | 118 } |
| 119 case TransformOperation::ScaleZ: | 119 case TransformOperation::ScaleZ: |
| (...skipping 15 matching lines...) Expand all Loading... |
| 135 case TransformOperation::TranslateX: | 135 case TransformOperation::TranslateX: |
| 136 case TransformOperation::TranslateY: { | 136 case TransformOperation::TranslateY: { |
| 137 Length tx = Length(0, Fixed); | 137 Length tx = Length(0, Fixed); |
| 138 Length ty = Length(0, Fixed); | 138 Length ty = Length(0, Fixed); |
| 139 if (transformType == TransformOperation::TranslateY) | 139 if (transformType == TransformOperation::TranslateY) |
| 140 ty = convertToFloatLength(firstValue, conversionData); | 140 ty = convertToFloatLength(firstValue, conversionData); |
| 141 else { | 141 else { |
| 142 tx = convertToFloatLength(firstValue, conversionData); | 142 tx = convertToFloatLength(firstValue, conversionData); |
| 143 if (transformType != TransformOperation::TranslateX) { | 143 if (transformType != TransformOperation::TranslateX) { |
| 144 if (transformValue.length() > 1) { | 144 if (transformValue.length() > 1) { |
| 145 CSSPrimitiveValue& secondValue = toCSSPrimitiveValue(tra
nsformValue.item(1)); | 145 const CSSPrimitiveValue& secondValue = toCSSPrimitiveVal
ue(transformValue.item(1)); |
| 146 ty = convertToFloatLength(secondValue, conversionData); | 146 ty = convertToFloatLength(secondValue, conversionData); |
| 147 } | 147 } |
| 148 } | 148 } |
| 149 } | 149 } |
| 150 | 150 |
| 151 outOperations.operations().append(TranslateTransformOperation::creat
e(tx, ty, 0, transformType)); | 151 outOperations.operations().append(TranslateTransformOperation::creat
e(tx, ty, 0, transformType)); |
| 152 break; | 152 break; |
| 153 } | 153 } |
| 154 case TransformOperation::TranslateZ: | 154 case TransformOperation::TranslateZ: |
| 155 case TransformOperation::Translate3D: { | 155 case TransformOperation::Translate3D: { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 171 case TransformOperation::RotateY: | 171 case TransformOperation::RotateY: |
| 172 case TransformOperation::RotateZ: { | 172 case TransformOperation::RotateZ: { |
| 173 double angle = firstValue.computeDegrees(); | 173 double angle = firstValue.computeDegrees(); |
| 174 double x = transformType == TransformOperation::RotateX; | 174 double x = transformType == TransformOperation::RotateX; |
| 175 double y = transformType == TransformOperation::RotateY; | 175 double y = transformType == TransformOperation::RotateY; |
| 176 double z = transformType == TransformOperation::RotateZ; | 176 double z = transformType == TransformOperation::RotateZ; |
| 177 outOperations.operations().append(RotateTransformOperation::create(x
, y, z, angle, transformType)); | 177 outOperations.operations().append(RotateTransformOperation::create(x
, y, z, angle, transformType)); |
| 178 break; | 178 break; |
| 179 } | 179 } |
| 180 case TransformOperation::Rotate3D: { | 180 case TransformOperation::Rotate3D: { |
| 181 CSSPrimitiveValue& secondValue = toCSSPrimitiveValue(transformValue.
item(1)); | 181 const CSSPrimitiveValue& secondValue = toCSSPrimitiveValue(transform
Value.item(1)); |
| 182 CSSPrimitiveValue& thirdValue = toCSSPrimitiveValue(transformValue.i
tem(2)); | 182 const CSSPrimitiveValue& thirdValue = toCSSPrimitiveValue(transformV
alue.item(2)); |
| 183 CSSPrimitiveValue& fourthValue = toCSSPrimitiveValue(transformValue.
item(3)); | 183 const CSSPrimitiveValue& fourthValue = toCSSPrimitiveValue(transform
Value.item(3)); |
| 184 double x = firstValue.getDoubleValue(); | 184 double x = firstValue.getDoubleValue(); |
| 185 double y = secondValue.getDoubleValue(); | 185 double y = secondValue.getDoubleValue(); |
| 186 double z = thirdValue.getDoubleValue(); | 186 double z = thirdValue.getDoubleValue(); |
| 187 double angle = fourthValue.computeDegrees(); | 187 double angle = fourthValue.computeDegrees(); |
| 188 outOperations.operations().append(RotateTransformOperation::create(x
, y, z, angle, transformType)); | 188 outOperations.operations().append(RotateTransformOperation::create(x
, y, z, angle, transformType)); |
| 189 break; | 189 break; |
| 190 } | 190 } |
| 191 case TransformOperation::Skew: | 191 case TransformOperation::Skew: |
| 192 case TransformOperation::SkewX: | 192 case TransformOperation::SkewX: |
| 193 case TransformOperation::SkewY: { | 193 case TransformOperation::SkewY: { |
| 194 double angleX = 0; | 194 double angleX = 0; |
| 195 double angleY = 0; | 195 double angleY = 0; |
| 196 double angle = firstValue.computeDegrees(); | 196 double angle = firstValue.computeDegrees(); |
| 197 if (transformType == TransformOperation::SkewY) | 197 if (transformType == TransformOperation::SkewY) |
| 198 angleY = angle; | 198 angleY = angle; |
| 199 else { | 199 else { |
| 200 angleX = angle; | 200 angleX = angle; |
| 201 if (transformType == TransformOperation::Skew) { | 201 if (transformType == TransformOperation::Skew) { |
| 202 if (transformValue.length() > 1) { | 202 if (transformValue.length() > 1) { |
| 203 CSSPrimitiveValue& secondValue = toCSSPrimitiveValue(tra
nsformValue.item(1)); | 203 const CSSPrimitiveValue& secondValue = toCSSPrimitiveVal
ue(transformValue.item(1)); |
| 204 angleY = secondValue.computeDegrees(); | 204 angleY = secondValue.computeDegrees(); |
| 205 } | 205 } |
| 206 } | 206 } |
| 207 } | 207 } |
| 208 outOperations.operations().append(SkewTransformOperation::create(ang
leX, angleY, transformType)); | 208 outOperations.operations().append(SkewTransformOperation::create(ang
leX, angleY, transformType)); |
| 209 break; | 209 break; |
| 210 } | 210 } |
| 211 case TransformOperation::Matrix: { | 211 case TransformOperation::Matrix: { |
| 212 double a = firstValue.getDoubleValue(); | 212 double a = firstValue.getDoubleValue(); |
| 213 double b = toCSSPrimitiveValue(transformValue.item(1)).getDoubleValu
e(); | 213 double b = toCSSPrimitiveValue(transformValue.item(1)).getDoubleValu
e(); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 break; | 245 break; |
| 246 } | 246 } |
| 247 default: | 247 default: |
| 248 ASSERT_NOT_REACHED(); | 248 ASSERT_NOT_REACHED(); |
| 249 break; | 249 break; |
| 250 } | 250 } |
| 251 } | 251 } |
| 252 } | 252 } |
| 253 | 253 |
| 254 } // namespace blink | 254 } // namespace blink |
| OLD | NEW |