From d10384ac431a588da7d52129e081f4107dd92e56 Mon Sep 17 00:00:00 2001 From: James Robinson Date: Tue, 4 Aug 2015 13:06:39 -0700 Subject: [PATCH] Remove unused CSSMatrix files --- sky/engine/core/core.gni | 3 - sky/engine/core/css/CSSMatrix.cpp | 189 ------------------------------ sky/engine/core/css/CSSMatrix.h | 160 ------------------------- sky/engine/core/css/CSSMatrix.idl | 104 ---------------- 4 files changed, 456 deletions(-) delete mode 100644 sky/engine/core/css/CSSMatrix.cpp delete mode 100644 sky/engine/core/css/CSSMatrix.h delete mode 100644 sky/engine/core/css/CSSMatrix.idl diff --git a/sky/engine/core/core.gni b/sky/engine/core/core.gni index a309af4c08f..aa197315aa9 100644 --- a/sky/engine/core/core.gni +++ b/sky/engine/core/core.gni @@ -47,8 +47,6 @@ sky_core_files = [ "css/CSSLineBoxContainValue.h", "css/CSSMarkup.cpp", "css/CSSMarkup.h", - "css/CSSMatrix.cpp", - "css/CSSMatrix.h", "css/CSSOMUtils.cpp", "css/CSSOMUtils.h", "css/CSSPrimitiveValue.cpp", @@ -631,7 +629,6 @@ sky_core_files = [ core_idl_files = get_path_info([ "css/CSS.idl", - "css/CSSMatrix.idl", "css/CSSStyleDeclaration.idl", "css/MediaQueryList.idl", "css/MediaQueryListEvent.idl", diff --git a/sky/engine/core/css/CSSMatrix.cpp b/sky/engine/core/css/CSSMatrix.cpp deleted file mode 100644 index c9abd8156dd..00000000000 --- a/sky/engine/core/css/CSSMatrix.cpp +++ /dev/null @@ -1,189 +0,0 @@ -/* - * Copyright (C) 2008 Apple Inc. All Rights Reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "sky/engine/core/css/CSSMatrix.h" - -#include "gen/sky/core/CSSPropertyNames.h" -#include "gen/sky/core/CSSValueKeywords.h" -#include "sky/engine/bindings/exception_state.h" -#include "sky/engine/core/css/CSSToLengthConversionData.h" -#include "sky/engine/core/css/StylePropertySet.h" -#include "sky/engine/core/css/parser/BisonCSSParser.h" -#include "sky/engine/core/css/resolver/TransformBuilder.h" -#include "sky/engine/core/dom/ExceptionCode.h" -#include "sky/engine/core/rendering/style/RenderStyle.h" -#include "sky/engine/core/rendering/style/StyleInheritedData.h" -#include "sky/engine/wtf/MathExtras.h" - -namespace blink { - -CSSMatrix::CSSMatrix(const TransformationMatrix& m) - : m_matrix(m) -{ -} - -CSSMatrix::CSSMatrix(const String& s, ExceptionState& exceptionState) -{ - setMatrixValue(s, exceptionState); -} - -void CSSMatrix::setMatrixValue(const String& string, ExceptionState& exceptionState) -{ - if (string.isEmpty()) - return; - - // FIXME: crbug.com/154722 - should this continue to use legacy style parsing? - RefPtr styleDeclaration = MutableStylePropertySet::create(); - if (BisonCSSParser::parseValue(styleDeclaration.get(), CSSPropertyWebkitTransform, string, HTMLStandardMode, 0)) { - // Convert to TransformOperations. This can fail if a property - // requires style (i.e., param uses 'ems' or 'exs') - RefPtr 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)) - return; - - DEFINE_STATIC_REF(RenderStyle, defaultStyle, RenderStyle::createDefaultStyle()); - TransformOperations operations; - if (!TransformBuilder::createTransformOperations(value.get(), CSSToLengthConversionData(defaultStyle, 0), 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.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.ThrowDOMException(SyntaxError, "Failed to parse '" + string + "'."); - } -} - -// Perform a concatenation of the matrices (this * secondMatrix) -PassRefPtr CSSMatrix::multiply(CSSMatrix* secondMatrix) const -{ - if (!secondMatrix) - return nullptr; - - return CSSMatrix::create(TransformationMatrix(m_matrix).multiply(secondMatrix->m_matrix)); -} - -PassRefPtr 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()); -} - -PassRefPtr CSSMatrix::translate(double x, double y, double z) const -{ - 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)); -} - -PassRefPtr CSSMatrix::scale(double scaleX, double scaleY, double scaleZ) const -{ - 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)); -} - -PassRefPtr CSSMatrix::rotate(double rotX, double rotY, double rotZ) const -{ - if (std::isnan(rotX)) - rotX = 0; - - if (std::isnan(rotY) && std::isnan(rotZ)) { - rotZ = rotX; - rotX = 0; - rotY = 0; - } - - if (std::isnan(rotY)) - rotY = 0; - if (std::isnan(rotZ)) - rotZ = 0; - return CSSMatrix::create(TransformationMatrix(m_matrix).rotate3d(rotX, rotY, rotZ)); -} - -PassRefPtr CSSMatrix::rotateAxisAngle(double x, double y, double z, double angle) const -{ - if (std::isnan(x)) - x = 0; - if (std::isnan(y)) - y = 0; - if (std::isnan(z)) - z = 0; - if (std::isnan(angle)) - angle = 0; - if (!x && !y && !z) - z = 1; - return CSSMatrix::create(TransformationMatrix(m_matrix).rotate3d(x, y, z, angle)); -} - -PassRefPtr CSSMatrix::skewX(double angle) const -{ - if (std::isnan(angle)) - angle = 0; - return CSSMatrix::create(TransformationMatrix(m_matrix).skewX(angle)); -} - -PassRefPtr CSSMatrix::skewY(double angle) const -{ - if (std::isnan(angle)) - angle = 0; - return CSSMatrix::create(TransformationMatrix(m_matrix).skewY(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()); -} - -} // namespace blink diff --git a/sky/engine/core/css/CSSMatrix.h b/sky/engine/core/css/CSSMatrix.h deleted file mode 100644 index e516829b331..00000000000 --- a/sky/engine/core/css/CSSMatrix.h +++ /dev/null @@ -1,160 +0,0 @@ -/* - * Copyright (C) 2008 Apple Inc. All Rights Reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef SKY_ENGINE_CORE_CSS_CSSMATRIX_H_ -#define SKY_ENGINE_CORE_CSS_CSSMATRIX_H_ - -#include "sky/engine/tonic/dart_wrappable.h" -#include "sky/engine/platform/transforms/TransformationMatrix.h" -#include "sky/engine/wtf/RefCounted.h" -#include "sky/engine/wtf/text/WTFString.h" - -namespace blink { - -class ExceptionState; - -class CSSMatrix final : public RefCounted, public DartWrappable { - DEFINE_WRAPPERTYPEINFO(); -public: - static PassRefPtr create(const TransformationMatrix& m) - { - return adoptRef(new CSSMatrix(m)); - } - static PassRefPtr create(const String& s, ExceptionState& exceptionState) - { - return adoptRef(new CSSMatrix(s, exceptionState)); - } - - double a() const { return m_matrix.a(); } - double b() const { return m_matrix.b(); } - double c() const { return m_matrix.c(); } - double d() const { return m_matrix.d(); } - double e() const { return m_matrix.e(); } - double f() const { return m_matrix.f(); } - - void setA(double f) { m_matrix.setA(f); } - void setB(double f) { m_matrix.setB(f); } - void setC(double f) { m_matrix.setC(f); } - void setD(double f) { m_matrix.setD(f); } - void setE(double f) { m_matrix.setE(f); } - void setF(double f) { m_matrix.setF(f); } - - double m11() const { return m_matrix.m11(); } - double m12() const { return m_matrix.m12(); } - double m13() const { return m_matrix.m13(); } - double m14() const { return m_matrix.m14(); } - double m21() const { return m_matrix.m21(); } - double m22() const { return m_matrix.m22(); } - double m23() const { return m_matrix.m23(); } - double m24() const { return m_matrix.m24(); } - double m31() const { return m_matrix.m31(); } - double m32() const { return m_matrix.m32(); } - double m33() const { return m_matrix.m33(); } - double m34() const { return m_matrix.m34(); } - double m41() const { return m_matrix.m41(); } - double m42() const { return m_matrix.m42(); } - double m43() const { return m_matrix.m43(); } - double m44() const { return m_matrix.m44(); } - - void setM11(double f) { m_matrix.setM11(f); } - void setM12(double f) { m_matrix.setM12(f); } - void setM13(double f) { m_matrix.setM13(f); } - void setM14(double f) { m_matrix.setM14(f); } - void setM21(double f) { m_matrix.setM21(f); } - void setM22(double f) { m_matrix.setM22(f); } - void setM23(double f) { m_matrix.setM23(f); } - void setM24(double f) { m_matrix.setM24(f); } - void setM31(double f) { m_matrix.setM31(f); } - void setM32(double f) { m_matrix.setM32(f); } - void setM33(double f) { m_matrix.setM33(f); } - void setM34(double f) { m_matrix.setM34(f); } - void setM41(double f) { m_matrix.setM41(f); } - void setM42(double f) { m_matrix.setM42(f); } - void setM43(double f) { m_matrix.setM43(f); } - void setM44(double f) { m_matrix.setM44(f); } - - void setMatrixValue(const String&, ExceptionState&); - - // The following math function return a new matrix with the - // specified operation applied. The this value is not modified. - - // Multiply this matrix by secondMatrix, on the right (result = this * secondMatrix) - PassRefPtr multiply(CSSMatrix* secondMatrix) const; - - // Return the inverse of this matrix. Throw an exception if the matrix is not invertible - PassRefPtr inverse(ExceptionState&) const; - - // Return this matrix translated by the passed values. - // Passing a NaN will use a value of 0. This allows the 3D form to used for 2D operations - // Operation is performed as though the this matrix is multiplied by a matrix with - // the translation values on the left (result = translation(x,y,z) * this) - PassRefPtr translate(double x, double y, double z) const; - - // Returns this matrix scaled by the passed values. - // Passing scaleX or scaleZ as NaN uses a value of 1, but passing scaleY of NaN - // makes it the same as scaleX. This allows the 3D form to used for 2D operations - // Operation is performed as though the this matrix is multiplied by a matrix with - // the scale values on the left (result = scale(x,y,z) * this) - PassRefPtr scale(double scaleX, double scaleY, double scaleZ) const; - - // Returns this matrix rotated by the passed values. - // If rotY and rotZ are NaN, rotate about Z (rotX=0, rotateY=0, rotateZ=rotX). - // Otherwise use a rotation value of 0 for any passed NaN. - // Operation is performed as though the this matrix is multiplied by a matrix with - // the rotation values on the left (result = rotation(x,y,z) * this) - PassRefPtr rotate(double rotX, double rotY, double rotZ) const; - - // Returns this matrix rotated about the passed axis by the passed angle. - // Passing a NaN will use a value of 0. If the axis is (0,0,0) use a value - // Operation is performed as though the this matrix is multiplied by a matrix with - // the rotation values on the left (result = rotation(x,y,z,angle) * this) - PassRefPtr rotateAxisAngle(double x, double y, double z, double angle) const; - - // Return this matrix skewed along the X axis by the passed values. - // Passing a NaN will use a value of 0. - // Operation is performed as though the this matrix is multiplied by a matrix with - // the skew values on the left (result = skewX(angle) * this) - PassRefPtr skewX(double angle) const; - - // Return this matrix skewed along the Y axis by the passed values. - // Passing a NaN will use a value of 0. - // Operation is performed as though the this matrix is multiplied by a matrix with - // the skew values on the left (result = skewY(angle) * this) - PassRefPtr skewY(double angle) const; - - const TransformationMatrix& transform() const { return m_matrix; } - - String toString() const; - -protected: - CSSMatrix(const TransformationMatrix&); - CSSMatrix(const String&, ExceptionState&); - - TransformationMatrix m_matrix; -}; - -} // namespace blink - -#endif // SKY_ENGINE_CORE_CSS_CSSMATRIX_H_ diff --git a/sky/engine/core/css/CSSMatrix.idl b/sky/engine/core/css/CSSMatrix.idl deleted file mode 100644 index 1507a784754..00000000000 --- a/sky/engine/core/css/CSSMatrix.idl +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Copyright (C) 2008, 2010 Apple Inc. All Rights Reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -// Introduced in DOM Level ?: -[ - Constructor(optional DOMString cssValue = null), - ImplementedAs=CSSMatrix, - RaisesException=Constructor, -] interface CSSMatrix { - - // These attributes are simple aliases for certain elements of the 4x4 matrix - attribute double a; // alias for m11 - attribute double b; // alias for m12 - attribute double c; // alias for m21 - attribute double d; // alias for m22 - attribute double e; // alias for m41 - attribute double f; // alias for m42 - - attribute double m11; - attribute double m12; - attribute double m13; - attribute double m14; - attribute double m21; - attribute double m22; - attribute double m23; - attribute double m24; - attribute double m31; - attribute double m32; - attribute double m33; - attribute double m34; - attribute double m41; - attribute double m42; - attribute double m43; - attribute double m44; - - [RaisesException] void setMatrixValue([Default=Undefined] optional DOMString string); - - // Multiply this matrix by secondMatrix, on the right (result = this * secondMatrix) - [Immutable] CSSMatrix multiply([Default=Undefined] optional CSSMatrix secondMatrix); - - // Return the inverse of this matrix. Throw an exception if the matrix is not invertible - [Immutable, RaisesException] CSSMatrix inverse(); - - // Return this matrix translated by the passed values. - // Passing a NaN will use a value of 0. This allows the 3D form to used for 2D operations - [Immutable] CSSMatrix translate([Default=Undefined] optional double x, - [Default=Undefined] optional double y, - [Default=Undefined] optional double z); - - // Returns this matrix scaled by the passed values. - // Passing scaleX or scaleZ as NaN uses a value of 1, but passing scaleY of NaN - // makes it the same as scaleX. This allows the 3D form to used for 2D operations - [Immutable] CSSMatrix scale([Default=Undefined] optional double scaleX, - [Default=Undefined] optional double scaleY, - [Default=Undefined] optional double scaleZ); - - // Returns this matrix rotated by the passed values. - // If rotY and rotZ are NaN, rotate about Z (rotX=0, rotateY=0, rotateZ=rotX). - // Otherwise use a rotation value of 0 for any passed NaN. - [Immutable] CSSMatrix rotate([Default=Undefined] optional double rotX, - [Default=Undefined] optional double rotY, - [Default=Undefined] optional double rotZ); - - // Returns this matrix rotated about the passed axis by the passed angle. - // Passing a NaN will use a value of 0. If the axis is (0,0,0) use a value - // of (0,0,1). - [Immutable] CSSMatrix rotateAxisAngle([Default=Undefined] optional double x, - [Default=Undefined] optional double y, - [Default=Undefined] optional double z, - [Default=Undefined] optional double angle); - - // Returns this matrix skewed along the X axis by the passed values. - // Passing a NaN will use a value of 0. - [Immutable] CSSMatrix skewX([Default=Undefined] optional double angle); - - // Returns this matrix skewed along the Y axis by the passed values. - // Passing a NaN will use a value of 0. - [Immutable] CSSMatrix skewY([Default=Undefined] optional double angle); - - [NotEnumerable] stringifier; -}; -