diff options
Diffstat (limited to 'chromium/third_party/WebKit/Source/core/css/CSSMatrix.cpp')
-rw-r--r-- | chromium/third_party/WebKit/Source/core/css/CSSMatrix.cpp | 43 |
1 files changed, 22 insertions, 21 deletions
diff --git a/chromium/third_party/WebKit/Source/core/css/CSSMatrix.cpp b/chromium/third_party/WebKit/Source/core/css/CSSMatrix.cpp index 4926df97629..dc974c1a003 100644 --- a/chromium/third_party/WebKit/Source/core/css/CSSMatrix.cpp +++ b/chromium/third_party/WebKit/Source/core/css/CSSMatrix.cpp @@ -26,10 +26,10 @@ #include "config.h" #include "core/css/CSSMatrix.h" -#include "CSSPropertyNames.h" -#include "CSSValueKeywords.h" #include "bindings/v8/ExceptionState.h" -#include "core/css/CSSParser.h" +#include "core/CSSPropertyNames.h" +#include "core/CSSValueKeywords.h" +#include "core/css/parser/BisonCSSParser.h" #include "core/css/CSSToLengthConversionData.h" #include "core/css/StylePropertySet.h" #include "core/css/resolver/TransformBuilder.h" @@ -57,11 +57,12 @@ void CSSMatrix::setMatrixValue(const String& string, ExceptionState& exceptionSt if (string.isEmpty()) return; - RefPtr<MutableStylePropertySet> styleDeclaration = MutableStylePropertySet::create(); - if (CSSParser::parseValue(styleDeclaration.get(), CSSPropertyWebkitTransform, string, true, HTMLStandardMode, 0)) { + // FIXME: crbug.com/154722 - should this continue to use legacy style parsing? + RefPtrWillBeRawPtr<MutableStylePropertySet> styleDeclaration = MutableStylePropertySet::create(); + if (BisonCSSParser::parseValue(styleDeclaration.get(), CSSPropertyWebkitTransform, string, true, HTMLStandardMode, 0)) { // Convert to TransformOperations. This can fail if a property // requires style (i.e., param uses 'ems' or 'exs') - RefPtr<CSSValue> value = styleDeclaration->getPropertyCSSValue(CSSPropertyWebkitTransform); + RefPtrWillBeRawPtr<CSSValue> value = styleDeclaration->getPropertyCSSValue(CSSPropertyWebkitTransform); // 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)) @@ -69,45 +70,45 @@ void CSSMatrix::setMatrixValue(const String& string, ExceptionState& exceptionSt DEFINE_STATIC_REF(RenderStyle, defaultStyle, RenderStyle::createDefaultStyle()); TransformOperations operations; - if (!TransformBuilder::createTransformOperations(value.get(), CSSToLengthConversionData(defaultStyle, defaultStyle), operations)) { - exceptionState.throwUninformativeAndGenericDOMException(SyntaxError); + if (!TransformBuilder::createTransformOperations(value.get(), CSSToLengthConversionData(defaultStyle, defaultStyle, 0, 0, 1.0f), operations)) { + exceptionState.throwDOMException(SyntaxError, "Failed to interpret '" + string + "' as a transformation operation."); return; } // Convert transform operations to a TransformationMatrix. This can fail // if a param has a percentage ('%') if (operations.dependsOnBoxSize()) - exceptionState.throwUninformativeAndGenericDOMException(SyntaxError); + exceptionState.throwDOMException(SyntaxError, "The transformation depends on the box size, which is not supported."); TransformationMatrix t; operations.apply(FloatSize(0, 0), t); // set the matrix m_matrix = t; } else { // There is something there but parsing failed. - exceptionState.throwUninformativeAndGenericDOMException(SyntaxError); + exceptionState.throwDOMException(SyntaxError, "Failed to parse '" + string + "'."); } } // Perform a concatenation of the matrices (this * secondMatrix) -PassRefPtr<CSSMatrix> CSSMatrix::multiply(CSSMatrix* secondMatrix) const +PassRefPtrWillBeRawPtr<CSSMatrix> CSSMatrix::multiply(CSSMatrix* secondMatrix) const { if (!secondMatrix) - return 0; + return nullptr; return CSSMatrix::create(TransformationMatrix(m_matrix).multiply(secondMatrix->m_matrix)); } -PassRefPtr<CSSMatrix> CSSMatrix::inverse(ExceptionState& exceptionState) const +PassRefPtrWillBeRawPtr<CSSMatrix> CSSMatrix::inverse(ExceptionState& exceptionState) const { if (!m_matrix.isInvertible()) { - exceptionState.throwUninformativeAndGenericDOMException(NotSupportedError); - return 0; + exceptionState.throwDOMException(NotSupportedError, "The matrix is not invertable."); + return nullptr; } return CSSMatrix::create(m_matrix.inverse()); } -PassRefPtr<CSSMatrix> CSSMatrix::translate(double x, double y, double z) const +PassRefPtrWillBeRawPtr<CSSMatrix> CSSMatrix::translate(double x, double y, double z) const { if (std::isnan(x)) x = 0; @@ -118,7 +119,7 @@ PassRefPtr<CSSMatrix> CSSMatrix::translate(double x, double y, double z) const return CSSMatrix::create(TransformationMatrix(m_matrix).translate3d(x, y, z)); } -PassRefPtr<CSSMatrix> CSSMatrix::scale(double scaleX, double scaleY, double scaleZ) const +PassRefPtrWillBeRawPtr<CSSMatrix> CSSMatrix::scale(double scaleX, double scaleY, double scaleZ) const { if (std::isnan(scaleX)) scaleX = 1; @@ -129,7 +130,7 @@ PassRefPtr<CSSMatrix> CSSMatrix::scale(double scaleX, double scaleY, double scal return CSSMatrix::create(TransformationMatrix(m_matrix).scale3d(scaleX, scaleY, scaleZ)); } -PassRefPtr<CSSMatrix> CSSMatrix::rotate(double rotX, double rotY, double rotZ) const +PassRefPtrWillBeRawPtr<CSSMatrix> CSSMatrix::rotate(double rotX, double rotY, double rotZ) const { if (std::isnan(rotX)) rotX = 0; @@ -147,7 +148,7 @@ PassRefPtr<CSSMatrix> CSSMatrix::rotate(double rotX, double rotY, double rotZ) c return CSSMatrix::create(TransformationMatrix(m_matrix).rotate3d(rotX, rotY, rotZ)); } -PassRefPtr<CSSMatrix> CSSMatrix::rotateAxisAngle(double x, double y, double z, double angle) const +PassRefPtrWillBeRawPtr<CSSMatrix> CSSMatrix::rotateAxisAngle(double x, double y, double z, double angle) const { if (std::isnan(x)) x = 0; @@ -162,14 +163,14 @@ PassRefPtr<CSSMatrix> CSSMatrix::rotateAxisAngle(double x, double y, double z, d return CSSMatrix::create(TransformationMatrix(m_matrix).rotate3d(x, y, z, angle)); } -PassRefPtr<CSSMatrix> CSSMatrix::skewX(double angle) const +PassRefPtrWillBeRawPtr<CSSMatrix> CSSMatrix::skewX(double angle) const { if (std::isnan(angle)) angle = 0; return CSSMatrix::create(TransformationMatrix(m_matrix).skewX(angle)); } -PassRefPtr<CSSMatrix> CSSMatrix::skewY(double angle) const +PassRefPtrWillBeRawPtr<CSSMatrix> CSSMatrix::skewY(double angle) const { if (std::isnan(angle)) angle = 0; |