2008-11-25 Chris Marrin <cmarrin@apple.com>
authorcmarrin@apple.com <cmarrin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 26 Nov 2008 01:38:17 +0000 (01:38 +0000)
committercmarrin@apple.com <cmarrin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 26 Nov 2008 01:38:17 +0000 (01:38 +0000)
        Reviewed by Dan Bernstein.

        Fix for https://bugs.webkit.org/show_bug.cgi?id=22487
        I was not checking for the case of 0 length keyframe lists and dereffing a null pointer.

        Tests: animations/empty-keyframes.html
               animations/fill-unset-properties.html

        * css/CSSStyleSelector.cpp:
        (WebCore::CSSStyleSelector::keyframeStylesForAnimation):

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

LayoutTests/ChangeLog
LayoutTests/animations/empty-keyframes-expected.txt [new file with mode: 0644]
LayoutTests/animations/empty-keyframes.html [new file with mode: 0644]
LayoutTests/animations/fill-unset-properties-expected.txt [new file with mode: 0644]
LayoutTests/animations/fill-unset-properties.html [new file with mode: 0644]
WebCore/ChangeLog
WebCore/css/CSSStyleSelector.cpp

index ee2e50c..e631227 100644 (file)
@@ -1,3 +1,14 @@
+2008-11-25  Chris Marrin  <cmarrin@apple.com>
+
+        Reviewed by Dan Bernstein.
+
+        Testcases for https://bugs.webkit.org/show_bug.cgi?id=22487
+
+        * animations/empty-keyframes-expected.txt: Added.
+        * animations/empty-keyframes.html: Added.
+        * animations/fill-unset-properties-expected.txt: Added.
+        * animations/fill-unset-properties.html: Added.
+
 2008-11-25  Simon Fraser  <simon.fraser@apple.com>
 
         Reviewed by Darin Adler
