Title: [88390] trunk
Revision
88390
Author
[email protected]
Date
2011-06-08 14:39:41 -0700 (Wed, 08 Jun 2011)

Log Message

2011-06-08  Mike Reed  <[email protected]>

        Reviewed by James Robinson.

        [Skia] check for null-shader from gradient factory
        https://bugs.webkit.org/show_bug.cgi?id=62319

        * platform/chromium-linux/fast/gradients/crash-on-degenerate-gradient-expected.txt: Added.
2011-06-08  Mike Reed  <[email protected]>

        Reviewed by James Robinson.

        [Skia] check for null-shader from gradient factory
        https://bugs.webkit.org/show_bug.cgi?id=62319

        * platform/graphics/skia/GradientSkia.cpp:
        (WebCore::Gradient::platformDestroy):
        (WebCore::Gradient::platformGradient):

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (88389 => 88390)


--- trunk/LayoutTests/ChangeLog	2011-06-08 21:39:27 UTC (rev 88389)
+++ trunk/LayoutTests/ChangeLog	2011-06-08 21:39:41 UTC (rev 88390)
@@ -1,3 +1,12 @@
+2011-06-08  Mike Reed  <[email protected]>
+
+        Reviewed by James Robinson.
+
+        [Skia] check for null-shader from gradient factory
+        https://bugs.webkit.org/show_bug.cgi?id=62319
+
+        * platform/chromium-linux/fast/gradients/crash-on-degenerate-gradient-expected.txt: Added.
+
 2011-06-08  Kenneth Russell  <[email protected]>
 
         Reviewed by Adam Barth.

Added: trunk/LayoutTests/fast/gradients/crash-on-degenerate-gradient.html (0 => 88390)


--- trunk/LayoutTests/fast/gradients/crash-on-degenerate-gradient.html	                        (rev 0)
+++ trunk/LayoutTests/fast/gradients/crash-on-degenerate-gradient.html	2011-06-08 21:39:41 UTC (rev 88390)
@@ -0,0 +1,11 @@
+<head>
+<script>
+if (window.layoutTestController)
+  window.layoutTestController.dumpAsText();
+</script>
+</head>
+<body>
+<h1>Degenerate Linear gradient. Should not crash</h1>
+<button style="background-image: -webkit-radial-gradient(1 1, Scrollbar -1, red -1)">
+</body>
+
Property changes on: trunk/LayoutTests/fast/gradients/crash-on-degenerate-gradient.html
___________________________________________________________________

Added: svn:eol-style

Added: trunk/LayoutTests/platform/chromium-linux/fast/gradients/crash-on-degenerate-gradient-expected.txt (0 => 88390)


--- trunk/LayoutTests/platform/chromium-linux/fast/gradients/crash-on-degenerate-gradient-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/chromium-linux/fast/gradients/crash-on-degenerate-gradient-expected.txt	2011-06-08 21:39:41 UTC (rev 88390)
@@ -0,0 +1,3 @@
+Degenerate Linear gradient. Should not crash
+
+
Property changes on: trunk/LayoutTests/platform/chromium-linux/fast/gradients/crash-on-degenerate-gradient-expected.txt
___________________________________________________________________

Added: svn:eol-style

Modified: trunk/Source/WebCore/ChangeLog (88389 => 88390)


--- trunk/Source/WebCore/ChangeLog	2011-06-08 21:39:27 UTC (rev 88389)
+++ trunk/Source/WebCore/ChangeLog	2011-06-08 21:39:41 UTC (rev 88390)
@@ -1,3 +1,14 @@
+2011-06-08  Mike Reed  <[email protected]>
+
+        Reviewed by James Robinson.
+
+        [Skia] check for null-shader from gradient factory
+        https://bugs.webkit.org/show_bug.cgi?id=62319
+
+        * platform/graphics/skia/GradientSkia.cpp:
+        (WebCore::Gradient::platformDestroy):
+        (WebCore::Gradient::platformGradient):
+
 2011-06-08  Kenneth Russell  <[email protected]>
 
         Reviewed by Adam Barth.

Modified: trunk/Source/WebCore/platform/graphics/skia/GradientSkia.cpp (88389 => 88390)


--- trunk/Source/WebCore/platform/graphics/skia/GradientSkia.cpp	2011-06-08 21:39:27 UTC (rev 88389)
+++ trunk/Source/WebCore/platform/graphics/skia/GradientSkia.cpp	2011-06-08 21:39:41 UTC (rev 88390)
@@ -34,6 +34,7 @@
 #include "CSSParser.h"
 #include "GraphicsContext.h"
 
+#include "SkColorShader.h"
 #include "SkGradientShader.h"
 #include "SkiaUtils.h"
 
@@ -41,8 +42,7 @@
 
 void Gradient::platformDestroy()
 {
-    if (m_gradient)
-        SkSafeUnref(m_gradient);
+    SkSafeUnref(m_gradient);
     m_gradient = 0;
 }
 
@@ -146,11 +146,7 @@
         // Since the two-point radial gradient is slower than the plain radial,
         // only use it if we have to.
         if (m_p0 == m_p1 && m_r0 <= 0.0f) {
-            // The radius we give to Skia must be positive (and non-zero).  If
-            // we're given a zero radius, just ask for a very small radius so
-            // Skia will still return an object.
-            SkScalar radius = m_r1 > 0 ? WebCoreFloatToSkScalar(m_r1) : SK_ScalarMin;
-            m_gradient = SkGradientShader::CreateRadial(m_p1, radius, colors, pos, static_cast<int>(countUsed), tile);
+            m_gradient = SkGradientShader::CreateRadial(m_p1, m_r1, colors, pos, static_cast<int>(countUsed), tile);
         } else {
             // The radii we give to Skia must be positive.  If we're given a 
             // negative radius, ask for zero instead.
@@ -172,9 +168,11 @@
         m_gradient = SkGradientShader::CreateLinear(pts, colors, pos, static_cast<int>(countUsed), tile);
     }
 
-    ASSERT(m_gradient);
-    SkMatrix matrix = m_gradientSpaceTransformation;
-    m_gradient->setLocalMatrix(matrix);
+    if (!m_gradient)
+        // use last color, since our "geometry" was degenerate (e.g. radius==0)
+        m_gradient = new SkColorShader(colors[countUsed - 1]);
+    else
+        m_gradient->setLocalMatrix(m_gradientSpaceTransformation);
     return m_gradient;
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to