diff options
Diffstat (limited to 'Source/WebCore/css/WebKitCSSMatrix.cpp')
-rw-r--r-- | Source/WebCore/css/WebKitCSSMatrix.cpp | 72 |
1 files changed, 26 insertions, 46 deletions
diff --git a/Source/WebCore/css/WebKitCSSMatrix.cpp b/Source/WebCore/css/WebKitCSSMatrix.cpp index 46d3f3ed8..4f53657f8 100644 --- a/Source/WebCore/css/WebKitCSSMatrix.cpp +++ b/Source/WebCore/css/WebKitCSSMatrix.cpp @@ -28,7 +28,6 @@ #include "CSSParser.h" #include "CSSPropertyNames.h" -#include "CSSToLengthConversionData.h" #include "CSSValueKeywords.h" #include "ExceptionCode.h" #include "StyleProperties.h" @@ -57,17 +56,17 @@ void WebKitCSSMatrix::setMatrixValue(const String& string, ExceptionCode& ec) return; RefPtr<MutableStyleProperties> styleDeclaration = MutableStyleProperties::create(); - if (CSSParser::parseValue(styleDeclaration.get(), CSSPropertyTransform, string, true, CSSStrictMode, nullptr) != CSSParser::ParseResult::Error) { + if (CSSParser::parseValue(styleDeclaration.get(), CSSPropertyWebkitTransform, string, true, CSSStrictMode, 0)) { // Convert to TransformOperations. This can fail if a property // requires style (i.e., param uses 'ems' or 'exs') - RefPtr<CSSValue> value = styleDeclaration->getPropertyCSSValue(CSSPropertyTransform); + RefPtr<CSSValue> value = styleDeclaration->getPropertyCSSValue(CSSPropertyWebkitTransform); // Check for a "none" or empty transform. In these cases we can use the default identity matrix. - if (!value || (is<CSSPrimitiveValue>(*value) && downcast<CSSPrimitiveValue>(*value).getValueID() == CSSValueNone)) + if (!value || (value->isPrimitiveValue() && (toCSSPrimitiveValue(value.get()))->getValueID() == CSSValueNone)) return; TransformOperations operations; - if (!transformsForValue(*value, CSSToLengthConversionData(), operations)) { + if (!transformsForValue(0, 0, value.get(), operations)) { ec = SYNTAX_ERR; return; } @@ -89,26 +88,25 @@ void WebKitCSSMatrix::setMatrixValue(const String& string, ExceptionCode& ec) } // Perform a concatenation of the matrices (this * secondMatrix) -RefPtr<WebKitCSSMatrix> WebKitCSSMatrix::multiply(WebKitCSSMatrix* secondMatrix) const +PassRefPtr<WebKitCSSMatrix> WebKitCSSMatrix::multiply(WebKitCSSMatrix* secondMatrix) const { if (!secondMatrix) - return nullptr; + return 0; - RefPtr<WebKitCSSMatrix> matrix = WebKitCSSMatrix::create(m_matrix); - matrix->m_matrix.multiply(secondMatrix->m_matrix); - return matrix; + return WebKitCSSMatrix::create(TransformationMatrix(m_matrix).multiply(secondMatrix->m_matrix)); } -RefPtr<WebKitCSSMatrix> WebKitCSSMatrix::inverse(ExceptionCode& ec) const +PassRefPtr<WebKitCSSMatrix> WebKitCSSMatrix::inverse(ExceptionCode& ec) const { - if (auto inverse = m_matrix.inverse()) - return WebKitCSSMatrix::create(inverse.value()); - - ec = NOT_SUPPORTED_ERR; - return nullptr; + if (!m_matrix.isInvertible()) { + ec = NOT_SUPPORTED_ERR; + return 0; + } + + return WebKitCSSMatrix::create(m_matrix.inverse()); } -RefPtr<WebKitCSSMatrix> WebKitCSSMatrix::translate(double x, double y, double z) const +PassRefPtr<WebKitCSSMatrix> WebKitCSSMatrix::translate(double x, double y, double z) const { if (std::isnan(x)) x = 0; @@ -116,13 +114,10 @@ RefPtr<WebKitCSSMatrix> WebKitCSSMatrix::translate(double x, double y, double z) y = 0; if (std::isnan(z)) z = 0; - - RefPtr<WebKitCSSMatrix> matrix = WebKitCSSMatrix::create(m_matrix); - matrix->m_matrix.translate3d(x, y, z); - return matrix; + return WebKitCSSMatrix::create(TransformationMatrix(m_matrix).translate3d(x, y, z)); } -RefPtr<WebKitCSSMatrix> WebKitCSSMatrix::scale(double scaleX, double scaleY, double scaleZ) const +PassRefPtr<WebKitCSSMatrix> WebKitCSSMatrix::scale(double scaleX, double scaleY, double scaleZ) const { if (std::isnan(scaleX)) scaleX = 1; @@ -130,13 +125,10 @@ RefPtr<WebKitCSSMatrix> WebKitCSSMatrix::scale(double scaleX, double scaleY, dou scaleY = scaleX; if (std::isnan(scaleZ)) scaleZ = 1; - - RefPtr<WebKitCSSMatrix> matrix = WebKitCSSMatrix::create(m_matrix); - matrix->m_matrix.scale3d(scaleX, scaleY, scaleZ); - return matrix; + return WebKitCSSMatrix::create(TransformationMatrix(m_matrix).scale3d(scaleX, scaleY, scaleZ)); } -RefPtr<WebKitCSSMatrix> WebKitCSSMatrix::rotate(double rotX, double rotY, double rotZ) const +PassRefPtr<WebKitCSSMatrix> WebKitCSSMatrix::rotate(double rotX, double rotY, double rotZ) const { if (std::isnan(rotX)) rotX = 0; @@ -151,13 +143,10 @@ RefPtr<WebKitCSSMatrix> WebKitCSSMatrix::rotate(double rotX, double rotY, double rotY = 0; if (std::isnan(rotZ)) rotZ = 0; - - RefPtr<WebKitCSSMatrix> matrix = WebKitCSSMatrix::create(m_matrix); - matrix->m_matrix.rotate3d(rotX, rotY, rotZ); - return matrix; + return WebKitCSSMatrix::create(TransformationMatrix(m_matrix).rotate3d(rotX, rotY, rotZ)); } -RefPtr<WebKitCSSMatrix> WebKitCSSMatrix::rotateAxisAngle(double x, double y, double z, double angle) const +PassRefPtr<WebKitCSSMatrix> WebKitCSSMatrix::rotateAxisAngle(double x, double y, double z, double angle) const { if (std::isnan(x)) x = 0; @@ -169,30 +158,21 @@ RefPtr<WebKitCSSMatrix> WebKitCSSMatrix::rotateAxisAngle(double x, double y, dou angle = 0; if (x == 0 && y == 0 && z == 0) z = 1; - - RefPtr<WebKitCSSMatrix> matrix = WebKitCSSMatrix::create(m_matrix); - matrix->m_matrix.rotate3d(x, y, z, angle); - return matrix; + return WebKitCSSMatrix::create(TransformationMatrix(m_matrix).rotate3d(x, y, z, angle)); } -RefPtr<WebKitCSSMatrix> WebKitCSSMatrix::skewX(double angle) const +PassRefPtr<WebKitCSSMatrix> WebKitCSSMatrix::skewX(double angle) const { if (std::isnan(angle)) angle = 0; - - RefPtr<WebKitCSSMatrix> matrix = WebKitCSSMatrix::create(m_matrix); - matrix->m_matrix.skewX(angle); - return matrix; + return WebKitCSSMatrix::create(TransformationMatrix(m_matrix).skewX(angle)); } -RefPtr<WebKitCSSMatrix> WebKitCSSMatrix::skewY(double angle) const +PassRefPtr<WebKitCSSMatrix> WebKitCSSMatrix::skewY(double angle) const { if (std::isnan(angle)) angle = 0; - - RefPtr<WebKitCSSMatrix> matrix = WebKitCSSMatrix::create(m_matrix); - matrix->m_matrix.skewY(angle); - return matrix; + return WebKitCSSMatrix::create(TransformationMatrix(m_matrix).skewY(angle)); } String WebKitCSSMatrix::toString() const |