Title: [91504] trunk
Revision
91504
Author
[email protected]
Date
2011-07-21 14:43:10 -0700 (Thu, 21 Jul 2011)

Log Message

Update webglcontextlost / webglcontextrestored delivery to match spec changes
https://bugs.webkit.org/show_bug.cgi?id=58621

Reviewed by James Robinson.

Source/WebCore: 

Updated conditions under which webglcontextrestored event is
delivered to be spec compliant.

* html/canvas/WebGLRenderingContext.cpp:
(WebCore::WebGLRenderingContext::WebGLRenderingContext):
(WebCore::WebGLRenderingContext::loseContext):
(WebCore::WebGLRenderingContext::maybeRestoreContext):
* html/canvas/WebGLRenderingContext.h:

LayoutTests: 

Updated layout test to test spec compliant behavior.

* fast/canvas/webgl/context-lost-restored-expected.txt:
* fast/canvas/webgl/context-lost-restored.html:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (91503 => 91504)


--- trunk/LayoutTests/ChangeLog	2011-07-21 21:42:51 UTC (rev 91503)
+++ trunk/LayoutTests/ChangeLog	2011-07-21 21:43:10 UTC (rev 91504)
@@ -1,3 +1,15 @@
+2011-07-21  Kenneth Russell  <[email protected]>
+
+        Update webglcontextlost / webglcontextrestored delivery to match spec changes
+        https://bugs.webkit.org/show_bug.cgi?id=58621
+
+        Reviewed by James Robinson.
+
+        Updated layout test to test spec compliant behavior.
+
+        * fast/canvas/webgl/context-lost-restored-expected.txt:
+        * fast/canvas/webgl/context-lost-restored.html:
+
 2011-07-21  Ryosuke Niwa  <[email protected]>
 
         Chromium rebaselines after r91493.

Modified: trunk/LayoutTests/fast/canvas/webgl/context-lost-restored-expected.txt (91503 => 91504)


--- trunk/LayoutTests/fast/canvas/webgl/context-lost-restored-expected.txt	2011-07-21 21:42:51 UTC (rev 91503)
+++ trunk/LayoutTests/fast/canvas/webgl/context-lost-restored-expected.txt	2011-07-21 21:43:10 UTC (rev 91504)
@@ -40,6 +40,7 @@
 PASS gl.useProgram(program) was expected value: NO_ERROR.
 PASS gl.bindBuffer(gl.ARRAY_BUFFER, bufferObjects[0]) was expected value: NO_ERROR.
 
+PASS extension.restoreContext() was expected value: NO_ERROR.
 
 PASS successfullyParsed is true
 

Modified: trunk/LayoutTests/fast/canvas/webgl/context-lost-restored.html (91503 => 91504)


--- trunk/LayoutTests/fast/canvas/webgl/context-lost-restored.html	2011-07-21 21:42:51 UTC (rev 91503)
+++ trunk/LayoutTests/fast/canvas/webgl/context-lost-restored.html	2011-07-21 21:43:10 UTC (rev 91504)
@@ -15,6 +15,7 @@
 var program;
 var texture;
 var texColor = [255, 10, 20, 255];
+var allowRestore;
 
 function init()
 {
@@ -58,10 +59,11 @@
     debug("Test losing a context and inability to restore it.");
 
     canvas.addEventListener("webglcontextlost", testLostContext);
+    canvas.addEventListener("webglcontextrestored", testShouldNotRestoreContext);
+    allowRestore = false;
 
     testOriginalContext();
     extension.loseContext();
-    // FIXME: this isn't yet spec compliant.
     shouldGenerateGLError(gl, gl.INVALID_OPERATION, "extension.restoreContext()");
     debug("");
 }
@@ -75,10 +77,11 @@
 
     canvas.addEventListener("webglcontextlost", testLostContext);
     canvas.addEventListener("webglcontextrestored", testRestoredContext);
+    allowRestore = true;
 
     testOriginalContext();
     extension.loseContext();
-    extension.restoreContext();
+    shouldGenerateGLError(gl, gl.NO_ERROR, "extension.restoreContext()");
     debug("");
 }
 
@@ -110,15 +113,23 @@
     debug("");
 }
 
