Index: third_party/WebKit/Source/core/css/CSSMatrix.cpp |
diff --git a/third_party/WebKit/Source/core/css/CSSMatrix.cpp b/third_party/WebKit/Source/core/css/CSSMatrix.cpp |
index 00e937709f5d0b396e4f059eed02a216d4d57118..06beb451bdf51baba423be98a37fdb75c60787c2 100644 |
--- a/third_party/WebKit/Source/core/css/CSSMatrix.cpp |
+++ b/third_party/WebKit/Source/core/css/CSSMatrix.cpp |
@@ -33,6 +33,7 @@ |
#include "core/css/StylePropertySet.h" |
#include "core/css/parser/CSSParser.h" |
#include "core/css/resolver/TransformBuilder.h" |
+#include "core/dom/DOMMatrix.h" |
#include "core/dom/ExceptionCode.h" |
#include "core/frame/UseCounter.h" |
#include "core/layout/api/LayoutViewItem.h" |
@@ -49,95 +50,71 @@ CSSMatrix* CSSMatrix::create(ExecutionContext* executionContext, |
return new CSSMatrix(s, exceptionState); |
} |
-CSSMatrix::CSSMatrix(const TransformationMatrix& m) |
- : m_matrix(TransformationMatrix::create(m)) {} |
+CSSMatrix::CSSMatrix(const TransformationMatrix& m) : DOMMatrix(m) {} |
CSSMatrix::CSSMatrix(const String& s, ExceptionState& exceptionState) |
- : m_matrix(TransformationMatrix::create()) { |
+ : DOMMatrix() { |
setMatrixValue(s, exceptionState); |
} |
-static inline PassRefPtr<ComputedStyle> createInitialStyle() { |
- RefPtr<ComputedStyle> initialStyle = ComputedStyle::create(); |
- initialStyle->font().update(nullptr); |
- return initialStyle; |
-} |
- |
void CSSMatrix::setMatrixValue(const String& string, |
ExceptionState& exceptionState) { |
- if (string.isEmpty()) |
- return; |
- |
- if (const CSSValue* value = |
- CSSParser::parseSingleValue(CSSPropertyTransform, string)) { |
- // Check for a "none" transform. In these cases we can use the default |
- // identity matrix. |
- if (value->isIdentifierValue() && |
- (toCSSIdentifierValue(value))->getValueID() == CSSValueNone) |
- return; |
- |
- DEFINE_STATIC_REF(ComputedStyle, initialStyle, createInitialStyle()); |
- TransformOperations operations = |
- TransformBuilder::createTransformOperations( |
- *value, CSSToLengthConversionData(initialStyle, initialStyle, |
- LayoutViewItem(nullptr), 1.0f)); |
- |
- // Convert transform operations to a TransformationMatrix. This can fail |
- // if a param has a percentage ('%') |
- if (operations.dependsOnBoxSize()) |
- exceptionState.throwDOMException(SyntaxError, |
- "The transformation depends on the box " |
- "size, which is not supported."); |
- m_matrix = TransformationMatrix::create(); |
- operations.apply(FloatSize(0, 0), *m_matrix); |
- } else { // There is something there but parsing failed. |
- exceptionState.throwDOMException(SyntaxError, |
- "Failed to parse '" + string + "'."); |
- } |
+ DOMMatrix::setMatrixValue(string, exceptionState); |
} |
// Perform a concatenation of the matrices (this * secondMatrix) |
-CSSMatrix* CSSMatrix::multiply(CSSMatrix* secondMatrix) const { |
+CSSMatrix* CSSMatrix::multiply(CSSMatrix* secondMatrix, |
+ ExceptionState& exceptionState) { |
if (!secondMatrix) |
return nullptr; |
- return CSSMatrix::create( |
- TransformationMatrix(*m_matrix).multiply(*secondMatrix->m_matrix)); |
+ DOMMatrixInit matrix; |
+ |
+ matrix.setM11(secondMatrix->m11()); |
+ matrix.setM12(secondMatrix->m12()); |
+ matrix.setM13(secondMatrix->m13()); |
+ matrix.setM14(secondMatrix->m14()); |
+ matrix.setM21(secondMatrix->m21()); |
+ matrix.setM22(secondMatrix->m22()); |
+ matrix.setM23(secondMatrix->m23()); |
+ matrix.setM24(secondMatrix->m24()); |
+ matrix.setM31(secondMatrix->m31()); |
+ matrix.setM32(secondMatrix->m32()); |
+ matrix.setM33(secondMatrix->m33()); |
+ matrix.setM34(secondMatrix->m34()); |
+ matrix.setM41(secondMatrix->m41()); |
+ matrix.setM42(secondMatrix->m42()); |
+ matrix.setM43(secondMatrix->m43()); |
+ matrix.setM44(secondMatrix->m44()); |
+ |
+ return (CSSMatrix*)multiplySelf(matrix, exceptionState); |
} |
-CSSMatrix* CSSMatrix::inverse(ExceptionState& exceptionState) const { |
- if (!m_matrix->isInvertible()) { |
- exceptionState.throwDOMException(NotSupportedError, |
- "The matrix is not invertable."); |
- return nullptr; |
- } |
- |
- return CSSMatrix::create(m_matrix->inverse()); |
+CSSMatrix* CSSMatrix::inverse(ExceptionState& exceptionState) { |
+ return (CSSMatrix*)invertSelf(); |
} |
-CSSMatrix* CSSMatrix::translate(double x, double y, double z) const { |
+CSSMatrix* CSSMatrix::translate(double x, double y, double z) { |
if (std::isnan(x)) |
x = 0; |
if (std::isnan(y)) |
y = 0; |
if (std::isnan(z)) |
z = 0; |
- return CSSMatrix::create( |
- TransformationMatrix(*m_matrix).translate3d(x, y, z)); |
+ return (CSSMatrix*)translateSelf(x, y, z); |
} |
-CSSMatrix* CSSMatrix::scale(double scaleX, double scaleY, double scaleZ) const { |
+CSSMatrix* CSSMatrix::scale(double scaleX, double scaleY, double scaleZ) { |
if (std::isnan(scaleX)) |
scaleX = 1; |
if (std::isnan(scaleY)) |
scaleY = scaleX; |
if (std::isnan(scaleZ)) |
scaleZ = 1; |
- return CSSMatrix::create( |
- TransformationMatrix(*m_matrix).scale3d(scaleX, scaleY, scaleZ)); |
+ return (CSSMatrix*)scaleSelf(scaleX, scaleY, scaleZ); |
} |
-CSSMatrix* CSSMatrix::rotate(double rotX, double rotY, double rotZ) const { |
+CSSMatrix* CSSMatrix::rotate(double rotX, double rotY, double rotZ) { |
if (std::isnan(rotX)) |
rotX = 0; |
@@ -151,14 +128,13 @@ CSSMatrix* CSSMatrix::rotate(double rotX, double rotY, double rotZ) const { |
rotY = 0; |
if (std::isnan(rotZ)) |
rotZ = 0; |
- return CSSMatrix::create( |
- TransformationMatrix(*m_matrix).rotate3d(rotX, rotY, rotZ)); |
+ return (CSSMatrix*)rotateSelf(rotX, rotY, rotZ); |
} |
CSSMatrix* CSSMatrix::rotateAxisAngle(double x, |
double y, |
double z, |
- double angle) const { |
+ double angle) { |
if (std::isnan(x)) |
x = 0; |
if (std::isnan(y)) |
@@ -169,36 +145,23 @@ CSSMatrix* CSSMatrix::rotateAxisAngle(double x, |
angle = 0; |
if (!x && !y && !z) |
z = 1; |
- return CSSMatrix::create( |
- TransformationMatrix(*m_matrix).rotate3d(x, y, z, angle)); |
+ return (CSSMatrix*)rotateAxisAngleSelf(x, y, z, angle); |
} |
-CSSMatrix* CSSMatrix::skewX(double angle) const { |
+CSSMatrix* CSSMatrix::skewX(double angle) { |
if (std::isnan(angle)) |
angle = 0; |
- return CSSMatrix::create(TransformationMatrix(*m_matrix).skewX(angle)); |
+ return (CSSMatrix*)skewXSelf(angle); |
} |
-CSSMatrix* CSSMatrix::skewY(double angle) const { |
+CSSMatrix* CSSMatrix::skewY(double angle) { |
if (std::isnan(angle)) |
angle = 0; |
- return CSSMatrix::create(TransformationMatrix(*m_matrix).skewY(angle)); |
+ return (CSSMatrix*)skewYSelf(angle); |
} |
-String CSSMatrix::toString() const { |
- // FIXME - Need to ensure valid CSS floating point values |
- // (https://bugs.webkit.org/show_bug.cgi?id=20674) |
- if (m_matrix->isAffine()) |
- 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()); |
- return String::format( |
- "matrix3d(%f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, " |
- "%f)", |
- m_matrix->m11(), m_matrix->m12(), m_matrix->m13(), m_matrix->m14(), |
- m_matrix->m21(), m_matrix->m22(), m_matrix->m23(), m_matrix->m24(), |
- m_matrix->m31(), m_matrix->m32(), m_matrix->m33(), m_matrix->m34(), |
- m_matrix->m41(), m_matrix->m42(), m_matrix->m43(), m_matrix->m44()); |
+String CSSMatrix::toString() { |
+ return DOMMatrix::toString(); |
} |
} // namespace blink |