Title: [91003] trunk/Source/WebCore
Revision
91003
Author
[email protected]
Date
2011-07-14 09:29:55 -0700 (Thu, 14 Jul 2011)

Log Message

Don't skip custom cursors if an Image* is null,
since this can lead to a non-custom Cursor flickering
back in when the custom cursor hasn't finished loading yet.
https://bugs.webkit.org/show_bug.cgi?id=64321

Reviewed by Darin Fisher.

Manual test, since we're testing visual flickering.

* manual-tests/canvas-cursor.html: Added.
* page/EventHandler.cpp:
(WebCore::EventHandler::selectCursor):
* platform/Cursor.cpp:
(WebCore::determineHotSpot):

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (91002 => 91003)


--- trunk/Source/WebCore/ChangeLog	2011-07-14 16:20:01 UTC (rev 91002)
+++ trunk/Source/WebCore/ChangeLog	2011-07-14 16:29:55 UTC (rev 91003)
@@ -1,3 +1,20 @@
+2011-07-14  Nate Chapin  <[email protected]>
+
+        Don't skip custom cursors if an Image* is null,
+        since this can lead to a non-custom Cursor flickering 
+        back in when the custom cursor hasn't finished loading yet.
+        https://bugs.webkit.org/show_bug.cgi?id=64321
+
+        Reviewed by Darin Fisher.
+
+        Manual test, since we're testing visual flickering.
+
+        * manual-tests/canvas-cursor.html: Added.
+        * page/EventHandler.cpp:
+        (WebCore::EventHandler::selectCursor):
+        * platform/Cursor.cpp:
+        (WebCore::determineHotSpot):
+
 2011-07-14  Young Han Lee  <[email protected]>
 
         Reviewed by Dirk Schulze.

Added: trunk/Source/WebCore/manual-tests/canvas-cursor.html (0 => 91003)


--- trunk/Source/WebCore/manual-tests/canvas-cursor.html	                        (rev 0)
+++ trunk/Source/WebCore/manual-tests/canvas-cursor.html	2011-07-14 16:29:55 UTC (rev 91003)
@@ -0,0 +1,41 @@
+<html>
+<body>
+This is a test of our ability to convert a canvas to a data url and use it as a cursor. We pass if the cursor animates smoothly and without flickering.<br>
+See https://bugs.webkit.org/show_bug.cgi?id=64321.
+<canvas id="c" width="40" height="40"></canvas>
+<script type="text/_javascript_">
+var icon = new Image;
+icon.src = ''
+
+function drawArrow(angle) {
+    var canvas = document.getElementById('c');
+    canvas.width = canvas.width // reset canvas
+    var ctx = canvas.getContext('2d');
+
+    ctx.translate(ctx.canvas.width / 2, ctx.canvas.height / 2);
+    ctx.rotate(angle);
+    ctx.drawImage(icon, -icon.width / 2, -icon.height / 2);
+
+    var x = 20;//Math.floor(Math.cos(angle) * icon.width / 2) + icon.width / 2;
+    var y = 20;//Math.floor(Math.sin(angle) * icon.width / 2) + icon.width / 2;
+
+    var data = ""
+    if (data)
+        document.body.style.cursor = 'url('+data+') ' + x + ' ' + y + ', pointer';
+    else
+        console.log('failure');
+}
+
+(function() {
+    var angle = 0;
+    var run = function() {
+        angle += Math.PI / 16;
+        drawArrow(angle);
+        setTimeout(run, 100);
+    };
+    run();
+})();
+    drawArrow();
+</script>
+</body>
+</html>

Modified: trunk/Source/WebCore/page/EventHandler.cpp (91002 => 91003)


--- trunk/Source/WebCore/page/EventHandler.cpp	2011-07-14 16:20:01 UTC (rev 91002)
+++ trunk/Source/WebCore/page/EventHandler.cpp	2011-07-14 16:29:55 UTC (rev 91003)
@@ -1204,8 +1204,6 @@
             IntSize size = cimage->image()->size();
             if (size.width() > 128 || size.height() > 128)
                 continue;
-            if (cimage->image()->isNull())
-                break;
             if (!cimage->errorOccurred())
                 return Cursor(cimage->image(), hotSpot);
         }

Modified: trunk/Source/WebCore/platform/Cursor.cpp (91002 => 91003)


--- trunk/Source/WebCore/platform/Cursor.cpp	2011-07-14 16:20:01 UTC (rev 91002)
+++ trunk/Source/WebCore/platform/Cursor.cpp	2011-07-14 16:29:55 UTC (rev 91003)
@@ -32,6 +32,9 @@
 
 IntPoint determineHotSpot(Image* image, const IntPoint& specifiedHotSpot)
 {
+    if (image->isNull())
+        return IntPoint();
+
     // Hot spot must be inside cursor rectangle.
     IntRect imageRect = image->rect();
     if (imageRect.contains(specifiedHotSpot))
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to