WebCore:
authormitz@apple.com <mitz@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 23 Nov 2007 04:11:09 +0000 (04:11 +0000)
committermitz@apple.com <mitz@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 23 Nov 2007 04:11:09 +0000 (04:11 +0000)
        Reviewed by Maciej Stachowiak.

        - fix http://bugs.webkit.org/show_bug.cgi?id=15943
          -webkit-transform matrix does not work

        Test: fast/transforms/matrix-01.html

        Parse all six matrix entries as numbers.

        * css/CSSParser.cpp:
        (WebCore::TransformOperationInfo::TransformOperationInfo):
        (WebCore::CSSParser::parseTransform):
        * css/CSSStyleSelector.cpp:
        (WebCore::CSSStyleSelector::applyProperty):
        * rendering/RenderStyle.cpp:
        (WebCore::MatrixTransformOperation::blend):
        * rendering/RenderStyle.h:
        (WebCore::MatrixTransformOperation::MatrixTransformOperation):
        (WebCore::MatrixTransformOperation::apply):

LayoutTests:

        Reviewed by Maciej Stachowiak.

        - pixel test for http://bugs.webkit.org/show_bug.cgi?id=15943
          -webkit-transform matrix does not work

        * fast/transforms/matrix-01.html: Added.
        * platform/mac/fast/transforms/matrix-01-expected.checksum: Added.
        * platform/mac/fast/transforms/matrix-01-expected.png: Added.
        * platform/mac/fast/transforms/matrix-01-expected.txt: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@27978 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/fast/transforms/matrix-01.html [new file with mode: 0644]
LayoutTests/platform/mac/fast/transforms/matrix-01-expected.checksum [new file with mode: 0644]
LayoutTests/platform/mac/fast/transforms/matrix-01-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/fast/transforms/matrix-01-expected.txt [new file with mode: 0644]
WebCore/ChangeLog
WebCore/css/CSSParser.cpp
WebCore/css/CSSStyleSelector.cpp
WebCore/rendering/RenderStyle.cpp
WebCore/rendering/RenderStyle.h

index d49ae17b5e699f2279ae4f7da51fb50d1f3dd970..1e5d6bb440a913297ac0359ebe047527364dae69 100644 (file)
@@ -1,3 +1,15 @@
+2007-11-22  Dan Bernstein  <mitz@apple.com>
+
+        Reviewed by Maciej Stachowiak.
+
+        - pixel test for http://bugs.webkit.org/show_bug.cgi?id=15943
+          -webkit-transform matrix does not work
+
+        * fast/transforms/matrix-01.html: Added.
+        * platform/mac/fast/transforms/matrix-01-expected.checksum: Added.
+        * platform/mac/fast/transforms/matrix-01-expected.png: Added.
+        * platform/mac/fast/transforms/matrix-01-expected.txt: Added.
+
 2007-11-22  Julien Chaffraix  <julien.chaffraix@gmail.com>
 
         Reviewed by Alexey.
