| 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 12 matching lines...) Expand all Loading... |
| 23 * You should have received a copy of the GNU Library General Public License | 23 * You should have received a copy of the GNU Library General Public License |
| 24 * along with this library; see the file COPYING.LIB. If not, write to | 24 * along with this library; see the file COPYING.LIB. If not, write to |
| 25 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 25 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 26 * Boston, MA 02110-1301, USA. | 26 * Boston, MA 02110-1301, USA. |
| 27 */ | 27 */ |
| 28 | 28 |
| 29 #include "config.h" | 29 #include "config.h" |
| 30 #include "core/css/resolver/TransformBuilder.h" | 30 #include "core/css/resolver/TransformBuilder.h" |
| 31 | 31 |
| 32 #include "core/css/CSSPrimitiveValueMappings.h" | 32 #include "core/css/CSSPrimitiveValueMappings.h" |
| 33 #include "core/css/WebKitCSSTransformValue.h" | 33 #include "core/css/CSSTransformValue.h" |
| 34 #include "core/platform/graphics/transforms/Matrix3DTransformOperation.h" | 34 #include "core/platform/graphics/transforms/Matrix3DTransformOperation.h" |
| 35 #include "core/platform/graphics/transforms/MatrixTransformOperation.h" | 35 #include "core/platform/graphics/transforms/MatrixTransformOperation.h" |
| 36 #include "core/platform/graphics/transforms/PerspectiveTransformOperation.h" | 36 #include "core/platform/graphics/transforms/PerspectiveTransformOperation.h" |
| 37 #include "core/platform/graphics/transforms/RotateTransformOperation.h" | 37 #include "core/platform/graphics/transforms/RotateTransformOperation.h" |
| 38 #include "core/platform/graphics/transforms/ScaleTransformOperation.h" | 38 #include "core/platform/graphics/transforms/ScaleTransformOperation.h" |
| 39 #include "core/platform/graphics/transforms/SkewTransformOperation.h" | 39 #include "core/platform/graphics/transforms/SkewTransformOperation.h" |
| 40 #include "core/platform/graphics/transforms/TransformationMatrix.h" | 40 #include "core/platform/graphics/transforms/TransformationMatrix.h" |
| 41 #include "core/platform/graphics/transforms/TranslateTransformOperation.h" | 41 #include "core/platform/graphics/transforms/TranslateTransformOperation.h" |
| 42 #include "core/rendering/style/RenderStyle.h" | 42 #include "core/rendering/style/RenderStyle.h" |
| 43 | 43 |
| 44 namespace WebCore { | 44 namespace WebCore { |
| 45 | 45 |
| 46 TransformBuilder::TransformBuilder() | 46 TransformBuilder::TransformBuilder() |
| 47 { | 47 { |
| 48 } | 48 } |
| 49 | 49 |
| 50 TransformBuilder::~TransformBuilder() | 50 TransformBuilder::~TransformBuilder() |
| 51 { | 51 { |
| 52 } | 52 } |
| 53 | 53 |
| 54 static Length convertToFloatLength(CSSPrimitiveValue* primitiveValue, RenderStyl
e* style, RenderStyle* rootStyle, double multiplier) | 54 static Length convertToFloatLength(CSSPrimitiveValue* primitiveValue, RenderStyl
e* style, RenderStyle* rootStyle, double multiplier) |
| 55 { | 55 { |
| 56 return primitiveValue ? primitiveValue->convertToLength<FixedFloatConversion
| PercentConversion | CalculatedConversion | FractionConversion | ViewportPerce
ntageConversion>(style, rootStyle, multiplier) : Length(Undefined); | 56 return primitiveValue ? primitiveValue->convertToLength<FixedFloatConversion
| PercentConversion | CalculatedConversion | FractionConversion | ViewportPerce
ntageConversion>(style, rootStyle, multiplier) : Length(Undefined); |
| 57 } | 57 } |
| 58 | 58 |
| 59 static TransformOperation::OperationType getTransformOperationType(WebKitCSSTran
sformValue::TransformOperationType type) | 59 static TransformOperation::OperationType getTransformOperationType(CSSTransformV
alue::TransformOperationType type) |
| 60 { | 60 { |
| 61 switch (type) { | 61 switch (type) { |
| 62 case WebKitCSSTransformValue::ScaleTransformOperation: return TransformOpera
tion::SCALE; | 62 case CSSTransformValue::ScaleTransformOperation: return TransformOperation::
SCALE; |
| 63 case WebKitCSSTransformValue::ScaleXTransformOperation: return TransformOper
ation::SCALE_X; | 63 case CSSTransformValue::ScaleXTransformOperation: return TransformOperation:
:SCALE_X; |
| 64 case WebKitCSSTransformValue::ScaleYTransformOperation: return TransformOper
ation::SCALE_Y; | 64 case CSSTransformValue::ScaleYTransformOperation: return TransformOperation:
:SCALE_Y; |
| 65 case WebKitCSSTransformValue::ScaleZTransformOperation: return TransformOper
ation::SCALE_Z; | 65 case CSSTransformValue::ScaleZTransformOperation: return TransformOperation:
:SCALE_Z; |
| 66 case WebKitCSSTransformValue::Scale3DTransformOperation: return TransformOpe
ration::SCALE_3D; | 66 case CSSTransformValue::Scale3DTransformOperation: return TransformOperation
::SCALE_3D; |
| 67 case WebKitCSSTransformValue::TranslateTransformOperation: return TransformO
peration::TRANSLATE; | 67 case CSSTransformValue::TranslateTransformOperation: return TransformOperati
on::TRANSLATE; |
| 68 case WebKitCSSTransformValue::TranslateXTransformOperation: return Transform
Operation::TRANSLATE_X; | 68 case CSSTransformValue::TranslateXTransformOperation: return TransformOperat
ion::TRANSLATE_X; |
| 69 case WebKitCSSTransformValue::TranslateYTransformOperation: return Transform
Operation::TRANSLATE_Y; | 69 case CSSTransformValue::TranslateYTransformOperation: return TransformOperat
ion::TRANSLATE_Y; |
| 70 case WebKitCSSTransformValue::TranslateZTransformOperation: return Transform
Operation::TRANSLATE_Z; | 70 case CSSTransformValue::TranslateZTransformOperation: return TransformOperat
ion::TRANSLATE_Z; |
| 71 case WebKitCSSTransformValue::Translate3DTransformOperation: return Transfor
mOperation::TRANSLATE_3D; | 71 case CSSTransformValue::Translate3DTransformOperation: return TransformOpera
tion::TRANSLATE_3D; |
| 72 case WebKitCSSTransformValue::RotateTransformOperation: return TransformOper
ation::ROTATE; | 72 case CSSTransformValue::RotateTransformOperation: return TransformOperation:
:ROTATE; |
| 73 case WebKitCSSTransformValue::RotateXTransformOperation: return TransformOpe
ration::ROTATE_X; | 73 case CSSTransformValue::RotateXTransformOperation: return TransformOperation
::ROTATE_X; |
| 74 case WebKitCSSTransformValue::RotateYTransformOperation: return TransformOpe
ration::ROTATE_Y; | 74 case CSSTransformValue::RotateYTransformOperation: return TransformOperation
::ROTATE_Y; |
| 75 case WebKitCSSTransformValue::RotateZTransformOperation: return TransformOpe
ration::ROTATE_Z; | 75 case CSSTransformValue::RotateZTransformOperation: return TransformOperation
::ROTATE_Z; |
| 76 case WebKitCSSTransformValue::Rotate3DTransformOperation: return TransformOp
eration::ROTATE_3D; | 76 case CSSTransformValue::Rotate3DTransformOperation: return TransformOperatio
n::ROTATE_3D; |
| 77 case WebKitCSSTransformValue::SkewTransformOperation: return TransformOperat
ion::SKEW; | 77 case CSSTransformValue::SkewTransformOperation: return TransformOperation::S
KEW; |
| 78 case WebKitCSSTransformValue::SkewXTransformOperation: return TransformOpera
tion::SKEW_X; | 78 case CSSTransformValue::SkewXTransformOperation: return TransformOperation::
SKEW_X; |
| 79 case WebKitCSSTransformValue::SkewYTransformOperation: return TransformOpera
tion::SKEW_Y; | 79 case CSSTransformValue::SkewYTransformOperation: return TransformOperation::
SKEW_Y; |
| 80 case WebKitCSSTransformValue::MatrixTransformOperation: return TransformOper
ation::MATRIX; | 80 case CSSTransformValue::MatrixTransformOperation: return TransformOperation:
:MATRIX; |
| 81 case WebKitCSSTransformValue::Matrix3DTransformOperation: return TransformOp
eration::MATRIX_3D; | 81 case CSSTransformValue::Matrix3DTransformOperation: return TransformOperatio
n::MATRIX_3D; |
| 82 case WebKitCSSTransformValue::PerspectiveTransformOperation: return Transfor
mOperation::PERSPECTIVE; | 82 case CSSTransformValue::PerspectiveTransformOperation: return TransformOpera
tion::PERSPECTIVE; |
| 83 case WebKitCSSTransformValue::UnknownTransformOperation: return TransformOpe
ration::NONE; | 83 case CSSTransformValue::UnknownTransformOperation: return TransformOperation
::NONE; |
| 84 } | 84 } |
| 85 return TransformOperation::NONE; | 85 return TransformOperation::NONE; |
| 86 } | 86 } |
| 87 | 87 |
| 88 bool TransformBuilder::createTransformOperations(CSSValue* inValue, RenderStyle*
style, RenderStyle* rootStyle, TransformOperations& outOperations) | 88 bool TransformBuilder::createTransformOperations(CSSValue* inValue, RenderStyle*
style, RenderStyle* rootStyle, TransformOperations& outOperations) |
| 89 { | 89 { |
| 90 if (!inValue || !inValue->isValueList()) { | 90 if (!inValue || !inValue->isValueList()) { |
| 91 outOperations.clear(); | 91 outOperations.clear(); |
| 92 return false; | 92 return false; |
| 93 } | 93 } |
| 94 | 94 |
| 95 float zoomFactor = style ? style->effectiveZoom() : 1; | 95 float zoomFactor = style ? style->effectiveZoom() : 1; |
| 96 TransformOperations operations; | 96 TransformOperations operations; |
| 97 for (CSSValueListIterator i = inValue; i.hasMore(); i.advance()) { | 97 for (CSSValueListIterator i = inValue; i.hasMore(); i.advance()) { |
| 98 CSSValue* currValue = i.value(); | 98 CSSValue* currValue = i.value(); |
| 99 | 99 |
| 100 if (!currValue->isWebKitCSSTransformValue()) | 100 if (!currValue->isCSSTransformValue()) |
| 101 continue; | 101 continue; |
| 102 | 102 |
| 103 WebKitCSSTransformValue* transformValue = static_cast<WebKitCSSTransform
Value*>(i.value()); | 103 CSSTransformValue* transformValue = static_cast<CSSTransformValue*>(i.va
lue()); |
| 104 if (!transformValue->length()) | 104 if (!transformValue->length()) |
| 105 continue; | 105 continue; |
| 106 | 106 |
| 107 bool haveNonPrimitiveValue = false; | 107 bool haveNonPrimitiveValue = false; |
| 108 for (unsigned j = 0; j < transformValue->length(); ++j) { | 108 for (unsigned j = 0; j < transformValue->length(); ++j) { |
| 109 if (!transformValue->itemWithoutBoundsCheck(j)->isPrimitiveValue())
{ | 109 if (!transformValue->itemWithoutBoundsCheck(j)->isPrimitiveValue())
{ |
| 110 haveNonPrimitiveValue = true; | 110 haveNonPrimitiveValue = true; |
| 111 break; | 111 break; |
| 112 } | 112 } |
| 113 } | 113 } |
| 114 if (haveNonPrimitiveValue) | 114 if (haveNonPrimitiveValue) |
| 115 continue; | 115 continue; |
| 116 | 116 |
| 117 CSSPrimitiveValue* firstValue = toCSSPrimitiveValue(transformValue->item
WithoutBoundsCheck(0)); | 117 CSSPrimitiveValue* firstValue = toCSSPrimitiveValue(transformValue->item
WithoutBoundsCheck(0)); |
| 118 | 118 |
| 119 switch (transformValue->operationType()) { | 119 switch (transformValue->operationType()) { |
| 120 case WebKitCSSTransformValue::ScaleTransformOperation: | 120 case CSSTransformValue::ScaleTransformOperation: |
| 121 case WebKitCSSTransformValue::ScaleXTransformOperation: | 121 case CSSTransformValue::ScaleXTransformOperation: |
| 122 case WebKitCSSTransformValue::ScaleYTransformOperation: { | 122 case CSSTransformValue::ScaleYTransformOperation: { |
| 123 double sx = 1.0; | 123 double sx = 1.0; |
| 124 double sy = 1.0; | 124 double sy = 1.0; |
| 125 if (transformValue->operationType() == WebKitCSSTransformValue::Scal
eYTransformOperation) | 125 if (transformValue->operationType() == CSSTransformValue::ScaleYTran
sformOperation) |
| 126 sy = firstValue->getDoubleValue(); | 126 sy = firstValue->getDoubleValue(); |
| 127 else { | 127 else { |
| 128 sx = firstValue->getDoubleValue(); | 128 sx = firstValue->getDoubleValue(); |
| 129 if (transformValue->operationType() != WebKitCSSTransformValue::
ScaleXTransformOperation) { | 129 if (transformValue->operationType() != CSSTransformValue::ScaleX
TransformOperation) { |
| 130 if (transformValue->length() > 1) { | 130 if (transformValue->length() > 1) { |
| 131 CSSPrimitiveValue* secondValue = toCSSPrimitiveValue(tra
nsformValue->itemWithoutBoundsCheck(1)); | 131 CSSPrimitiveValue* secondValue = toCSSPrimitiveValue(tra
nsformValue->itemWithoutBoundsCheck(1)); |
| 132 sy = secondValue->getDoubleValue(); | 132 sy = secondValue->getDoubleValue(); |
| 133 } else | 133 } else |
| 134 sy = sx; | 134 sy = sx; |
| 135 } | 135 } |
| 136 } | 136 } |
| 137 operations.operations().append(ScaleTransformOperation::create(sx, s
y, 1.0, getTransformOperationType(transformValue->operationType()))); | 137 operations.operations().append(ScaleTransformOperation::create(sx, s
y, 1.0, getTransformOperationType(transformValue->operationType()))); |
| 138 break; | 138 break; |
| 139 } | 139 } |
| 140 case WebKitCSSTransformValue::ScaleZTransformOperation: | 140 case CSSTransformValue::ScaleZTransformOperation: |
| 141 case WebKitCSSTransformValue::Scale3DTransformOperation: { | 141 case CSSTransformValue::Scale3DTransformOperation: { |
| 142 double sx = 1.0; | 142 double sx = 1.0; |
| 143 double sy = 1.0; | 143 double sy = 1.0; |
| 144 double sz = 1.0; | 144 double sz = 1.0; |
| 145 if (transformValue->operationType() == WebKitCSSTransformValue::Scal
eZTransformOperation) | 145 if (transformValue->operationType() == CSSTransformValue::ScaleZTran
sformOperation) |
| 146 sz = firstValue->getDoubleValue(); | 146 sz = firstValue->getDoubleValue(); |
| 147 else if (transformValue->operationType() == WebKitCSSTransformValue:
:ScaleYTransformOperation) | 147 else if (transformValue->operationType() == CSSTransformValue::Scale
YTransformOperation) |
| 148 sy = firstValue->getDoubleValue(); | 148 sy = firstValue->getDoubleValue(); |
| 149 else { | 149 else { |
| 150 sx = firstValue->getDoubleValue(); | 150 sx = firstValue->getDoubleValue(); |
| 151 if (transformValue->operationType() != WebKitCSSTransformValue::
ScaleXTransformOperation) { | 151 if (transformValue->operationType() != CSSTransformValue::ScaleX
TransformOperation) { |
| 152 if (transformValue->length() > 2) { | 152 if (transformValue->length() > 2) { |
| 153 CSSPrimitiveValue* thirdValue = toCSSPrimitiveValue(tran
sformValue->itemWithoutBoundsCheck(2)); | 153 CSSPrimitiveValue* thirdValue = toCSSPrimitiveValue(tran
sformValue->itemWithoutBoundsCheck(2)); |
| 154 sz = thirdValue->getDoubleValue(); | 154 sz = thirdValue->getDoubleValue(); |
| 155 } | 155 } |
| 156 if (transformValue->length() > 1) { | 156 if (transformValue->length() > 1) { |
| 157 CSSPrimitiveValue* secondValue = toCSSPrimitiveValue(tra
nsformValue->itemWithoutBoundsCheck(1)); | 157 CSSPrimitiveValue* secondValue = toCSSPrimitiveValue(tra
nsformValue->itemWithoutBoundsCheck(1)); |
| 158 sy = secondValue->getDoubleValue(); | 158 sy = secondValue->getDoubleValue(); |
| 159 } else | 159 } else |
| 160 sy = sx; | 160 sy = sx; |
| 161 } | 161 } |
| 162 } | 162 } |
| 163 operations.operations().append(ScaleTransformOperation::create(sx, s
y, sz, getTransformOperationType(transformValue->operationType()))); | 163 operations.operations().append(ScaleTransformOperation::create(sx, s
y, sz, getTransformOperationType(transformValue->operationType()))); |
| 164 break; | 164 break; |
| 165 } | 165 } |
| 166 case WebKitCSSTransformValue::TranslateTransformOperation: | 166 case CSSTransformValue::TranslateTransformOperation: |
| 167 case WebKitCSSTransformValue::TranslateXTransformOperation: | 167 case CSSTransformValue::TranslateXTransformOperation: |
| 168 case WebKitCSSTransformValue::TranslateYTransformOperation: { | 168 case CSSTransformValue::TranslateYTransformOperation: { |
| 169 Length tx = Length(0, Fixed); | 169 Length tx = Length(0, Fixed); |
| 170 Length ty = Length(0, Fixed); | 170 Length ty = Length(0, Fixed); |
| 171 if (transformValue->operationType() == WebKitCSSTransformValue::Tran
slateYTransformOperation) | 171 if (transformValue->operationType() == CSSTransformValue::TranslateY
TransformOperation) |
| 172 ty = convertToFloatLength(firstValue, style, rootStyle, zoomFact
or); | 172 ty = convertToFloatLength(firstValue, style, rootStyle, zoomFact
or); |
| 173 else { | 173 else { |
| 174 tx = convertToFloatLength(firstValue, style, rootStyle, zoomFact
or); | 174 tx = convertToFloatLength(firstValue, style, rootStyle, zoomFact
or); |
| 175 if (transformValue->operationType() != WebKitCSSTransformValue::
TranslateXTransformOperation) { | 175 if (transformValue->operationType() != CSSTransformValue::Transl
ateXTransformOperation) { |
| 176 if (transformValue->length() > 1) { | 176 if (transformValue->length() > 1) { |
| 177 CSSPrimitiveValue* secondValue = toCSSPrimitiveValue(tra
nsformValue->itemWithoutBoundsCheck(1)); | 177 CSSPrimitiveValue* secondValue = toCSSPrimitiveValue(tra
nsformValue->itemWithoutBoundsCheck(1)); |
| 178 ty = convertToFloatLength(secondValue, style, rootStyle,
zoomFactor); | 178 ty = convertToFloatLength(secondValue, style, rootStyle,
zoomFactor); |
| 179 } | 179 } |
| 180 } | 180 } |
| 181 } | 181 } |
| 182 | 182 |
| 183 if (tx.isUndefined() || ty.isUndefined()) | 183 if (tx.isUndefined() || ty.isUndefined()) |
| 184 return false; | 184 return false; |
| 185 | 185 |
| 186 operations.operations().append(TranslateTransformOperation::create(t
x, ty, Length(0, Fixed), getTransformOperationType(transformValue->operationType
()))); | 186 operations.operations().append(TranslateTransformOperation::create(t
x, ty, Length(0, Fixed), getTransformOperationType(transformValue->operationType
()))); |
| 187 break; | 187 break; |
| 188 } | 188 } |
| 189 case WebKitCSSTransformValue::TranslateZTransformOperation: | 189 case CSSTransformValue::TranslateZTransformOperation: |
| 190 case WebKitCSSTransformValue::Translate3DTransformOperation: { | 190 case CSSTransformValue::Translate3DTransformOperation: { |
| 191 Length tx = Length(0, Fixed); | 191 Length tx = Length(0, Fixed); |
| 192 Length ty = Length(0, Fixed); | 192 Length ty = Length(0, Fixed); |
| 193 Length tz = Length(0, Fixed); | 193 Length tz = Length(0, Fixed); |
| 194 if (transformValue->operationType() == WebKitCSSTransformValue::Tran
slateZTransformOperation) | 194 if (transformValue->operationType() == CSSTransformValue::TranslateZ
TransformOperation) |
| 195 tz = convertToFloatLength(firstValue, style, rootStyle, zoomFact
or); | 195 tz = convertToFloatLength(firstValue, style, rootStyle, zoomFact
or); |
| 196 else if (transformValue->operationType() == WebKitCSSTransformValue:
:TranslateYTransformOperation) | 196 else if (transformValue->operationType() == CSSTransformValue::Trans
lateYTransformOperation) |
| 197 ty = convertToFloatLength(firstValue, style, rootStyle, zoomFact
or); | 197 ty = convertToFloatLength(firstValue, style, rootStyle, zoomFact
or); |
| 198 else { | 198 else { |
| 199 tx = convertToFloatLength(firstValue, style, rootStyle, zoomFact
or); | 199 tx = convertToFloatLength(firstValue, style, rootStyle, zoomFact
or); |
| 200 if (transformValue->operationType() != WebKitCSSTransformValue::
TranslateXTransformOperation) { | 200 if (transformValue->operationType() != CSSTransformValue::Transl
ateXTransformOperation) { |
| 201 if (transformValue->length() > 2) { | 201 if (transformValue->length() > 2) { |
| 202 CSSPrimitiveValue* thirdValue = toCSSPrimitiveValue(tran
sformValue->itemWithoutBoundsCheck(2)); | 202 CSSPrimitiveValue* thirdValue = toCSSPrimitiveValue(tran
sformValue->itemWithoutBoundsCheck(2)); |
| 203 tz = convertToFloatLength(thirdValue, style, rootStyle,
zoomFactor); | 203 tz = convertToFloatLength(thirdValue, style, rootStyle,
zoomFactor); |
| 204 } | 204 } |
| 205 if (transformValue->length() > 1) { | 205 if (transformValue->length() > 1) { |
| 206 CSSPrimitiveValue* secondValue = toCSSPrimitiveValue(tra
nsformValue->itemWithoutBoundsCheck(1)); | 206 CSSPrimitiveValue* secondValue = toCSSPrimitiveValue(tra
nsformValue->itemWithoutBoundsCheck(1)); |
| 207 ty = convertToFloatLength(secondValue, style, rootStyle,
zoomFactor); | 207 ty = convertToFloatLength(secondValue, style, rootStyle,
zoomFactor); |
| 208 } | 208 } |
| 209 } | 209 } |
| 210 } | 210 } |
| 211 | 211 |
| 212 if (tx.isUndefined() || ty.isUndefined() || tz.isUndefined()) | 212 if (tx.isUndefined() || ty.isUndefined() || tz.isUndefined()) |
| 213 return false; | 213 return false; |
| 214 | 214 |
| 215 operations.operations().append(TranslateTransformOperation::create(t
x, ty, tz, getTransformOperationType(transformValue->operationType()))); | 215 operations.operations().append(TranslateTransformOperation::create(t
x, ty, tz, getTransformOperationType(transformValue->operationType()))); |
| 216 break; | 216 break; |
| 217 } | 217 } |
| 218 case WebKitCSSTransformValue::RotateTransformOperation: { | 218 case CSSTransformValue::RotateTransformOperation: { |
| 219 double angle = firstValue->computeDegrees(); | 219 double angle = firstValue->computeDegrees(); |
| 220 operations.operations().append(RotateTransformOperation::create(0, 0
, 1, angle, getTransformOperationType(transformValue->operationType()))); | 220 operations.operations().append(RotateTransformOperation::create(0, 0
, 1, angle, getTransformOperationType(transformValue->operationType()))); |
| 221 break; | 221 break; |
| 222 } | 222 } |
| 223 case WebKitCSSTransformValue::RotateXTransformOperation: | 223 case CSSTransformValue::RotateXTransformOperation: |
| 224 case WebKitCSSTransformValue::RotateYTransformOperation: | 224 case CSSTransformValue::RotateYTransformOperation: |
| 225 case WebKitCSSTransformValue::RotateZTransformOperation: { | 225 case CSSTransformValue::RotateZTransformOperation: { |
| 226 double x = 0; | 226 double x = 0; |
| 227 double y = 0; | 227 double y = 0; |
| 228 double z = 0; | 228 double z = 0; |
| 229 double angle = firstValue->computeDegrees(); | 229 double angle = firstValue->computeDegrees(); |
| 230 | 230 |
| 231 if (transformValue->operationType() == WebKitCSSTransformValue::Rota
teXTransformOperation) | 231 if (transformValue->operationType() == CSSTransformValue::RotateXTra
nsformOperation) |
| 232 x = 1; | 232 x = 1; |
| 233 else if (transformValue->operationType() == WebKitCSSTransformValue:
:RotateYTransformOperation) | 233 else if (transformValue->operationType() == CSSTransformValue::Rotat
eYTransformOperation) |
| 234 y = 1; | 234 y = 1; |
| 235 else | 235 else |
| 236 z = 1; | 236 z = 1; |
| 237 operations.operations().append(RotateTransformOperation::create(x, y
, z, angle, getTransformOperationType(transformValue->operationType()))); | 237 operations.operations().append(RotateTransformOperation::create(x, y
, z, angle, getTransformOperationType(transformValue->operationType()))); |
| 238 break; | 238 break; |
| 239 } | 239 } |
| 240 case WebKitCSSTransformValue::Rotate3DTransformOperation: { | 240 case CSSTransformValue::Rotate3DTransformOperation: { |
| 241 if (transformValue->length() < 4) | 241 if (transformValue->length() < 4) |
| 242 break; | 242 break; |
| 243 CSSPrimitiveValue* secondValue = toCSSPrimitiveValue(transformValue-
>itemWithoutBoundsCheck(1)); | 243 CSSPrimitiveValue* secondValue = toCSSPrimitiveValue(transformValue-
>itemWithoutBoundsCheck(1)); |
| 244 CSSPrimitiveValue* thirdValue = toCSSPrimitiveValue(transformValue->
itemWithoutBoundsCheck(2)); | 244 CSSPrimitiveValue* thirdValue = toCSSPrimitiveValue(transformValue->
itemWithoutBoundsCheck(2)); |
| 245 CSSPrimitiveValue* fourthValue = toCSSPrimitiveValue(transformValue-
>itemWithoutBoundsCheck(3)); | 245 CSSPrimitiveValue* fourthValue = toCSSPrimitiveValue(transformValue-
>itemWithoutBoundsCheck(3)); |
| 246 double x = firstValue->getDoubleValue(); | 246 double x = firstValue->getDoubleValue(); |
| 247 double y = secondValue->getDoubleValue(); | 247 double y = secondValue->getDoubleValue(); |
| 248 double z = thirdValue->getDoubleValue(); | 248 double z = thirdValue->getDoubleValue(); |
| 249 double angle = fourthValue->computeDegrees(); | 249 double angle = fourthValue->computeDegrees(); |
| 250 operations.operations().append(RotateTransformOperation::create(x, y
, z, angle, getTransformOperationType(transformValue->operationType()))); | 250 operations.operations().append(RotateTransformOperation::create(x, y
, z, angle, getTransformOperationType(transformValue->operationType()))); |
| 251 break; | 251 break; |
| 252 } | 252 } |
| 253 case WebKitCSSTransformValue::SkewTransformOperation: | 253 case CSSTransformValue::SkewTransformOperation: |
| 254 case WebKitCSSTransformValue::SkewXTransformOperation: | 254 case CSSTransformValue::SkewXTransformOperation: |
| 255 case WebKitCSSTransformValue::SkewYTransformOperation: { | 255 case CSSTransformValue::SkewYTransformOperation: { |
| 256 double angleX = 0; | 256 double angleX = 0; |
| 257 double angleY = 0; | 257 double angleY = 0; |
| 258 double angle = firstValue->computeDegrees(); | 258 double angle = firstValue->computeDegrees(); |
| 259 if (transformValue->operationType() == WebKitCSSTransformValue::Skew
YTransformOperation) | 259 if (transformValue->operationType() == CSSTransformValue::SkewYTrans
formOperation) |
| 260 angleY = angle; | 260 angleY = angle; |
| 261 else { | 261 else { |
| 262 angleX = angle; | 262 angleX = angle; |
| 263 if (transformValue->operationType() == WebKitCSSTransformValue::
SkewTransformOperation) { | 263 if (transformValue->operationType() == CSSTransformValue::SkewTr
ansformOperation) { |
| 264 if (transformValue->length() > 1) { | 264 if (transformValue->length() > 1) { |
| 265 CSSPrimitiveValue* secondValue = toCSSPrimitiveValue(tra
nsformValue->itemWithoutBoundsCheck(1)); | 265 CSSPrimitiveValue* secondValue = toCSSPrimitiveValue(tra
nsformValue->itemWithoutBoundsCheck(1)); |
| 266 angleY = secondValue->computeDegrees(); | 266 angleY = secondValue->computeDegrees(); |
| 267 } | 267 } |
| 268 } | 268 } |
| 269 } | 269 } |
| 270 operations.operations().append(SkewTransformOperation::create(angleX
, angleY, getTransformOperationType(transformValue->operationType()))); | 270 operations.operations().append(SkewTransformOperation::create(angleX
, angleY, getTransformOperationType(transformValue->operationType()))); |
| 271 break; | 271 break; |
| 272 } | 272 } |
| 273 case WebKitCSSTransformValue::MatrixTransformOperation: { | 273 case CSSTransformValue::MatrixTransformOperation: { |
| 274 if (transformValue->length() < 6) | 274 if (transformValue->length() < 6) |
| 275 break; | 275 break; |
| 276 double a = firstValue->getDoubleValue(); | 276 double a = firstValue->getDoubleValue(); |
| 277 double b = toCSSPrimitiveValue(transformValue->itemWithoutBoundsChec
k(1))->getDoubleValue(); | 277 double b = toCSSPrimitiveValue(transformValue->itemWithoutBoundsChec
k(1))->getDoubleValue(); |
| 278 double c = toCSSPrimitiveValue(transformValue->itemWithoutBoundsChec
k(2))->getDoubleValue(); | 278 double c = toCSSPrimitiveValue(transformValue->itemWithoutBoundsChec
k(2))->getDoubleValue(); |
| 279 double d = toCSSPrimitiveValue(transformValue->itemWithoutBoundsChec
k(3))->getDoubleValue(); | 279 double d = toCSSPrimitiveValue(transformValue->itemWithoutBoundsChec
k(3))->getDoubleValue(); |
| 280 double e = zoomFactor * toCSSPrimitiveValue(transformValue->itemWith
outBoundsCheck(4))->getDoubleValue(); | 280 double e = zoomFactor * toCSSPrimitiveValue(transformValue->itemWith
outBoundsCheck(4))->getDoubleValue(); |
| 281 double f = zoomFactor * toCSSPrimitiveValue(transformValue->itemWith
outBoundsCheck(5))->getDoubleValue(); | 281 double f = zoomFactor * toCSSPrimitiveValue(transformValue->itemWith
outBoundsCheck(5))->getDoubleValue(); |
| 282 operations.operations().append(MatrixTransformOperation::create(a, b
, c, d, e, f)); | 282 operations.operations().append(MatrixTransformOperation::create(a, b
, c, d, e, f)); |
| 283 break; | 283 break; |
| 284 } | 284 } |
| 285 case WebKitCSSTransformValue::Matrix3DTransformOperation: { | 285 case CSSTransformValue::Matrix3DTransformOperation: { |
| 286 if (transformValue->length() < 16) | 286 if (transformValue->length() < 16) |
| 287 break; | 287 break; |
| 288 TransformationMatrix matrix(toCSSPrimitiveValue(transformValue->item
WithoutBoundsCheck(0))->getDoubleValue(), | 288 TransformationMatrix matrix(toCSSPrimitiveValue(transformValue->item
WithoutBoundsCheck(0))->getDoubleValue(), |
| 289 toCSSPrimitiveValue(transformValue->itemWithoutBoundsCheck(1))->
getDoubleValue(), | 289 toCSSPrimitiveValue(transformValue->itemWithoutBoundsCheck(1))->
getDoubleValue(), |
| 290 toCSSPrimitiveValue(transformValue->itemWithoutBoundsCheck(2))->
getDoubleValue(), | 290 toCSSPrimitiveValue(transformValue->itemWithoutBoundsCheck(2))->
getDoubleValue(), |
| 291 toCSSPrimitiveValue(transformValue->itemWithoutBoundsCheck(3))->
getDoubleValue(), | 291 toCSSPrimitiveValue(transformValue->itemWithoutBoundsCheck(3))->
getDoubleValue(), |
| 292 toCSSPrimitiveValue(transformValue->itemWithoutBoundsCheck(4))->
getDoubleValue(), | 292 toCSSPrimitiveValue(transformValue->itemWithoutBoundsCheck(4))->
getDoubleValue(), |
| 293 toCSSPrimitiveValue(transformValue->itemWithoutBoundsCheck(5))->
getDoubleValue(), | 293 toCSSPrimitiveValue(transformValue->itemWithoutBoundsCheck(5))->
getDoubleValue(), |
| 294 toCSSPrimitiveValue(transformValue->itemWithoutBoundsCheck(6))->
getDoubleValue(), | 294 toCSSPrimitiveValue(transformValue->itemWithoutBoundsCheck(6))->
getDoubleValue(), |
| 295 toCSSPrimitiveValue(transformValue->itemWithoutBoundsCheck(7))->
getDoubleValue(), | 295 toCSSPrimitiveValue(transformValue->itemWithoutBoundsCheck(7))->
getDoubleValue(), |
| 296 toCSSPrimitiveValue(transformValue->itemWithoutBoundsCheck(8))->
getDoubleValue(), | 296 toCSSPrimitiveValue(transformValue->itemWithoutBoundsCheck(8))->
getDoubleValue(), |
| 297 toCSSPrimitiveValue(transformValue->itemWithoutBoundsCheck(9))->
getDoubleValue(), | 297 toCSSPrimitiveValue(transformValue->itemWithoutBoundsCheck(9))->
getDoubleValue(), |
| 298 toCSSPrimitiveValue(transformValue->itemWithoutBoundsCheck(10))-
>getDoubleValue(), | 298 toCSSPrimitiveValue(transformValue->itemWithoutBoundsCheck(10))-
>getDoubleValue(), |
| 299 toCSSPrimitiveValue(transformValue->itemWithoutBoundsCheck(11))-
>getDoubleValue(), | 299 toCSSPrimitiveValue(transformValue->itemWithoutBoundsCheck(11))-
>getDoubleValue(), |
| 300 zoomFactor * toCSSPrimitiveValue(transformValue->itemWithoutBoun
dsCheck(12))->getDoubleValue(), | 300 zoomFactor * toCSSPrimitiveValue(transformValue->itemWithoutBoun
dsCheck(12))->getDoubleValue(), |
| 301 zoomFactor * toCSSPrimitiveValue(transformValue->itemWithoutBoun
dsCheck(13))->getDoubleValue(), | 301 zoomFactor * toCSSPrimitiveValue(transformValue->itemWithoutBoun
dsCheck(13))->getDoubleValue(), |
| 302 toCSSPrimitiveValue(transformValue->itemWithoutBoundsCheck(14))-
>getDoubleValue(), | 302 toCSSPrimitiveValue(transformValue->itemWithoutBoundsCheck(14))-
>getDoubleValue(), |
| 303 toCSSPrimitiveValue(transformValue->itemWithoutBoundsCheck(15))-
>getDoubleValue()); | 303 toCSSPrimitiveValue(transformValue->itemWithoutBoundsCheck(15))-
>getDoubleValue()); |
| 304 operations.operations().append(Matrix3DTransformOperation::create(ma
trix)); | 304 operations.operations().append(Matrix3DTransformOperation::create(ma
trix)); |
| 305 break; | 305 break; |
| 306 } | 306 } |
| 307 case WebKitCSSTransformValue::PerspectiveTransformOperation: { | 307 case CSSTransformValue::PerspectiveTransformOperation: { |
| 308 Length p = Length(0, Fixed); | 308 Length p = Length(0, Fixed); |
| 309 if (firstValue->isLength()) | 309 if (firstValue->isLength()) |
| 310 p = convertToFloatLength(firstValue, style, rootStyle, zoomFacto
r); | 310 p = convertToFloatLength(firstValue, style, rootStyle, zoomFacto
r); |
| 311 else { | 311 else { |
| 312 // This is a quirk that should go away when 3d transforms are fi
nalized. | 312 // This is a quirk that should go away when 3d transforms are fi
nalized. |
| 313 double val = firstValue->getDoubleValue(); | 313 double val = firstValue->getDoubleValue(); |
| 314 p = val >= 0 ? Length(clampToPositiveInteger(val), Fixed) : Leng
th(Undefined); | 314 p = val >= 0 ? Length(clampToPositiveInteger(val), Fixed) : Leng
th(Undefined); |
| 315 } | 315 } |
| 316 | 316 |
| 317 if (p.isUndefined()) | 317 if (p.isUndefined()) |
| 318 return false; | 318 return false; |
| 319 | 319 |
| 320 operations.operations().append(PerspectiveTransformOperation::create
(p)); | 320 operations.operations().append(PerspectiveTransformOperation::create
(p)); |
| 321 break; | 321 break; |
| 322 } | 322 } |
| 323 case WebKitCSSTransformValue::UnknownTransformOperation: | 323 case CSSTransformValue::UnknownTransformOperation: |
| 324 ASSERT_NOT_REACHED(); | 324 ASSERT_NOT_REACHED(); |
| 325 break; | 325 break; |
| 326 } | 326 } |
| 327 } | 327 } |
| 328 | 328 |
| 329 outOperations = operations; | 329 outOperations = operations; |
| 330 return true; | 330 return true; |
| 331 } | 331 } |
| 332 | 332 |
| 333 } // namespace WebCore | 333 } // namespace WebCore |
| OLD | NEW |