-function testLostContext()
+function testLostContext(e)
 {
     debug("Test lost context");
     shouldBeTrue("gl.isContextLost()");
     shouldBe("gl.getError()", "gl.CONTEXT_LOST_WEBGL");
     shouldBe("gl.getError()", "gl.NO_ERROR");
     debug("");
+    if (allowRestore)
+        e.preventDefault();
 }
 
+function testShouldNotRestoreContext(e)
+{
+    testFailed("Should not restore the context unless preventDefault is called on the context lost event");
+    debug("");
+}
+
 function testResources(expected)
 {
     var tests = [

Modified: trunk/Source/WebCore/ChangeLog (91503 => 91504)


--- trunk/Source/WebCore/ChangeLog	2011-07-21 21:42:51 UTC (rev 91503)
+++ trunk/Source/WebCore/ChangeLog	2011-07-21 21:43:10 UTC (rev 91504)
@@ -1,3 +1,19 @@
+2011-07-21  Kenneth Russell  <[email protected]>
+
+        Update webglcontextlost / webglcontextrestored delivery to match spec changes
+        https://bugs.webkit.org/show_bug.cgi?id=58621
+
+        Reviewed by James Robinson.
+
+        Updated conditions under which webglcontextrestored event is
+        delivered to be spec compliant.
+
+        * html/canvas/WebGLRenderingContext.cpp:
+        (WebCore::WebGLRenderingContext::WebGLRenderingContext):
+        (WebCore::WebGLRenderingContext::loseContext):
+        (WebCore::WebGLRenderingContext::maybeRestoreContext):
+        * html/canvas/WebGLRenderingContext.h:
+
 2011-07-21  Dave Hyatt  <[email protected]>
 
         https://bugs.webkit.org/show_bug.cgi?id=64975

Modified: trunk/Source/WebCore/html/canvas/WebGLRenderingContext.cpp (91503 => 91504)


--- trunk/Source/WebCore/html/canvas/WebGLRenderingContext.cpp	2011-07-21 21:42:51 UTC (rev 91503)
+++ trunk/Source/WebCore/html/canvas/WebGLRenderingContext.cpp	2011-07-21 21:43:10 UTC (rev 91504)
@@ -377,6 +377,7 @@
                                              GraphicsContext3D::Attributes attributes)
     : CanvasRenderingContext(passedCanvas)
     , m_context(context)
+    , m_restoreAllowed(false)
     , m_restoreTimer(this)
     , m_videoCache(4)
     , m_contextLost(false)
@@ -4768,7 +4769,9 @@
     }
     m_context->synthesizeGLError(GraphicsContext3D::CONTEXT_LOST_WEBGL);
 
-    canvas()->dispatchEvent(WebGLContextEvent::create(eventNames().webglcontextlostEvent, false, true, ""));
+    RefPtr<WebGLContextEvent> event = WebGLContextEvent::create(eventNames().webglcontextlostEvent, false, true, "");
+    canvas()->dispatchEvent(event);
+    m_restoreAllowed = event->defaultPrevented();
 }
 
 void WebGLRenderingContext::maybeRestoreContext(WebGLRenderingContext::LostContextMode mode)
@@ -4779,10 +4782,9 @@
         return;
     }
 
-    // The rendering context is not restored if there is no handler for the
-    // context restored event. (FIXME: this is not spec compliant. A follow-on
-    // patch will bring this to spec compliance.)
-    if (!canvas()->hasEventListeners(eventNames().webglcontextrestoredEvent)) {
+    // The rendering context is not restored unless the default
+    // behavior of the webglcontextlost event was prevented earlier.
+    if (!m_restoreAllowed) {
         if (mode == SyntheticLostContext)
             m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
         return;

Modified: trunk/Source/WebCore/html/canvas/WebGLRenderingContext.h (91503 => 91504)


--- trunk/Source/WebCore/html/canvas/WebGLRenderingContext.h	2011-07-21 21:42:51 UTC (rev 91503)
+++ trunk/Source/WebCore/html/canvas/WebGLRenderingContext.h	2011-07-21 21:43:10 UTC (rev 91504)
@@ -363,6 +363,7 @@
         WebGLRenderingContext* m_context;
     };
 
+    bool m_restoreAllowed;
     WebGLRenderingContextRestoreTimer m_restoreTimer;
 
     bool m_needsUpdate;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to