diff --git a/LayoutTests/fast/transforms/matrix-01.html b/LayoutTests/fast/transforms/matrix-01.html
new file mode 100644 (file)
index 0000000..95a5fa3
--- /dev/null
@@ -0,0 +1,15 @@
+<head>
+<style>
+        div {
+            width: 100px;
+            height: 100px;
+            -webkit-transform-origin: 0 0;
+            background-color: skyblue;
+            border: 5px solid black;
+        }
+        .matrix { -webkit-transform: rotate(-30deg) matrix(.866, .5, -.5, .866, 0, 0); }
+</style>
+</head>
+<body>
+    <div class="matrix"></div>
+</body>
diff --git a/LayoutTests/platform/mac/fast/transforms/matrix-01-expected.checksum b/LayoutTests/platform/mac/fast/transforms/matrix-01-expected.checksum
new file mode 100644 (file)
index 0000000..4c24865
--- /dev/null
@@ -0,0 +1 @@
+98c0236866e23a68f0cee5440380d146
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/fast/transforms/matrix-01-expected.png b/LayoutTests/platform/mac/fast/transforms/matrix-01-expected.png
new file mode 100644 (file)
index 0000000..a60c44b
Binary files /dev/null and b/LayoutTests/platform/mac/fast/transforms/matrix-01-expected.png differ
diff --git a/LayoutTests/platform/mac/fast/transforms/matrix-01-expected.txt b/LayoutTests/platform/mac/fast/transforms/matrix-01-expected.txt
new file mode 100644 (file)
index 0000000..b5ae485
--- /dev/null
@@ -0,0 +1,7 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+  RenderBlock {HTML} at (0,0) size 800x600
+    RenderBody {BODY} at (8,8) size 784x584
+layer at (8,8) size 110x110
+  RenderBlock {DIV} at (0,0) size 110x110 [bgcolor=#87CEEB] [border: (5px solid #000000)]
index 033502b7026857f4d532ae899a98d2869c0e6a2a..cd224a737675eb0a07319fb1a5d1f1fb5dd4f468 100644 (file)
@@ -1,3 +1,25 @@
+2007-11-22  Dan Bernstein  <mitz@apple.com>
+
+        Reviewed by Maciej Stachowiak.
+
+        - fix http://bugs.webkit.org/show_bug.cgi?id=15943
+          -webkit-transform matrix does not work
+
+        Test: fast/transforms/matrix-01.html
+
+        Parse all six matrix entries as numbers.
+
+        * css/CSSParser.cpp:
+        (WebCore::TransformOperationInfo::TransformOperationInfo):
+        (WebCore::CSSParser::parseTransform):
+        * css/CSSStyleSelector.cpp:
+        (WebCore::CSSStyleSelector::applyProperty):
+        * rendering/RenderStyle.cpp:
+        (WebCore::MatrixTransformOperation::blend):
+        * rendering/RenderStyle.h:
+        (WebCore::MatrixTransformOperation::MatrixTransformOperation):
+        (WebCore::MatrixTransformOperation::apply):
+
 2007-11-22  Laszlo Gombos  <laszlo.gombos@gmail.com>
 
         Reviewed by Alp Toker.
index 4adf3f523f3aba95c020b3580175cd11a4ad04cd..6660a2743e5c46d8b2941bb9070fe8689bd135d7 100644 (file)
@@ -3325,7 +3325,7 @@ public:
         } else if (fname == "matrix(") {
             m_type = CSSTransformValue::MatrixTransformOperation;
             m_argCount = 11;
-            m_unit = CSSParser::FLength;
+            m_unit = CSSParser::FNumber;
         }
         
         if (fname == "scale(" || fname == "skew(" || fname == "translate(") {
@@ -3382,18 +3382,9 @@ PassRefPtr<CSSValue> CSSParser::parseTransform()
         Value* a = args->current();
         unsigned argNumber = 0;
         while (a) {
-            bool strictParsing = true;
             CSSParser::Units unit = info.unit();
-            if (info.type() == CSSTransformValue::MatrixTransformOperation) {
-                // We use lax parsing for matrix(), since we want to allow raw numbers to be converted to fixed lengths.
-                strictParsing = false;
-                
-                // Allow percents in the last two spots of matrix().
-                if (argNumber >= 4)
-                    unit = (unit | CSSParser::FPercent);
-            }
 
-            if (!validUnit(a, unit, strictParsing))
+            if (!validUnit(a, unit, true))
                 return 0;
             
             // Add the value to the current transform operation.
index 186714586ff4259eb1cf49eef3a2cb6e937af8c3..67239161346e6be942f0a6dcd1e1776706db930d 100644 (file)
@@ -3977,13 +3977,12 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value)
                         CSSPrimitiveValue* fourthValue = static_cast<CSSPrimitiveValue*>(values->item(3));
                         CSSPrimitiveValue* fifthValue = static_cast<CSSPrimitiveValue*>(values->item(4));
                         CSSPrimitiveValue* sixthValue = static_cast<CSSPrimitiveValue*>(values->item(5));
-                        bool ok;
-                        MatrixTransformOperation* matrix = new MatrixTransformOperation(convertToLength(firstValue, style, &ok),
-                                                                                        convertToLength(secondValue, style, &ok),
-                                                                                        convertToLength(thirdValue, style, &ok),
-                                                                                        convertToLength(fourthValue, style, &ok),
-                                                                                        convertToLength(fifthValue, style, &ok),
-                                                                                        convertToLength(sixthValue, style, &ok));
+                        MatrixTransformOperation* matrix = new MatrixTransformOperation(firstValue->getDoubleValue(),
+                                                                                        secondValue->getDoubleValue(),
+                                                                                        thirdValue->getDoubleValue(),
+                                                                                        fourthValue->getDoubleValue(),
+                                                                                        fifthValue->getDoubleValue(),
+                                                                                        sixthValue->getDoubleValue());
                         operations.append(matrix);
                         break;
                     }   
