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