1 /* 2 * Copyright (C) 2000 Lars Knoll (knoll@kde.org) 3 * (C) 2000 Antti Koivisto (koivisto@kde.org) 4 * (C) 2000 Dirk Mueller (mueller@kde.org) 5 * Copyright (C) 2003, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. 6 * Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com) 7 * 8 * This library is free software; you can redistribute it and/or 9 * modify it under the terms of the GNU Library General Public 10 * License as published by the Free Software Foundation; either 11 * version 2 of the License, or (at your option) any later version. 12 * 13 * This library is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 * Library General Public License for more details. 17 * 18 * You should have received a copy of the GNU Library General Public License 19 * along with this library; see the file COPYING.LIB. If not, write to 20 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 21 * Boston, MA 02110-1301, USA. 22 * 23 */ 24 25 #ifndef THIRD_PARTY_BLINK_RENDERER_PLATFORM_TRANSFORMS_TRANSFORM_OPERATION_H_ 26 #define THIRD_PARTY_BLINK_RENDERER_PLATFORM_TRANSFORMS_TRANSFORM_OPERATION_H_ 27 28 #include "base/macros.h" 29 #include "base/memory/scoped_refptr.h" 30 #include "third_party/blink/renderer/platform/geometry/float_size.h" 31 #include "third_party/blink/renderer/platform/transforms/transformation_matrix.h" 32 #include "third_party/blink/renderer/platform/wtf/ref_counted.h" 33 34 namespace blink { 35 36 // CSS Transforms (may become part of CSS3) 37 38 class PLATFORM_EXPORT TransformOperation 39 : public RefCounted<TransformOperation> { 40 public: 41 enum OperationType { 42 kScaleX, 43 kScaleY, 44 kScale, 45 kTranslateX, 46 kTranslateY, 47 kTranslate, 48 kRotate, 49 kRotateZ = kRotate, 50 kSkewX, 51 kSkewY, 52 kSkew, 53 kMatrix, 54 kScaleZ, 55 kScale3D, 56 kTranslateZ, 57 kTranslate3D, 58 kRotateX, 59 kRotateY, 60 kRotate3D, 61 kMatrix3D, 62 kPerspective, 63 kInterpolated, 64 kIdentity, 65 kRotateAroundOrigin, 66 }; 67 68 TransformOperation() = default; 69 virtual ~TransformOperation() = default; 70 71 virtual bool operator==(const TransformOperation&) const = 0; 72 bool operator!=(const TransformOperation& o) const { return !(*this == o); } 73 74 virtual void Apply(TransformationMatrix&, 75 const FloatSize& border_box_size) const = 0; 76 77 // Implements the accumulative behavior described in 78 // https://drafts.csswg.org/css-transforms-2/#combining-transform-lists 79 virtual scoped_refptr<TransformOperation> Accumulate( 80 const TransformOperation& other) = 0; 81 82 virtual scoped_refptr<TransformOperation> Blend( 83 const TransformOperation* from, 84 double progress, 85 bool blend_to_identity = false) = 0; 86 virtual scoped_refptr<TransformOperation> Zoom(double factor) = 0; 87 88 virtual OperationType GetType() const = 0; 89 90 // https://drafts.csswg.org/css-transforms/#transform-primitives PrimitiveType()91 virtual OperationType PrimitiveType() const { return GetType(); } 92 IsSameType(const TransformOperation & other)93 bool IsSameType(const TransformOperation& other) const { 94 return other.GetType() == GetType(); 95 } 96 virtual bool CanBlendWith(const TransformOperation& other) const = 0; 97 PreservesAxisAlignment()98 virtual bool PreservesAxisAlignment() const { return false; } 99 Is3DOperation()100 bool Is3DOperation() const { 101 OperationType op_type = GetType(); 102 return op_type == kScaleZ || op_type == kScale3D || 103 op_type == kTranslateZ || op_type == kTranslate3D || 104 op_type == kRotateX || op_type == kRotateY || op_type == kRotate3D || 105 op_type == kMatrix3D || op_type == kPerspective || 106 op_type == kInterpolated; 107 } 108 HasNonTrivial3DComponent()109 virtual bool HasNonTrivial3DComponent() const { return Is3DOperation(); } 110 DependsOnBoxSize()111 virtual bool DependsOnBoxSize() const { return false; } 112 113 private: 114 DISALLOW_COPY_AND_ASSIGN(TransformOperation); 115 }; 116 117 } // namespace blink 118 119 #endif // THIRD_PARTY_BLINK_RENDERER_PLATFORM_TRANSFORMS_TRANSFORM_OPERATION_H_ 120