index a52dc481b542a877bcf905764924c8db3ac9362e..7a3b85fe5779a8312be8ca1a93740c1868b502f2 100644 (file)
@@ -513,27 +513,27 @@ TransformOperation* MatrixTransformOperation::blend(const TransformOperation* fr
         return this;
     
     if (blendToIdentity)
-        return new MatrixTransformOperation(Length(1, m_a.type()).blend(m_a, progress),
-                                            Length(0, m_b.type()).blend(m_b, progress),
-                                            Length(0, m_c.type()).blend(m_c, progress),
-                                            Length(1, m_d.type()).blend(m_d, progress),
-                                            Length(0, m_e.type()).blend(m_e, progress),
-                                            Length(0, m_f.type()).blend(m_f, progress));
+        return new MatrixTransformOperation(m_a * (1. - progress) + progress,
+                                            m_b * (1. - progress),
+                                            m_c * (1. - progress),
+                                            m_d * (1. - progress) + progress,
+                                            m_e * (1. - progress),
+                                            m_f * (1. - progress));
 
     const MatrixTransformOperation* fromOp = static_cast<const MatrixTransformOperation*>(from);
-    Length fromA = fromOp ? fromOp->m_a : Length(1, m_a.type());
-    Length fromB = fromOp ? fromOp->m_b : Length(0, m_b.type());
-    Length fromC = fromOp ? fromOp->m_c : Length(0, m_c.type());
-    Length fromD = fromOp ? fromOp->m_d : Length(1, m_d.type());
-    Length fromE = fromOp ? fromOp->m_e : Length(0, m_e.type());
-    Length fromF = fromOp ? fromOp->m_f : Length(0, m_f.type());
+    double fromA = fromOp ? fromOp->m_a : 1.;
+    double fromB = fromOp ? fromOp->m_b : 0;
+    double fromC = fromOp ? fromOp->m_c : 0;
+    double fromD = fromOp ? fromOp->m_d : 1.;
+    double fromE = fromOp ? fromOp->m_e : 0;
+    double fromF = fromOp ? fromOp->m_f : 0;
     
-    return new MatrixTransformOperation(m_a.blend(fromA, progress),
-                                        m_b.blend(fromB, progress),
-                                        m_c.blend(fromC, progress),
-                                        m_d.blend(fromD, progress),
-                                        m_e.blend(fromE, progress),
-                                        m_f.blend(fromF, progress));
+    return new MatrixTransformOperation(fromA + (m_a - fromA) * progress,
+                                        fromB + (m_b - fromB) * progress,
+                                        fromC + (m_c - fromC) * progress,
+                                        fromD + (m_d - fromD) * progress,
+                                        fromE + (m_e - fromE) * progress,
+                                        fromF + (m_f - fromF) * progress);
 }
 
 Transition::Transition()
index b729421d0a4a83b37f44ae86b4a8511007d46f4e..a1bd5cc75a4e5a6a2d46b45da0c00741b35f79be 100644 (file)
@@ -769,7 +769,7 @@ private:
 class MatrixTransformOperation : public TransformOperation
 {
 public:
-    MatrixTransformOperation(const Length& a, const Length& b, const Length& c, const Length& d, const Length& e, const Length& f)
+    MatrixTransformOperation(double a, double b, double c, double d, double e, double f)
     : m_a(a), m_b(b), m_c(c), m_d(d), m_e(e), m_f(f)
     {}
     
@@ -786,19 +786,19 @@ public:
 
     virtual void apply(AffineTransform& transform, const IntSize& borderBoxSize)
     {
-        AffineTransform matrix(m_a.value(), m_b.value(), m_c.value(), m_d.value(), m_e.calcValue(borderBoxSize.width()), m_f.calcValue(borderBoxSize.height()));
+        AffineTransform matrix(m_a, m_b, m_c, m_d, m_e, m_f);
         transform.multiply(matrix);
     }
 
     virtual TransformOperation* blend(const TransformOperation* from, double progress, bool blendToIdentity = false);
     
 private:
-    Length m_a;
-    Length m_b;
-    Length m_c;
-    Length m_d;
-    Length m_e;
-    Length m_f;
+    double m_a;
+    double m_b;
+    double m_c;
+    double m_d;
+    double m_e;
+    double m_f;
 };
 
 class TransformOperations