OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. | 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 12 matching lines...) Expand all Loading... |
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
24 */ | 24 */ |
25 | 25 |
26 #include "config.h" | 26 #include "config.h" |
27 #include "core/css/CSSMatrix.h" | 27 #include "core/css/CSSMatrix.h" |
28 | 28 |
29 #include "CSSPropertyNames.h" | 29 #include "CSSPropertyNames.h" |
30 #include "CSSValueKeywords.h" | 30 #include "CSSValueKeywords.h" |
31 #include "bindings/v8/ExceptionState.h" | 31 #include "bindings/v8/ExceptionState.h" |
32 #include "core/css/CSSParser.h" | 32 #include "core/css/CSSParser.h" |
| 33 #include "core/css/CSSToLengthConversionData.h" |
33 #include "core/css/StylePropertySet.h" | 34 #include "core/css/StylePropertySet.h" |
34 #include "core/css/resolver/TransformBuilder.h" | 35 #include "core/css/resolver/TransformBuilder.h" |
35 #include "core/dom/ExceptionCode.h" | 36 #include "core/dom/ExceptionCode.h" |
| 37 #include "core/rendering/style/RenderStyle.h" |
| 38 #include "core/rendering/style/StyleInheritedData.h" |
36 #include "wtf/MathExtras.h" | 39 #include "wtf/MathExtras.h" |
37 | 40 |
38 namespace WebCore { | 41 namespace WebCore { |
39 | 42 |
40 CSSMatrix::CSSMatrix(const TransformationMatrix& m) | 43 CSSMatrix::CSSMatrix(const TransformationMatrix& m) |
41 : m_matrix(m) | 44 : m_matrix(m) |
42 { | 45 { |
43 ScriptWrappable::init(this); | 46 ScriptWrappable::init(this); |
44 } | 47 } |
45 | 48 |
(...skipping 11 matching lines...) Expand all Loading... |
57 RefPtr<MutableStylePropertySet> styleDeclaration = MutableStylePropertySet::
create(); | 60 RefPtr<MutableStylePropertySet> styleDeclaration = MutableStylePropertySet::
create(); |
58 if (CSSParser::parseValue(styleDeclaration.get(), CSSPropertyWebkitTransform
, string, true, HTMLStandardMode, 0)) { | 61 if (CSSParser::parseValue(styleDeclaration.get(), CSSPropertyWebkitTransform
, string, true, HTMLStandardMode, 0)) { |
59 // Convert to TransformOperations. This can fail if a property | 62 // Convert to TransformOperations. This can fail if a property |
60 // requires style (i.e., param uses 'ems' or 'exs') | 63 // requires style (i.e., param uses 'ems' or 'exs') |
61 RefPtr<CSSValue> value = styleDeclaration->getPropertyCSSValue(CSSProper
tyWebkitTransform); | 64 RefPtr<CSSValue> value = styleDeclaration->getPropertyCSSValue(CSSProper
tyWebkitTransform); |
62 | 65 |
63 // Check for a "none" or empty transform. In these cases we can use the
default identity matrix. | 66 // Check for a "none" or empty transform. In these cases we can use the
default identity matrix. |
64 if (!value || (value->isPrimitiveValue() && (toCSSPrimitiveValue(value.g
et()))->getValueID() == CSSValueNone)) | 67 if (!value || (value->isPrimitiveValue() && (toCSSPrimitiveValue(value.g
et()))->getValueID() == CSSValueNone)) |
65 return; | 68 return; |
66 | 69 |
| 70 DEFINE_STATIC_REF(RenderStyle, defaultStyle, RenderStyle::createDefaultS
tyle()); |
67 TransformOperations operations; | 71 TransformOperations operations; |
68 if (!TransformBuilder::createTransformOperations(value.get(), 0, 0, oper
ations)) { | 72 if (!TransformBuilder::createTransformOperations(value.get(), CSSToLengt
hConversionData(defaultStyle, defaultStyle), operations)) { |
69 exceptionState.throwUninformativeAndGenericDOMException(SyntaxError)
; | 73 exceptionState.throwUninformativeAndGenericDOMException(SyntaxError)
; |
70 return; | 74 return; |
71 } | 75 } |
72 | 76 |
73 // Convert transform operations to a TransformationMatrix. This can fail | 77 // Convert transform operations to a TransformationMatrix. This can fail |
74 // if a param has a percentage ('%') | 78 // if a param has a percentage ('%') |
75 if (operations.dependsOnBoxSize()) | 79 if (operations.dependsOnBoxSize()) |
76 exceptionState.throwUninformativeAndGenericDOMException(SyntaxError)
; | 80 exceptionState.throwUninformativeAndGenericDOMException(SyntaxError)
; |
77 TransformationMatrix t; | 81 TransformationMatrix t; |
78 operations.apply(FloatSize(0, 0), t); | 82 operations.apply(FloatSize(0, 0), t); |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 if (m_matrix.isAffine()) | 182 if (m_matrix.isAffine()) |
179 return String::format("matrix(%f, %f, %f, %f, %f, %f)", m_matrix.a(), m_
matrix.b(), m_matrix.c(), m_matrix.d(), m_matrix.e(), m_matrix.f()); | 183 return String::format("matrix(%f, %f, %f, %f, %f, %f)", m_matrix.a(), m_
matrix.b(), m_matrix.c(), m_matrix.d(), m_matrix.e(), m_matrix.f()); |
180 return String::format("matrix3d(%f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f,
%f, %f, %f, %f, %f)", | 184 return String::format("matrix3d(%f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f,
%f, %f, %f, %f, %f)", |
181 m_matrix.m11(), m_matrix.m12(), m_matrix.m13(), m_matrix.m14(), | 185 m_matrix.m11(), m_matrix.m12(), m_matrix.m13(), m_matrix.m14(), |
182 m_matrix.m21(), m_matrix.m22(), m_matrix.m23(), m_matrix.m24(), | 186 m_matrix.m21(), m_matrix.m22(), m_matrix.m23(), m_matrix.m24(), |
183 m_matrix.m31(), m_matrix.m32(), m_matrix.m33(), m_matrix.m34(), | 187 m_matrix.m31(), m_matrix.m32(), m_matrix.m33(), m_matrix.m34(), |
184 m_matrix.m41(), m_matrix.m42(), m_matrix.m43(), m_matrix.m44()); | 188 m_matrix.m41(), m_matrix.m42(), m_matrix.m43(), m_matrix.m44()); |
185 } | 189 } |
186 | 190 |
187 } // namespace WebCore | 191 } // namespace WebCore |
OLD | NEW |