Changeset 76568 in webkit
- Timestamp:
- Jan 24, 2011 9:15:56 PM (13 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r76567 r76568 1 2011-01-24 Simon Fraser <simon.fraser@apple.com> 2 3 Reviewed by Chris Marrin. 4 5 perspective() transform function should take lengths 6 https://bugs.webkit.org/show_bug.cgi?id=52683 7 8 Add tests for perspective() handling, and interpolation for animation. 9 10 * animations/3d/transform-perspective-expected.txt: Added. 11 * animations/3d/transform-perspective.html: Added. 12 * transforms/3d/general/3dtransform-values-expected.txt: 13 * transforms/3d/general/3dtransform-values.html: 14 1 15 2011-01-24 Kent Tamura <tkent@chromium.org> 2 16 -
trunk/LayoutTests/transforms/3d/general/3dtransform-values-expected.txt
r74156 r76568 10 10 transform "rotate3d(0, 1, 0, 180px)" expected "none" : PASS 11 11 transform "rotate3d(0, 1, 0, 180px)" expected "none" : PASS 12 transform "perspective(400)" expected "matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, -0.0025, 0, 0, 0, 1)" : PASS 13 transform "perspective(400px)" expected "matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, -0.0025, 0, 0, 0, 1)" : PASS 14 transform "perspective(400em)" expected "matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, -0.00015625, 0, 0, 0, 1)" : PASS 15 transform "perspective(50%)" expected "none" : PASS 16 transform "perspective(-400)" expected "none" : PASS 17 transform "perspective(0)" expected "matrix(1, 0, 0, 1, 0, 0)" : PASS 18 transform "perspective(400deg)" expected "none" : PASS 19 transform "perspective(banana)" expected "none" : PASS 12 20 -
trunk/LayoutTests/transforms/3d/general/3dtransform-values.html
r74156 r76568 38 38 { 'transform' : 'rotate3d(0, 1, 0, 180px)', 'result' : 'none' }, // last value must be an angle 39 39 { 'transform' : 'rotate3d(0, 1, 0, 180px)', 'result' : 'none' }, // last value must be an angle 40 { 'transform' : 'perspective(400)', 'result' : 'matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, -0.0025, 0, 0, 0, 1)' }, // legacy 41 { 'transform' : 'perspective(400px)', 'result' : 'matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, -0.0025, 0, 0, 0, 1)' }, 42 { 'transform' : 'perspective(400em)', 'result' : 'matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, -0.00015625, 0, 0, 0, 1)' }, 43 { 'transform' : 'perspective(50%)', 'result' : 'none' }, 44 { 'transform' : 'perspective(-400)', 'result' : 'none' }, 45 { 'transform' : 'perspective(0)', 'result' : 'matrix(1, 0, 0, 1, 0, 0)' }, 46 { 'transform' : 'perspective(400deg)', 'result' : 'none' }, // unit must be length 47 { 'transform' : 'perspective(banana)', 'result' : 'none' }, // unit must be length 40 48 ]; 41 49 -
trunk/Source/WebCore/ChangeLog
r76567 r76568 1 2011-01-24 Simon Fraser <simon.fraser@apple.com> 2 3 Reviewed by Chris Marrin. 4 5 perspective() transform function should take lengths 6 https://bugs.webkit.org/show_bug.cgi?id=52683 7 8 The argument to the perspective() transform function should 9 be a Length, rather than a bare number. Bare numbers are still 10 accepted (and treated as px), but this behavior is deprecated. 11 12 Test: animations/3d/transform-perspective.html 13 transforms/3d/general/3dtransform-values.html 14 15 * css/CSSParser.cpp: 16 (WebCore::CSSParser::parseTransform): Check the units for the perspective() 17 function. Allow bare numbers for backwards compatibility. 18 * css/CSSStyleSelector.cpp: 19 (WebCore::CSSStyleSelector::createTransformOperations): Convert 20 value to Length. 21 * platform/graphics/transforms/PerspectiveTransformOperation.cpp: 22 (WebCore::clampToPostiveInteger): Helper. 23 (WebCore::PerspectiveTransformOperation::blend): Blend via Lengths. 24 * platform/graphics/transforms/PerspectiveTransformOperation.h: 25 (WebCore::PerspectiveTransformOperation::create): double -> Length. 26 (WebCore::PerspectiveTransformOperation::perspective): Ditto. 27 (WebCore::PerspectiveTransformOperation::isIdentity): Ditto. 28 (WebCore::PerspectiveTransformOperation::apply): Ditto. 29 (WebCore::PerspectiveTransformOperation::PerspectiveTransformOperation): Assert 30 that the Length is a fixed type. 31 1 32 2011-01-24 Kent Tamura <tkent@chromium.org> 2 33 -
trunk/Source/WebCore/css/CSSParser.cpp
r76047 r76568 5317 5317 if (!validUnit(a, FLength, true)) 5318 5318 return 0; 5319 } else if (info.type() == WebKitCSSTransformValue::PerspectiveTransformOperation && argNumber == 0) { 5320 // 1st param of perspective() must be a non-negative number (deprecated) or length. 5321 if (!validUnit(a, FNumber | FLength | FNonNeg, true)) 5322 return 0; 5319 5323 } else if (!validUnit(a, unit, true)) 5320 5324 return 0; -
trunk/Source/WebCore/css/CSSStyleSelector.cpp
r76378 r76568 7053 7053 } 7054 7054 case WebKitCSSTransformValue::PerspectiveTransformOperation: { 7055 double p = firstValue->getDoubleValue(); 7056 if (p < 0.0) 7055 bool ok = true; 7056 Length p = Length(0, Fixed); 7057 if (CSSPrimitiveValue::isUnitTypeLength(firstValue->primitiveType())) 7058 p = convertToLength(firstValue, style, rootStyle, zoomFactor, &ok); 7059 else { 7060 // This is a quirk that should go away when 3d transforms are finalized. 7061 double val = firstValue->getDoubleValue(); 7062 ok = val >= 0; 7063 val = min<double>(val, numeric_limits<int>::max()); 7064 p = Length(static_cast<int>(val), Fixed); 7065 } 7066 7067 if (!ok) 7057 7068 return false; 7069 7058 7070 operations.operations().append(PerspectiveTransformOperation::create(p)); 7059 7071 break; -
trunk/Source/WebCore/platform/graphics/transforms/PerspectiveTransformOperation.cpp
r41983 r76568 28 28 29 29 #include <algorithm> 30 #include <limits> 30 31 31 32 using namespace std; 32 33 33 34 namespace WebCore { 35 36 static int clampToPostiveInteger(double val) 37 { 38 return static_cast<int>(max<double>(min<double>(val, numeric_limits<int>::max()), 0)); 39 } 34 40 35 41 PassRefPtr<TransformOperation> PerspectiveTransformOperation::blend(const TransformOperation* from, double progress, bool blendToIdentity) … … 38 44 return this; 39 45 40 if (blendToIdentity) 41 return PerspectiveTransformOperation::create(m_p + (1. - m_p) * progress); 46 if (blendToIdentity) { 47 double p = m_p.calcFloatValue(1); 48 p = p + (1. - p) * progress; // FIXME: this seems wrong. https://bugs.webkit.org/show_bug.cgi?id=52700 49 return PerspectiveTransformOperation::create(Length(clampToPostiveInteger(p), Fixed)); 50 } 42 51 43 52 const PerspectiveTransformOperation* fromOp = static_cast<const PerspectiveTransformOperation*>(from); 44 double fromP = fromOp ? fromOp->m_p : 0;45 doubletoP = m_p;53 Length fromP = fromOp ? fromOp->m_p : Length(m_p.type()); 54 Length toP = m_p; 46 55 47 56 TransformationMatrix fromT; 48 57 TransformationMatrix toT; 49 fromT.applyPerspective(fromP );50 toT.applyPerspective(toP );58 fromT.applyPerspective(fromP.calcFloatValue(1)); 59 toT.applyPerspective(toP.calcFloatValue(1)); 51 60 toT.blend(fromT, progress); 52 61 TransformationMatrix::DecomposedType decomp; 53 62 toT.decompose(decomp); 54 55 return PerspectiveTransformOperation::create(decomp.perspectiveZ ? -1.0 / decomp.perspectiveZ : 0.0); 63 64 if (decomp.perspectiveZ) { 65 double val = -1.0 / decomp.perspectiveZ; 66 return PerspectiveTransformOperation::create(Length(clampToPostiveInteger(val), Fixed)); 67 } 68 return PerspectiveTransformOperation::create(Length(0, Fixed)); 56 69 } 57 70 -
trunk/Source/WebCore/platform/graphics/transforms/PerspectiveTransformOperation.h
r69884 r76568 27 27 #define PerspectiveTransformOperation_h 28 28 29 #include "Length.h" 29 30 #include "TransformOperation.h" 30 31 … … 33 34 class PerspectiveTransformOperation : public TransformOperation { 34 35 public: 35 static PassRefPtr<PerspectiveTransformOperation> create( doublep)36 static PassRefPtr<PerspectiveTransformOperation> create(const Length& p) 36 37 { 37 38 return adoptRef(new PerspectiveTransformOperation(p)); 38 39 } 39 40 40 doubleperspective() const { return m_p; }41 Length perspective() const { return m_p; } 41 42 42 43 private: 43 virtual bool isIdentity() const { return m_p == 0; }44 virtual bool isIdentity() const { return m_p.calcFloatValue(1) == 0; } 44 45 virtual OperationType getOperationType() const { return PERSPECTIVE; } 45 46 virtual bool isSameType(const TransformOperation& o) const { return o.getOperationType() == PERSPECTIVE; } … … 55 56 virtual bool apply(TransformationMatrix& transform, const IntSize&) const 56 57 { 57 transform.applyPerspective(m_p );58 transform.applyPerspective(m_p.calcFloatValue(1)); 58 59 return false; 59 60 } … … 61 62 virtual PassRefPtr<TransformOperation> blend(const TransformOperation* from, double progress, bool blendToIdentity = false); 62 63 63 PerspectiveTransformOperation( doublep)64 PerspectiveTransformOperation(const Length& p) 64 65 : m_p(p) 65 66 { 67 ASSERT(p.isFixed()); 66 68 } 67 69 68 doublem_p;70 Length m_p; 69 71 }; 70 72
Note: See TracChangeset
for help on using the changeset viewer.