diff --git a/LayoutTests/animations/empty-keyframes-expected.txt b/LayoutTests/animations/empty-keyframes-expected.txt
new file mode 100644 (file)
index 0000000..1724171
--- /dev/null
@@ -0,0 +1,3 @@
+Test for empty keyframes rule. Should not crash
+
+
diff --git a/LayoutTests/animations/empty-keyframes.html b/LayoutTests/animations/empty-keyframes.html
new file mode 100644 (file)
index 0000000..bbe779f
--- /dev/null
@@ -0,0 +1,30 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
+   "http://www.w3.org/TR/html4/loose.dtd">
+
+<html lang="en">
+<head>
+  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+  <title>Empty keyframes</title>
+  <style type="text/css" media="screen">
+    #box {
+      -webkit-animation-name: test, test-one;
+      -webkit-animation-duration: 1s;
+    }
+    @-webkit-keyframes test {
+    }
+
+    @-webkit-keyframes test-one {
+      0% {}
+    }
+  </style>
+  <script type="text/javascript" charset="utf-8">
+    if (window.layoutTestController)
+        layoutTestController.dumpAsText();
+  </script>
+</head>
+<body>
+  <p>Test for empty keyframes rule. Should not crash</p>
+<div id="box">
+</div>
+</body>
+</html>
diff --git a/LayoutTests/animations/fill-unset-properties-expected.txt b/LayoutTests/animations/fill-unset-properties-expected.txt
new file mode 100644 (file)
index 0000000..a57c5da
--- /dev/null
@@ -0,0 +1,8 @@
+Testing webkitTransitionDuration: PASS
+Testing webkitTransitionProperty: PASS
+Testing webkitTransitionDelay: PASS
+Testing webkitTransitionTimingFunction: PASS
+Testing webkitAnimationName: PASS
+Testing webkitAnimationDuration: PASS
+Testing webkitAnimationDelay: PASS
+
diff --git a/LayoutTests/animations/fill-unset-properties.html b/LayoutTests/animations/fill-unset-properties.html
new file mode 100644 (file)
index 0000000..b47a286
--- /dev/null
@@ -0,0 +1,65 @@
+<html> 
+<head>
+<title>Unfilled Properties Test</title> 
+<style type="text/css" media="screen">
+#box {
+    height: 50px;
+    width: 200px;
+    background-color: blue;
+    -webkit-transition-duration: 1s,2s;
+    -webkit-transition-property: opacity, left, opacity, top, width, opacity, height, opacity;
+    -webkit-transition-delay: 3s,4s,5s;
+    -webkit-transition-timing-function: linear;
+    -webkit-animation-name: a, b, c, d, e;
+    -webkit-animation-duration: 10s, 20s;
+    -webkit-animation-delay: 1s;
+}
+@-webkit-keyframes a { }
+@-webkit-keyframes b { }
+@-webkit-keyframes c { }
+@-webkit-keyframes d { }
+@-webkit-keyframes e { }
+</style>
+  <script type="text/javascript" charset="utf-8">
+    if (window.layoutTestController)
+        layoutTestController.dumpAsText();
+  
+    const kExpectedResults = [
+      { 'property': 'webkitTransitionDuration', 'value': '2s, 2s, 1s, 1s, 2s' },
+      { 'property': 'webkitTransitionProperty', 'value': 'left, top, width, height, opacity' },
+      { 'property': 'webkitTransitionDelay',    'value': '4s, 3s, 4s, 3s, 4s' },
+      { 'property': 'webkitTransitionTimingFunction', 'value': 'cubic-bezier(0, 0, 1, 1), cubic-bezier(0, 0, 1, 1), cubic-bezier(0, 0, 1, 1), cubic-bezier(0, 0, 1, 1), cubic-bezier(0, 0, 1, 1)' },
+      { 'property': 'webkitAnimationName',      'value': 'a, b, c, d, e' },
+      { 'property': 'webkitAnimationDuration',  'value': '10s, 20s, 10s, 20s, 10s' },
+      { 'property': 'webkitAnimationDelay',     'value': '1s, 1s, 1s, 1s, 1s' },
+    ];
+    
+    function start()
+    {
+        var box = document.getElementById('box');
+        var resultsString = "";
+        var boxStyle = window.getComputedStyle(box);
+        
+        kExpectedResults.forEach(function(curItem) {
+          var computedValue = boxStyle[curItem.property];
+          var expectedValue = curItem.value;
+          if (computedValue == expectedValue)
+            resultsString += "Testing " + curItem.property + ": PASS" + "<br>";
+          else
+            resultsString += "Testing " + curItem.property + " expected <code>" + curItem.value + "</code> got <code>" + computedValue + "</code>: FAIL" + "<br>";
+        });
+
+        var results = document.getElementById('result');
+        results.innerHTML = resultsString;
+    }
+    
+    window.addEventListener('load', start, false);
+  </script>
+</head> 
+<body>
+<div id="box">
+</div>
+<div id="result">
+</div>
+</body>
+</html>
index d067d80..4133df4 100644 (file)
 
 2008-11-25  Chris Marrin  <cmarrin@apple.com>
 
+        Reviewed by Dan Bernstein.
+
+        Fix for https://bugs.webkit.org/show_bug.cgi?id=22487
+        I was not checking for the case of 0 length keyframe lists and dereffing a null pointer.
+
+        Tests: animations/empty-keyframes.html
+               animations/fill-unset-properties.html
+
+        * css/CSSStyleSelector.cpp:
+        (WebCore::CSSStyleSelector::keyframeStylesForAnimation):
+
+2008-11-25  Chris Marrin  <cmarrin@apple.com>
+
         Reviewed by Darin Adler
 
         https://bugs.webkit.org/show_bug.cgi?id=22046
index 555d0f3..0af0f19 100644 (file)
@@ -1266,8 +1266,12 @@ void CSSStyleSelector::keyframeStylesForAnimation(Element* e, const RenderStyle*
     }
     
     // Make sure there is a 0% and a 100% keyframe
-    float first = list.beginKeyframes()->key();
-    float last = (list.endKeyframes()-1)->key();
+    float first = -1;
+    float last = -1;
+    if (list.size() >= 2) {
+        first = list.beginKeyframes()->key();
+        last = (list.endKeyframes()-1)->key();
+    }
     if (first != 0 || last != 1)
         list.clear();
 }