<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[164452] trunk/Source/WebCore</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/164452">164452</a></dd>
<dt>Author</dt> <dd>dino@apple.com</dd>
<dt>Date</dt> <dd>2014-02-20 15:12:18 -0800 (Thu, 20 Feb 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>An unresolved WebGL Context should operate normally until used
https://bugs.webkit.org/show_bug.cgi?id=129110

Reviewed by Brent Fulgham.

Add the ability to create a special instance of WebGLRenderingContext,
that appears normal but won't actually do anything if asked. This will
be created in the case of the WebGLLoadPolicy being &quot;pending&quot; and helps
in the case of pages that feature detect by creating a context and
immediately deleting it.

Note that the context doesn't actually try to recover from this state
yet, although that would be a nice addition. When asked to do something
it could actually try to create the GraphicsContext3D. However, if it
fails it would then have to fire a context lost.

* html/HTMLCanvasElement.cpp:
(WebCore::HTMLCanvasElement::getContext): Move the load policy code out of getContext.
* html/canvas/WebGLRenderingContext.cpp:
(WebCore::WebGLRenderingContext::create): Add the ability to create a pending context.
(WebCore::WebGLRenderingContext::WebGLRenderingContext): New constructor for a pending context.
(WebCore::WebGLRenderingContext::~WebGLRenderingContext): Only delete if not pending.
(WebCore::WebGLRenderingContext::destroyGraphicsContext3D): Ditto.
(WebCore::WebGLRenderingContext::clearIfComposited): Everything below is about checking the
pending state before doing anything, and triggering a resolution if necessary.
(WebCore::WebGLRenderingContext::activeTexture):
(WebCore::WebGLRenderingContext::attachShader):
(WebCore::WebGLRenderingContext::bindAttribLocation):
(WebCore::WebGLRenderingContext::checkObjectToBeBound):
(WebCore::WebGLRenderingContext::blendColor):
(WebCore::WebGLRenderingContext::blendEquation):
(WebCore::WebGLRenderingContext::blendEquationSeparate):
(WebCore::WebGLRenderingContext::blendFunc):
(WebCore::WebGLRenderingContext::blendFuncSeparate):
(WebCore::WebGLRenderingContext::bufferData):
(WebCore::WebGLRenderingContext::bufferSubData):
(WebCore::WebGLRenderingContext::checkFramebufferStatus):
(WebCore::WebGLRenderingContext::clear):
(WebCore::WebGLRenderingContext::clearColor):
(WebCore::WebGLRenderingContext::clearDepth):
(WebCore::WebGLRenderingContext::clearStencil):
(WebCore::WebGLRenderingContext::colorMask):
(WebCore::WebGLRenderingContext::compileShader):
(WebCore::WebGLRenderingContext::compressedTexImage2D):
(WebCore::WebGLRenderingContext::compressedTexSubImage2D):
(WebCore::WebGLRenderingContext::copyTexImage2D):
(WebCore::WebGLRenderingContext::copyTexSubImage2D):
(WebCore::WebGLRenderingContext::createBuffer):
(WebCore::WebGLRenderingContext::createFramebuffer):
(WebCore::WebGLRenderingContext::createTexture):
(WebCore::WebGLRenderingContext::createProgram):
(WebCore::WebGLRenderingContext::createRenderbuffer):
(WebCore::WebGLRenderingContext::createShader):
(WebCore::WebGLRenderingContext::cullFace):
(WebCore::WebGLRenderingContext::deleteObject):
(WebCore::WebGLRenderingContext::depthFunc):
(WebCore::WebGLRenderingContext::depthMask):
(WebCore::WebGLRenderingContext::depthRange):
(WebCore::WebGLRenderingContext::detachShader):
(WebCore::WebGLRenderingContext::disable):
(WebCore::WebGLRenderingContext::disableVertexAttribArray):
(WebCore::WebGLRenderingContext::validateDrawArrays):
(WebCore::WebGLRenderingContext::validateDrawElements):
(WebCore::WebGLRenderingContext::enable):
(WebCore::WebGLRenderingContext::enableVertexAttribArray):
(WebCore::WebGLRenderingContext::finish):
(WebCore::WebGLRenderingContext::flush):
(WebCore::WebGLRenderingContext::framebufferRenderbuffer):
(WebCore::WebGLRenderingContext::framebufferTexture2D):
(WebCore::WebGLRenderingContext::frontFace):
(WebCore::WebGLRenderingContext::generateMipmap):
(WebCore::WebGLRenderingContext::getActiveAttrib):
(WebCore::WebGLRenderingContext::getActiveUniform):
(WebCore::WebGLRenderingContext::getAttachedShaders):
(WebCore::WebGLRenderingContext::getAttribLocation):
(WebCore::WebGLRenderingContext::getBufferParameter):
(WebCore::WebGLRenderingContext::getContextAttributes):
(WebCore::WebGLRenderingContext::getExtension):
(WebCore::WebGLRenderingContext::getFramebufferAttachmentParameter):
(WebCore::WebGLRenderingContext::getParameter):
(WebCore::WebGLRenderingContext::getProgramParameter):
(WebCore::WebGLRenderingContext::getProgramInfoLog):
(WebCore::WebGLRenderingContext::getRenderbufferParameter):
(WebCore::WebGLRenderingContext::getShaderParameter):
(WebCore::WebGLRenderingContext::getShaderInfoLog):
(WebCore::WebGLRenderingContext::getShaderPrecisionFormat):
(WebCore::WebGLRenderingContext::getShaderSource):
(WebCore::WebGLRenderingContext::getTexParameter):
(WebCore::WebGLRenderingContext::getUniform):
(WebCore::WebGLRenderingContext::getUniformLocation):
(WebCore::WebGLRenderingContext::getVertexAttrib):
(WebCore::WebGLRenderingContext::getVertexAttribOffset):
(WebCore::WebGLRenderingContext::hint):
(WebCore::WebGLRenderingContext::isBuffer):
(WebCore::WebGLRenderingContext::isContextLostOrPending):
(WebCore::WebGLRenderingContext::isEnabled):
(WebCore::WebGLRenderingContext::isFramebuffer):
(WebCore::WebGLRenderingContext::isProgram):
(WebCore::WebGLRenderingContext::isRenderbuffer):
(WebCore::WebGLRenderingContext::isShader):
(WebCore::WebGLRenderingContext::isTexture):
(WebCore::WebGLRenderingContext::lineWidth):
(WebCore::WebGLRenderingContext::linkProgram):
(WebCore::WebGLRenderingContext::pixelStorei):
(WebCore::WebGLRenderingContext::polygonOffset):
(WebCore::WebGLRenderingContext::readPixels):
(WebCore::WebGLRenderingContext::releaseShaderCompiler):
(WebCore::WebGLRenderingContext::renderbufferStorage):
(WebCore::WebGLRenderingContext::sampleCoverage):
(WebCore::WebGLRenderingContext::scissor):
(WebCore::WebGLRenderingContext::shaderSource):
(WebCore::WebGLRenderingContext::stencilFunc):
(WebCore::WebGLRenderingContext::stencilFuncSeparate):
(WebCore::WebGLRenderingContext::stencilMask):
(WebCore::WebGLRenderingContext::stencilMaskSeparate):
(WebCore::WebGLRenderingContext::stencilOp):
(WebCore::WebGLRenderingContext::stencilOpSeparate):
(WebCore::WebGLRenderingContext::texImage2D):
(WebCore::WebGLRenderingContext::texParameter):
(WebCore::WebGLRenderingContext::texSubImage2D):
(WebCore::WebGLRenderingContext::uniform1f):
(WebCore::WebGLRenderingContext::uniform1fv):
(WebCore::WebGLRenderingContext::uniform1i):
(WebCore::WebGLRenderingContext::uniform1iv):
(WebCore::WebGLRenderingContext::uniform2f):
(WebCore::WebGLRenderingContext::uniform2fv):
(WebCore::WebGLRenderingContext::uniform2i):
(WebCore::WebGLRenderingContext::uniform2iv):
(WebCore::WebGLRenderingContext::uniform3f):
(WebCore::WebGLRenderingContext::uniform3fv):
(WebCore::WebGLRenderingContext::uniform3i):
(WebCore::WebGLRenderingContext::uniform3iv):
(WebCore::WebGLRenderingContext::uniform4f):
(WebCore::WebGLRenderingContext::uniform4fv):
(WebCore::WebGLRenderingContext::uniform4i):
(WebCore::WebGLRenderingContext::uniform4iv):
(WebCore::WebGLRenderingContext::uniformMatrix2fv):
(WebCore::WebGLRenderingContext::uniformMatrix3fv):
(WebCore::WebGLRenderingContext::uniformMatrix4fv):
(WebCore::WebGLRenderingContext::validateProgram):
(WebCore::WebGLRenderingContext::vertexAttribPointer):
(WebCore::WebGLRenderingContext::viewport):
(WebCore::WebGLRenderingContext::forceLostContext):
(WebCore::WebGLRenderingContext::forceRestoreContext):
(WebCore::WebGLRenderingContext::platformLayer):
(WebCore::WebGLRenderingContext::removeSharedObject):
(WebCore::WebGLRenderingContext::addSharedObject):
(WebCore::WebGLRenderingContext::removeContextObject):
(WebCore::WebGLRenderingContext::addContextObject):
(WebCore::WebGLRenderingContext::detachAndRemoveAllObjects):
(WebCore::WebGLRenderingContext::stop):
(WebCore::WebGLRenderingContext::vertexAttribfImpl):
(WebCore::WebGLRenderingContext::vertexAttribfvImpl):
(WebCore::WebGLRenderingContext::vertexAttribDivisor):
* html/canvas/WebGLRenderingContext.h:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorehtmlHTMLCanvasElementcpp">trunk/Source/WebCore/html/HTMLCanvasElement.cpp</a></li>
<li><a href="#trunkSourceWebCorehtmlcanvasWebGLRenderingContextcpp">trunk/Source/WebCore/html/canvas/WebGLRenderingContext.cpp</a></li>
<li><a href="#trunkSourceWebCorehtmlcanvasWebGLRenderingContexth">trunk/Source/WebCore/html/canvas/WebGLRenderingContext.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (164451 => 164452)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2014-02-20 23:11:52 UTC (rev 164451)
+++ trunk/Source/WebCore/ChangeLog        2014-02-20 23:12:18 UTC (rev 164452)
</span><span class="lines">@@ -1,5 +1,163 @@
</span><span class="cx"> 2014-02-20  Dean Jackson  &lt;dino@apple.com&gt;
</span><span class="cx"> 
</span><ins>+        An unresolved WebGL Context should operate normally until used
+        https://bugs.webkit.org/show_bug.cgi?id=129110
+
+        Reviewed by Brent Fulgham.
+
+        Add the ability to create a special instance of WebGLRenderingContext,
+        that appears normal but won't actually do anything if asked. This will
+        be created in the case of the WebGLLoadPolicy being &quot;pending&quot; and helps
+        in the case of pages that feature detect by creating a context and
+        immediately deleting it.
+
+        Note that the context doesn't actually try to recover from this state
+        yet, although that would be a nice addition. When asked to do something
+        it could actually try to create the GraphicsContext3D. However, if it
+        fails it would then have to fire a context lost.
+
+        * html/HTMLCanvasElement.cpp:
+        (WebCore::HTMLCanvasElement::getContext): Move the load policy code out of getContext.
+        * html/canvas/WebGLRenderingContext.cpp:
+        (WebCore::WebGLRenderingContext::create): Add the ability to create a pending context.
+        (WebCore::WebGLRenderingContext::WebGLRenderingContext): New constructor for a pending context.
+        (WebCore::WebGLRenderingContext::~WebGLRenderingContext): Only delete if not pending.
+        (WebCore::WebGLRenderingContext::destroyGraphicsContext3D): Ditto.
+        (WebCore::WebGLRenderingContext::clearIfComposited): Everything below is about checking the
+        pending state before doing anything, and triggering a resolution if necessary.
+        (WebCore::WebGLRenderingContext::activeTexture):
+        (WebCore::WebGLRenderingContext::attachShader):
+        (WebCore::WebGLRenderingContext::bindAttribLocation):
+        (WebCore::WebGLRenderingContext::checkObjectToBeBound):
+        (WebCore::WebGLRenderingContext::blendColor):
+        (WebCore::WebGLRenderingContext::blendEquation):
+        (WebCore::WebGLRenderingContext::blendEquationSeparate):
+        (WebCore::WebGLRenderingContext::blendFunc):
+        (WebCore::WebGLRenderingContext::blendFuncSeparate):
+        (WebCore::WebGLRenderingContext::bufferData):
+        (WebCore::WebGLRenderingContext::bufferSubData):
+        (WebCore::WebGLRenderingContext::checkFramebufferStatus):
+        (WebCore::WebGLRenderingContext::clear):
+        (WebCore::WebGLRenderingContext::clearColor):
+        (WebCore::WebGLRenderingContext::clearDepth):
+        (WebCore::WebGLRenderingContext::clearStencil):
+        (WebCore::WebGLRenderingContext::colorMask):
+        (WebCore::WebGLRenderingContext::compileShader):
+        (WebCore::WebGLRenderingContext::compressedTexImage2D):
+        (WebCore::WebGLRenderingContext::compressedTexSubImage2D):
+        (WebCore::WebGLRenderingContext::copyTexImage2D):
+        (WebCore::WebGLRenderingContext::copyTexSubImage2D):
+        (WebCore::WebGLRenderingContext::createBuffer):
+        (WebCore::WebGLRenderingContext::createFramebuffer):
+        (WebCore::WebGLRenderingContext::createTexture):
+        (WebCore::WebGLRenderingContext::createProgram):
+        (WebCore::WebGLRenderingContext::createRenderbuffer):
+        (WebCore::WebGLRenderingContext::createShader):
+        (WebCore::WebGLRenderingContext::cullFace):
+        (WebCore::WebGLRenderingContext::deleteObject):
+        (WebCore::WebGLRenderingContext::depthFunc):
+        (WebCore::WebGLRenderingContext::depthMask):
+        (WebCore::WebGLRenderingContext::depthRange):
+        (WebCore::WebGLRenderingContext::detachShader):
+        (WebCore::WebGLRenderingContext::disable):
+        (WebCore::WebGLRenderingContext::disableVertexAttribArray):
+        (WebCore::WebGLRenderingContext::validateDrawArrays):
+        (WebCore::WebGLRenderingContext::validateDrawElements):
+        (WebCore::WebGLRenderingContext::enable):
+        (WebCore::WebGLRenderingContext::enableVertexAttribArray):
+        (WebCore::WebGLRenderingContext::finish):
+        (WebCore::WebGLRenderingContext::flush):
+        (WebCore::WebGLRenderingContext::framebufferRenderbuffer):
+        (WebCore::WebGLRenderingContext::framebufferTexture2D):
+        (WebCore::WebGLRenderingContext::frontFace):
+        (WebCore::WebGLRenderingContext::generateMipmap):
+        (WebCore::WebGLRenderingContext::getActiveAttrib):
+        (WebCore::WebGLRenderingContext::getActiveUniform):
+        (WebCore::WebGLRenderingContext::getAttachedShaders):
+        (WebCore::WebGLRenderingContext::getAttribLocation):
+        (WebCore::WebGLRenderingContext::getBufferParameter):
+        (WebCore::WebGLRenderingContext::getContextAttributes):
+        (WebCore::WebGLRenderingContext::getExtension):
+        (WebCore::WebGLRenderingContext::getFramebufferAttachmentParameter):
+        (WebCore::WebGLRenderingContext::getParameter):
+        (WebCore::WebGLRenderingContext::getProgramParameter):
+        (WebCore::WebGLRenderingContext::getProgramInfoLog):
+        (WebCore::WebGLRenderingContext::getRenderbufferParameter):
+        (WebCore::WebGLRenderingContext::getShaderParameter):
+        (WebCore::WebGLRenderingContext::getShaderInfoLog):
+        (WebCore::WebGLRenderingContext::getShaderPrecisionFormat):
+        (WebCore::WebGLRenderingContext::getShaderSource):
+        (WebCore::WebGLRenderingContext::getTexParameter):
+        (WebCore::WebGLRenderingContext::getUniform):
+        (WebCore::WebGLRenderingContext::getUniformLocation):
+        (WebCore::WebGLRenderingContext::getVertexAttrib):
+        (WebCore::WebGLRenderingContext::getVertexAttribOffset):
+        (WebCore::WebGLRenderingContext::hint):
+        (WebCore::WebGLRenderingContext::isBuffer):
+        (WebCore::WebGLRenderingContext::isContextLostOrPending):
+        (WebCore::WebGLRenderingContext::isEnabled):
+        (WebCore::WebGLRenderingContext::isFramebuffer):
+        (WebCore::WebGLRenderingContext::isProgram):
+        (WebCore::WebGLRenderingContext::isRenderbuffer):
+        (WebCore::WebGLRenderingContext::isShader):
+        (WebCore::WebGLRenderingContext::isTexture):
+        (WebCore::WebGLRenderingContext::lineWidth):
+        (WebCore::WebGLRenderingContext::linkProgram):
+        (WebCore::WebGLRenderingContext::pixelStorei):
+        (WebCore::WebGLRenderingContext::polygonOffset):
+        (WebCore::WebGLRenderingContext::readPixels):
+        (WebCore::WebGLRenderingContext::releaseShaderCompiler):
+        (WebCore::WebGLRenderingContext::renderbufferStorage):
+        (WebCore::WebGLRenderingContext::sampleCoverage):
+        (WebCore::WebGLRenderingContext::scissor):
+        (WebCore::WebGLRenderingContext::shaderSource):
+        (WebCore::WebGLRenderingContext::stencilFunc):
+        (WebCore::WebGLRenderingContext::stencilFuncSeparate):
+        (WebCore::WebGLRenderingContext::stencilMask):
+        (WebCore::WebGLRenderingContext::stencilMaskSeparate):
+        (WebCore::WebGLRenderingContext::stencilOp):
+        (WebCore::WebGLRenderingContext::stencilOpSeparate):
+        (WebCore::WebGLRenderingContext::texImage2D):
+        (WebCore::WebGLRenderingContext::texParameter):
+        (WebCore::WebGLRenderingContext::texSubImage2D):
+        (WebCore::WebGLRenderingContext::uniform1f):
+        (WebCore::WebGLRenderingContext::uniform1fv):
+        (WebCore::WebGLRenderingContext::uniform1i):
+        (WebCore::WebGLRenderingContext::uniform1iv):
+        (WebCore::WebGLRenderingContext::uniform2f):
+        (WebCore::WebGLRenderingContext::uniform2fv):
+        (WebCore::WebGLRenderingContext::uniform2i):
+        (WebCore::WebGLRenderingContext::uniform2iv):
+        (WebCore::WebGLRenderingContext::uniform3f):
+        (WebCore::WebGLRenderingContext::uniform3fv):
+        (WebCore::WebGLRenderingContext::uniform3i):
+        (WebCore::WebGLRenderingContext::uniform3iv):
+        (WebCore::WebGLRenderingContext::uniform4f):
+        (WebCore::WebGLRenderingContext::uniform4fv):
+        (WebCore::WebGLRenderingContext::uniform4i):
+        (WebCore::WebGLRenderingContext::uniform4iv):
+        (WebCore::WebGLRenderingContext::uniformMatrix2fv):
+        (WebCore::WebGLRenderingContext::uniformMatrix3fv):
+        (WebCore::WebGLRenderingContext::uniformMatrix4fv):
+        (WebCore::WebGLRenderingContext::validateProgram):
+        (WebCore::WebGLRenderingContext::vertexAttribPointer):
+        (WebCore::WebGLRenderingContext::viewport):
+        (WebCore::WebGLRenderingContext::forceLostContext):
+        (WebCore::WebGLRenderingContext::forceRestoreContext):
+        (WebCore::WebGLRenderingContext::platformLayer):
+        (WebCore::WebGLRenderingContext::removeSharedObject):
+        (WebCore::WebGLRenderingContext::addSharedObject):
+        (WebCore::WebGLRenderingContext::removeContextObject):
+        (WebCore::WebGLRenderingContext::addContextObject):
+        (WebCore::WebGLRenderingContext::detachAndRemoveAllObjects):
+        (WebCore::WebGLRenderingContext::stop):
+        (WebCore::WebGLRenderingContext::vertexAttribfImpl):
+        (WebCore::WebGLRenderingContext::vertexAttribfvImpl):
+        (WebCore::WebGLRenderingContext::vertexAttribDivisor):
+        * html/canvas/WebGLRenderingContext.h:
+
+2014-02-20  Dean Jackson  &lt;dino@apple.com&gt;
+
</ins><span class="cx">         Add an unresolved WebGLPolicy and an API to resolve it
</span><span class="cx">         https://bugs.webkit.org/show_bug.cgi?id=129109
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLCanvasElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLCanvasElement.cpp (164451 => 164452)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLCanvasElement.cpp        2014-02-20 23:11:52 UTC (rev 164451)
+++ trunk/Source/WebCore/html/HTMLCanvasElement.cpp        2014-02-20 23:12:18 UTC (rev 164452)
</span><span class="lines">@@ -42,7 +42,6 @@
</span><span class="cx"> #include &quot;HTMLNames.h&quot;
</span><span class="cx"> #include &quot;ImageData.h&quot;
</span><span class="cx"> #include &quot;MIMETypeRegistry.h&quot;
</span><del>-#include &quot;MainFrame.h&quot;
</del><span class="cx"> #include &quot;Page.h&quot;
</span><span class="cx"> #include &quot;RenderHTMLCanvas.h&quot;
</span><span class="cx"> #include &quot;ScriptController.h&quot;
</span><span class="lines">@@ -221,14 +220,6 @@
</span><span class="cx">             if (m_context &amp;&amp; !m_context-&gt;is3d())
</span><span class="cx">                 return nullptr;
</span><span class="cx">             if (!m_context) {
</span><del>-                Document&amp; topDocument = document().topDocument();
-                Page* page = topDocument.page();
-                if (page &amp;&amp; !topDocument.url().isLocalFile()) {
-                    WebGLLoadPolicy policy = page-&gt;mainFrame().loader().client().webGLPolicyForURL(topDocument.url());
-
-                    if (policy == WebGLBlockCreation)
-                        return nullptr;
-                }
</del><span class="cx">                 m_context = WebGLRenderingContext::create(this, static_cast&lt;WebGLContextAttributes*&gt;(attrs));
</span><span class="cx">                 if (m_context) {
</span><span class="cx">                     // Need to make sure a RenderLayer and compositing layer get created for the Canvas
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlcanvasWebGLRenderingContextcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/canvas/WebGLRenderingContext.cpp (164451 => 164452)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/canvas/WebGLRenderingContext.cpp        2014-02-20 23:11:52 UTC (rev 164451)
+++ trunk/Source/WebCore/html/canvas/WebGLRenderingContext.cpp        2014-02-20 23:12:18 UTC (rev 164452)
</span><span class="lines">@@ -32,6 +32,7 @@
</span><span class="cx"> #include &quot;ANGLEInstancedArrays.h&quot;
</span><span class="cx"> #include &quot;CachedImage.h&quot;
</span><span class="cx"> #include &quot;DOMWindow.h&quot;
</span><ins>+#include &quot;Document.h&quot;
</ins><span class="cx"> #include &quot;EXTDrawBuffers.h&quot;
</span><span class="cx"> #include &quot;EXTTextureFilterAnisotropic.h&quot;
</span><span class="cx"> #include &quot;ExceptionCode.h&quot;
</span><span class="lines">@@ -47,6 +48,7 @@
</span><span class="cx"> #include &quot;ImageData.h&quot;
</span><span class="cx"> #include &quot;IntSize.h&quot;
</span><span class="cx"> #include &quot;Logging.h&quot;
</span><ins>+#include &quot;MainFrame.h&quot;
</ins><span class="cx"> #include &quot;NotImplemented.h&quot;
</span><span class="cx"> #include &quot;OESElementIndexUint.h&quot;
</span><span class="cx"> #include &quot;OESStandardDerivatives.h&quot;
</span><span class="lines">@@ -392,14 +394,30 @@
</span><span class="cx">     if (!frame)
</span><span class="cx">         return nullptr;
</span><span class="cx"> 
</span><del>-    // The FrameLoaderClient might creation of a new WebGL context despite the page settings; in
</del><ins>+    // The FrameLoaderClient might block creation of a new WebGL context despite the page settings; in
</ins><span class="cx">     // particular, if WebGL contexts were lost one or more times via the GL_ARB_robustness extension.
</span><span class="cx">     if (!frame-&gt;loader().client().allowWebGL(frame-&gt;settings().webGLEnabled())) {
</span><span class="cx">         canvas-&gt;dispatchEvent(WebGLContextEvent::create(eventNames().webglcontextcreationerrorEvent, false, true, &quot;Web page was not allowed to create a WebGL context.&quot;));
</span><span class="cx">         return nullptr;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    HostWindow* hostWindow = document.view()-&gt;root()-&gt;hostWindow();
</del><ins>+    bool isPendingPolicyResolution = false;
+    Document&amp; topDocument = document.topDocument();
+    Page* page = topDocument.page();
+    if (page &amp;&amp; !topDocument.url().isLocalFile()) {
+        WebGLLoadPolicy policy = page-&gt;mainFrame().loader().client().webGLPolicyForURL(topDocument.url());
+
+        if (policy == WebGLBlockCreation) {
+            LOG(WebGL, &quot;The policy for this URL (%s) is to block WebGL.&quot;, topDocument.url().host().utf8().data());
+            return nullptr;
+        }
+
+        if (policy == WebGLPendingCreation) {
+            LOG(WebGL, &quot;WebGL policy is pending. May need to be resolved later.&quot;);
+            isPendingPolicyResolution = true;
+        }
+    }
+
</ins><span class="cx">     GraphicsContext3D::Attributes attributes = attrs ? attrs-&gt;attributes() : GraphicsContext3D::Attributes();
</span><span class="cx"> 
</span><span class="cx">     if (attributes.antialias) {
</span><span class="lines">@@ -417,6 +435,14 @@
</span><span class="cx">     if (frame-&gt;settings().forceSoftwareWebGLRendering())
</span><span class="cx">         attributes.forceSoftwareRenderer = true;
</span><span class="cx"> 
</span><ins>+    if (isPendingPolicyResolution) {
+        LOG(WebGL, &quot;Create a WebGL context that looks real, but will require a policy resolution if used.&quot;);
+        OwnPtr&lt;WebGLRenderingContext&gt; renderingContext = adoptPtr(new WebGLRenderingContext(canvas, attributes));
+        renderingContext-&gt;suspendIfNeeded();
+        return renderingContext.release();
+    }
+
+    HostWindow* hostWindow = document.view()-&gt;root()-&gt;hostWindow();
</ins><span class="cx">     RefPtr&lt;GraphicsContext3D&gt; context(GraphicsContext3D::create(attributes, hostWindow));
</span><span class="cx"> 
</span><span class="cx">     if (!context || !context-&gt;makeContextCurrent()) {
</span><span class="lines">@@ -434,8 +460,27 @@
</span><span class="cx">     return renderingContext.release();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+WebGLRenderingContext::WebGLRenderingContext(HTMLCanvasElement* passedCanvas, GraphicsContext3D::Attributes attributes)
+    : CanvasRenderingContext(passedCanvas)
+    , ActiveDOMObject(&amp;passedCanvas-&gt;document())
+    , m_context(0)
+    , m_drawingBuffer(0)
+    , m_dispatchContextLostEventTimer(this, &amp;WebGLRenderingContext::dispatchContextLostEvent)
+    , m_restoreAllowed(false)
+    , m_restoreTimer(this, &amp;WebGLRenderingContext::maybeRestoreContext)
+    , m_generatedImageCache(0)
+    , m_contextLost(false)
+    , m_contextLostMode(SyntheticLostContext)
+    , m_attributes(attributes)
+    , m_synthesizedErrorsToConsole(true)
+    , m_numGLErrorsToConsoleAllowed(maxGLErrorsAllowedToConsole)
+    , m_isPendingPolicyResolution(true)
+    , m_hasRequestedPolicyResolution(false)
+{
+}
+
</ins><span class="cx"> WebGLRenderingContext::WebGLRenderingContext(HTMLCanvasElement* passedCanvas, PassRefPtr&lt;GraphicsContext3D&gt; context,
</span><del>-                                             GraphicsContext3D::Attributes attributes)
</del><ins>+    GraphicsContext3D::Attributes attributes)
</ins><span class="cx">     : CanvasRenderingContext(passedCanvas)
</span><span class="cx">     , ActiveDOMObject(&amp;passedCanvas-&gt;document())
</span><span class="cx">     , m_context(context)
</span><span class="lines">@@ -449,6 +494,8 @@
</span><span class="cx">     , m_attributes(attributes)
</span><span class="cx">     , m_synthesizedErrorsToConsole(true)
</span><span class="cx">     , m_numGLErrorsToConsoleAllowed(maxGLErrorsAllowedToConsole)
</span><ins>+    , m_isPendingPolicyResolution(false)
+    , m_hasRequestedPolicyResolution(false)
</ins><span class="cx"> {
</span><span class="cx">     ASSERT(m_context);
</span><span class="cx">     m_contextGroup = WebGLContextGroup::create();
</span><span class="lines">@@ -598,13 +645,18 @@
</span><span class="cx">     m_blackTexture2D = nullptr;
</span><span class="cx">     m_blackTextureCubeMap = nullptr;
</span><span class="cx"> 
</span><del>-    detachAndRemoveAllObjects();
-    destroyGraphicsContext3D();
-    m_contextGroup-&gt;removeContext(this);
</del><ins>+    if (!m_isPendingPolicyResolution) {
+        detachAndRemoveAllObjects();
+        destroyGraphicsContext3D();
+        m_contextGroup-&gt;removeContext(this);
+    }
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebGLRenderingContext::destroyGraphicsContext3D()
</span><span class="cx"> {
</span><ins>+    if (m_isPendingPolicyResolution)
+        return;
+
</ins><span class="cx">     // The drawing buffer holds a context reference. It must also be destroyed
</span><span class="cx">     // in order for the context to be released.
</span><span class="cx">     if (m_drawingBuffer)
</span><span class="lines">@@ -643,7 +695,7 @@
</span><span class="cx"> 
</span><span class="cx"> bool WebGLRenderingContext::clearIfComposited(GC3Dbitfield mask)
</span><span class="cx"> {
</span><del>-    if (isContextLost()) 
</del><ins>+    if (isContextLostOrPending())
</ins><span class="cx">         return false;
</span><span class="cx"> 
</span><span class="cx">     if (!m_context-&gt;layerComposited() || m_layerCleared
</span><span class="lines">@@ -840,7 +892,7 @@
</span><span class="cx"> void WebGLRenderingContext::activeTexture(GC3Denum texture, ExceptionCode&amp; ec)
</span><span class="cx"> {
</span><span class="cx">     UNUSED_PARAM(ec);
</span><del>-    if (isContextLost())
</del><ins>+    if (isContextLostOrPending())
</ins><span class="cx">         return;
</span><span class="cx">     if (texture - GraphicsContext3D::TEXTURE0 &gt;= m_textureUnits.size()) {
</span><span class="cx">         synthesizeGLError(GraphicsContext3D::INVALID_ENUM, &quot;activeTexture&quot;, &quot;texture unit out of range&quot;);
</span><span class="lines">@@ -856,7 +908,7 @@
</span><span class="cx"> void WebGLRenderingContext::attachShader(WebGLProgram* program, WebGLShader* shader, ExceptionCode&amp; ec)
</span><span class="cx"> {
</span><span class="cx">     UNUSED_PARAM(ec);
</span><del>-    if (isContextLost() || !validateWebGLObject(&quot;attachShader&quot;, program) || !validateWebGLObject(&quot;attachShader&quot;, shader))
</del><ins>+    if (isContextLostOrPending() || !validateWebGLObject(&quot;attachShader&quot;, program) || !validateWebGLObject(&quot;attachShader&quot;, shader))
</ins><span class="cx">         return;
</span><span class="cx">     if (!program-&gt;attachShader(shader)) {
</span><span class="cx">         synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, &quot;attachShader&quot;, &quot;shader attachment already has shader&quot;);
</span><span class="lines">@@ -869,7 +921,7 @@
</span><span class="cx"> void WebGLRenderingContext::bindAttribLocation(WebGLProgram* program, GC3Duint index, const String&amp; name, ExceptionCode&amp; ec)
</span><span class="cx"> {
</span><span class="cx">     UNUSED_PARAM(ec);
</span><del>-    if (isContextLost() || !validateWebGLObject(&quot;bindAttribLocation&quot;, program))
</del><ins>+    if (isContextLostOrPending() || !validateWebGLObject(&quot;bindAttribLocation&quot;, program))
</ins><span class="cx">         return;
</span><span class="cx">     if (!validateLocationLength(&quot;bindAttribLocation&quot;, name))
</span><span class="cx">         return;
</span><span class="lines">@@ -889,7 +941,7 @@
</span><span class="cx"> bool WebGLRenderingContext::checkObjectToBeBound(const char* functionName, WebGLObject* object, bool&amp; deleted)
</span><span class="cx"> {
</span><span class="cx">     deleted = false;
</span><del>-    if (isContextLost())
</del><ins>+    if (isContextLostOrPending())
</ins><span class="cx">         return false;
</span><span class="cx">     if (object) {
</span><span class="cx">         if (!object-&gt;validate(contextGroup(), this)) {
</span><span class="lines">@@ -1013,21 +1065,21 @@
</span><span class="cx"> 
</span><span class="cx"> void WebGLRenderingContext::blendColor(GC3Dfloat red, GC3Dfloat green, GC3Dfloat blue, GC3Dfloat alpha)
</span><span class="cx"> {
</span><del>-    if (isContextLost())
</del><ins>+    if (isContextLostOrPending())
</ins><span class="cx">         return;
</span><span class="cx">     m_context-&gt;blendColor(red, green, blue, alpha);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebGLRenderingContext::blendEquation(GC3Denum mode)
</span><span class="cx"> {
</span><del>-    if (isContextLost() || !validateBlendEquation(&quot;blendEquation&quot;, mode))
</del><ins>+    if (isContextLostOrPending() || !validateBlendEquation(&quot;blendEquation&quot;, mode))
</ins><span class="cx">         return;
</span><span class="cx">     m_context-&gt;blendEquation(mode);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebGLRenderingContext::blendEquationSeparate(GC3Denum modeRGB, GC3Denum modeAlpha)
</span><span class="cx"> {
</span><del>-    if (isContextLost() || !validateBlendEquation(&quot;blendEquation&quot;, modeRGB) || !validateBlendEquation(&quot;blendEquation&quot;, modeAlpha))
</del><ins>+    if (isContextLostOrPending() || !validateBlendEquation(&quot;blendEquation&quot;, modeRGB) || !validateBlendEquation(&quot;blendEquation&quot;, modeAlpha))
</ins><span class="cx">         return;
</span><span class="cx">     m_context-&gt;blendEquationSeparate(modeRGB, modeAlpha);
</span><span class="cx"> }
</span><span class="lines">@@ -1035,7 +1087,7 @@
</span><span class="cx"> 
</span><span class="cx"> void WebGLRenderingContext::blendFunc(GC3Denum sfactor, GC3Denum dfactor)
</span><span class="cx"> {
</span><del>-    if (isContextLost() || !validateBlendFuncFactors(&quot;blendFunc&quot;, sfactor, dfactor))
</del><ins>+    if (isContextLostOrPending() || !validateBlendFuncFactors(&quot;blendFunc&quot;, sfactor, dfactor))
</ins><span class="cx">         return;
</span><span class="cx">     m_context-&gt;blendFunc(sfactor, dfactor);
</span><span class="cx"> }
</span><span class="lines">@@ -1043,7 +1095,7 @@
</span><span class="cx"> void WebGLRenderingContext::blendFuncSeparate(GC3Denum srcRGB, GC3Denum dstRGB, GC3Denum srcAlpha, GC3Denum dstAlpha)
</span><span class="cx"> {
</span><span class="cx">     // Note: Alpha does not have the same restrictions as RGB.
</span><del>-    if (isContextLost() || !validateBlendFuncFactors(&quot;blendFunc&quot;, srcRGB, dstRGB))
</del><ins>+    if (isContextLostOrPending() || !validateBlendFuncFactors(&quot;blendFunc&quot;, srcRGB, dstRGB))
</ins><span class="cx">         return;
</span><span class="cx">     m_context-&gt;blendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha);
</span><span class="cx"> }
</span><span class="lines">@@ -1051,7 +1103,7 @@
</span><span class="cx"> void WebGLRenderingContext::bufferData(GC3Denum target, long long size, GC3Denum usage, ExceptionCode&amp; ec)
</span><span class="cx"> {
</span><span class="cx">     UNUSED_PARAM(ec);
</span><del>-    if (isContextLost())
</del><ins>+    if (isContextLostOrPending())
</ins><span class="cx">         return;
</span><span class="cx">     WebGLBuffer* buffer = validateBufferDataParameters(&quot;bufferData&quot;, target, usage);
</span><span class="cx">     if (!buffer)
</span><span class="lines">@@ -1077,7 +1129,7 @@
</span><span class="cx"> void WebGLRenderingContext::bufferData(GC3Denum target, ArrayBuffer* data, GC3Denum usage, ExceptionCode&amp; ec)
</span><span class="cx"> {
</span><span class="cx">     UNUSED_PARAM(ec);
</span><del>-    if (isContextLost())
</del><ins>+    if (isContextLostOrPending())
</ins><span class="cx">         return;
</span><span class="cx">     WebGLBuffer* buffer = validateBufferDataParameters(&quot;bufferData&quot;, target, usage);
</span><span class="cx">     if (!buffer)
</span><span class="lines">@@ -1099,7 +1151,7 @@
</span><span class="cx"> void WebGLRenderingContext::bufferData(GC3Denum target, ArrayBufferView* data, GC3Denum usage, ExceptionCode&amp; ec)
</span><span class="cx"> {
</span><span class="cx">     UNUSED_PARAM(ec);
</span><del>-    if (isContextLost())
</del><ins>+    if (isContextLostOrPending())
</ins><span class="cx">         return;
</span><span class="cx">     WebGLBuffer* buffer = validateBufferDataParameters(&quot;bufferData&quot;, target, usage);
</span><span class="cx">     if (!buffer)
</span><span class="lines">@@ -1121,7 +1173,7 @@
</span><span class="cx"> void WebGLRenderingContext::bufferSubData(GC3Denum target, long long offset, ArrayBuffer* data, ExceptionCode&amp; ec)
</span><span class="cx"> {
</span><span class="cx">     UNUSED_PARAM(ec);
</span><del>-    if (isContextLost())
</del><ins>+    if (isContextLostOrPending())
</ins><span class="cx">         return;
</span><span class="cx">     WebGLBuffer* buffer = validateBufferDataParameters(&quot;bufferSubData&quot;, target, GraphicsContext3D::STATIC_DRAW);
</span><span class="cx">     if (!buffer)
</span><span class="lines">@@ -1145,7 +1197,7 @@
</span><span class="cx"> void WebGLRenderingContext::bufferSubData(GC3Denum target, long long offset, ArrayBufferView* data, ExceptionCode&amp; ec)
</span><span class="cx"> {
</span><span class="cx">     UNUSED_PARAM(ec);
</span><del>-    if (isContextLost())
</del><ins>+    if (isContextLostOrPending())
</ins><span class="cx">         return;
</span><span class="cx">     WebGLBuffer* buffer = validateBufferDataParameters(&quot;bufferSubData&quot;, target, GraphicsContext3D::STATIC_DRAW);
</span><span class="cx">     if (!buffer)
</span><span class="lines">@@ -1168,7 +1220,7 @@
</span><span class="cx"> 
</span><span class="cx"> GC3Denum WebGLRenderingContext::checkFramebufferStatus(GC3Denum target)
</span><span class="cx"> {
</span><del>-    if (isContextLost())
</del><ins>+    if (isContextLostOrPending())
</ins><span class="cx">         return GraphicsContext3D::FRAMEBUFFER_UNSUPPORTED;
</span><span class="cx">     if (target != GraphicsContext3D::FRAMEBUFFER) {
</span><span class="cx">         synthesizeGLError(GraphicsContext3D::INVALID_ENUM, &quot;checkFramebufferStatus&quot;, &quot;invalid target&quot;);
</span><span class="lines">@@ -1188,7 +1240,7 @@
</span><span class="cx"> 
</span><span class="cx"> void WebGLRenderingContext::clear(GC3Dbitfield mask)
</span><span class="cx"> {
</span><del>-    if (isContextLost())
</del><ins>+    if (isContextLostOrPending())
</ins><span class="cx">         return;
</span><span class="cx">     if (mask &amp; ~(GraphicsContext3D::COLOR_BUFFER_BIT | GraphicsContext3D::DEPTH_BUFFER_BIT | GraphicsContext3D::STENCIL_BUFFER_BIT)) {
</span><span class="cx">         synthesizeGLError(GraphicsContext3D::INVALID_VALUE, &quot;clear&quot;, &quot;invalid mask&quot;);
</span><span class="lines">@@ -1206,7 +1258,7 @@
</span><span class="cx"> 
</span><span class="cx"> void WebGLRenderingContext::clearColor(GC3Dfloat r, GC3Dfloat g, GC3Dfloat b, GC3Dfloat a)
</span><span class="cx"> {
</span><del>-    if (isContextLost())
</del><ins>+    if (isContextLostOrPending())
</ins><span class="cx">         return;
</span><span class="cx">     if (std::isnan(r))
</span><span class="cx">         r = 0;
</span><span class="lines">@@ -1225,7 +1277,7 @@
</span><span class="cx"> 
</span><span class="cx"> void WebGLRenderingContext::clearDepth(GC3Dfloat depth)
</span><span class="cx"> {
</span><del>-    if (isContextLost())
</del><ins>+    if (isContextLostOrPending())
</ins><span class="cx">         return;
</span><span class="cx">     m_clearDepth = depth;
</span><span class="cx">     m_context-&gt;clearDepth(depth);
</span><span class="lines">@@ -1233,7 +1285,7 @@
</span><span class="cx"> 
</span><span class="cx"> void WebGLRenderingContext::clearStencil(GC3Dint s)
</span><span class="cx"> {
</span><del>-    if (isContextLost())
</del><ins>+    if (isContextLostOrPending())
</ins><span class="cx">         return;
</span><span class="cx">     m_clearStencil = s;
</span><span class="cx">     m_context-&gt;clearStencil(s);
</span><span class="lines">@@ -1241,7 +1293,7 @@
</span><span class="cx"> 
</span><span class="cx"> void WebGLRenderingContext::colorMask(GC3Dboolean red, GC3Dboolean green, GC3Dboolean blue, GC3Dboolean alpha)
</span><span class="cx"> {
</span><del>-    if (isContextLost())
</del><ins>+    if (isContextLostOrPending())
</ins><span class="cx">         return;
</span><span class="cx">     m_colorMask[0] = red;
</span><span class="cx">     m_colorMask[1] = green;
</span><span class="lines">@@ -1253,7 +1305,7 @@
</span><span class="cx"> void WebGLRenderingContext::compileShader(WebGLShader* shader, ExceptionCode&amp; ec)
</span><span class="cx"> {
</span><span class="cx">     UNUSED_PARAM(ec);
</span><del>-    if (isContextLost() || !validateWebGLObject(&quot;compileShader&quot;, shader))
</del><ins>+    if (isContextLostOrPending() || !validateWebGLObject(&quot;compileShader&quot;, shader))
</ins><span class="cx">         return;
</span><span class="cx">     m_context-&gt;compileShader(objectOrZero(shader));
</span><span class="cx">     GC3Dint value;
</span><span class="lines">@@ -1264,7 +1316,7 @@
</span><span class="cx"> void WebGLRenderingContext::compressedTexImage2D(GC3Denum target, GC3Dint level, GC3Denum internalformat, GC3Dsizei width,
</span><span class="cx">                                                  GC3Dsizei height, GC3Dint border, ArrayBufferView* data)
</span><span class="cx"> {
</span><del>-    if (isContextLost())
</del><ins>+    if (isContextLostOrPending())
</ins><span class="cx">         return;
</span><span class="cx">     if (!validateTexFuncLevel(&quot;compressedTexImage2D&quot;, target, level))
</span><span class="cx">         return;
</span><span class="lines">@@ -1300,7 +1352,7 @@
</span><span class="cx"> void WebGLRenderingContext::compressedTexSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset,
</span><span class="cx">                                                     GC3Dsizei width, GC3Dsizei height, GC3Denum format, ArrayBufferView* data)
</span><span class="cx"> {
</span><del>-    if (isContextLost())
</del><ins>+    if (isContextLostOrPending())
</ins><span class="cx">         return;
</span><span class="cx">     if (!validateTexFuncLevel(&quot;compressedTexSubImage2D&quot;, target, level))
</span><span class="cx">         return;
</span><span class="lines">@@ -1339,7 +1391,7 @@
</span><span class="cx"> 
</span><span class="cx"> void WebGLRenderingContext::copyTexImage2D(GC3Denum target, GC3Dint level, GC3Denum internalformat, GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei height, GC3Dint border)
</span><span class="cx"> {
</span><del>-    if (isContextLost())
</del><ins>+    if (isContextLostOrPending())
</ins><span class="cx">         return;
</span><span class="cx">     if (!validateTexFuncParameters(&quot;copyTexImage2D&quot;, NotTexSubImage2D, target, level, internalformat, width, height, border, internalformat, GraphicsContext3D::UNSIGNED_BYTE))
</span><span class="cx">         return;
</span><span class="lines">@@ -1385,7 +1437,7 @@
</span><span class="cx"> 
</span><span class="cx"> void WebGLRenderingContext::copyTexSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei height)
</span><span class="cx"> {
</span><del>-    if (isContextLost())
</del><ins>+    if (isContextLostOrPending())
</ins><span class="cx">         return;
</span><span class="cx">     if (!validateTexFuncLevel(&quot;copyTexSubImage2D&quot;, target, level))
</span><span class="cx">         return;
</span><span class="lines">@@ -1455,7 +1507,7 @@
</span><span class="cx"> 
</span><span class="cx"> PassRefPtr&lt;WebGLBuffer&gt; WebGLRenderingContext::createBuffer()
</span><span class="cx"> {
</span><del>-    if (isContextLost())
</del><ins>+    if (isContextLostOrPending())
</ins><span class="cx">         return 0;
</span><span class="cx">     RefPtr&lt;WebGLBuffer&gt; o = WebGLBuffer::create(this);
</span><span class="cx">     addSharedObject(o.get());
</span><span class="lines">@@ -1464,7 +1516,7 @@
</span><span class="cx"> 
</span><span class="cx"> PassRefPtr&lt;WebGLFramebuffer&gt; WebGLRenderingContext::createFramebuffer()
</span><span class="cx"> {
</span><del>-    if (isContextLost())
</del><ins>+    if (isContextLostOrPending())
</ins><span class="cx">         return 0;
</span><span class="cx">     RefPtr&lt;WebGLFramebuffer&gt; o = WebGLFramebuffer::create(this);
</span><span class="cx">     addContextObject(o.get());
</span><span class="lines">@@ -1473,7 +1525,7 @@
</span><span class="cx"> 
</span><span class="cx"> PassRefPtr&lt;WebGLTexture&gt; WebGLRenderingContext::createTexture()
</span><span class="cx"> {
</span><del>-    if (isContextLost())
</del><ins>+    if (isContextLostOrPending())
</ins><span class="cx">         return 0;
</span><span class="cx">     RefPtr&lt;WebGLTexture&gt; o = WebGLTexture::create(this);
</span><span class="cx">     addSharedObject(o.get());
</span><span class="lines">@@ -1482,7 +1534,7 @@
</span><span class="cx"> 
</span><span class="cx"> PassRefPtr&lt;WebGLProgram&gt; WebGLRenderingContext::createProgram()
</span><span class="cx"> {
</span><del>-    if (isContextLost())
</del><ins>+    if (isContextLostOrPending())
</ins><span class="cx">         return 0;
</span><span class="cx">     RefPtr&lt;WebGLProgram&gt; o = WebGLProgram::create(this);
</span><span class="cx">     addSharedObject(o.get());
</span><span class="lines">@@ -1491,7 +1543,7 @@
</span><span class="cx"> 
</span><span class="cx"> PassRefPtr&lt;WebGLRenderbuffer&gt; WebGLRenderingContext::createRenderbuffer()
</span><span class="cx"> {
</span><del>-    if (isContextLost())
</del><ins>+    if (isContextLostOrPending())
</ins><span class="cx">         return 0;
</span><span class="cx">     RefPtr&lt;WebGLRenderbuffer&gt; o = WebGLRenderbuffer::create(this);
</span><span class="cx">     addSharedObject(o.get());
</span><span class="lines">@@ -1501,7 +1553,7 @@
</span><span class="cx"> PassRefPtr&lt;WebGLShader&gt; WebGLRenderingContext::createShader(GC3Denum type, ExceptionCode&amp; ec)
</span><span class="cx"> {
</span><span class="cx">     UNUSED_PARAM(ec);
</span><del>-    if (isContextLost())
</del><ins>+    if (isContextLostOrPending())
</ins><span class="cx">         return 0;
</span><span class="cx">     if (type != GraphicsContext3D::VERTEX_SHADER &amp;&amp; type != GraphicsContext3D::FRAGMENT_SHADER) {
</span><span class="cx">         synthesizeGLError(GraphicsContext3D::INVALID_ENUM, &quot;createShader&quot;, &quot;invalid shader type&quot;);
</span><span class="lines">@@ -1515,14 +1567,14 @@
</span><span class="cx"> 
</span><span class="cx"> void WebGLRenderingContext::cullFace(GC3Denum mode)
</span><span class="cx"> {
</span><del>-    if (isContextLost())
</del><ins>+    if (isContextLostOrPending())
</ins><span class="cx">         return;
</span><span class="cx">     m_context-&gt;cullFace(mode);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> bool WebGLRenderingContext::deleteObject(WebGLObject* object)
</span><span class="cx"> {
</span><del>-    if (isContextLost() || !object)
</del><ins>+    if (isContextLostOrPending() || !object)
</ins><span class="cx">         return false;
</span><span class="cx">     if (!object-&gt;validate(contextGroup(), this)) {
</span><span class="cx">         synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, &quot;delete&quot;, &quot;object does not belong to this context&quot;);
</span><span class="lines">@@ -1598,14 +1650,14 @@
</span><span class="cx"> 
</span><span class="cx"> void WebGLRenderingContext::depthFunc(GC3Denum func)
</span><span class="cx"> {
</span><del>-    if (isContextLost())
</del><ins>+    if (isContextLostOrPending())
</ins><span class="cx">         return;
</span><span class="cx">     m_context-&gt;depthFunc(func);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebGLRenderingContext::depthMask(GC3Dboolean flag)
</span><span class="cx"> {
</span><del>-    if (isContextLost())
</del><ins>+    if (isContextLostOrPending())
</ins><span class="cx">         return;
</span><span class="cx">     m_depthMask = flag;
</span><span class="cx">     m_context-&gt;depthMask(flag);
</span><span class="lines">@@ -1613,7 +1665,7 @@
</span><span class="cx"> 
</span><span class="cx"> void WebGLRenderingContext::depthRange(GC3Dfloat zNear, GC3Dfloat zFar)
</span><span class="cx"> {
</span><del>-    if (isContextLost())
</del><ins>+    if (isContextLostOrPending())
</ins><span class="cx">         return;
</span><span class="cx">     if (zNear &gt; zFar) {
</span><span class="cx">         synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, &quot;depthRange&quot;, &quot;zNear &gt; zFar&quot;);
</span><span class="lines">@@ -1625,7 +1677,7 @@
</span><span class="cx"> void WebGLRenderingContext::detachShader(WebGLProgram* program, WebGLShader* shader, ExceptionCode&amp; ec)
</span><span class="cx"> {
</span><span class="cx">     UNUSED_PARAM(ec);
</span><del>-    if (isContextLost() || !validateWebGLObject(&quot;detachShader&quot;, program) || !validateWebGLObject(&quot;detachShader&quot;, shader))
</del><ins>+    if (isContextLostOrPending() || !validateWebGLObject(&quot;detachShader&quot;, program) || !validateWebGLObject(&quot;detachShader&quot;, shader))
</ins><span class="cx">         return;
</span><span class="cx">     if (!program-&gt;detachShader(shader)) {
</span><span class="cx">         synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, &quot;detachShader&quot;, &quot;shader not attached&quot;);
</span><span class="lines">@@ -1637,7 +1689,7 @@
</span><span class="cx"> 
</span><span class="cx"> void WebGLRenderingContext::disable(GC3Denum cap)
</span><span class="cx"> {
</span><del>-    if (isContextLost() || !validateCapability(&quot;disable&quot;, cap))
</del><ins>+    if (isContextLostOrPending() || !validateCapability(&quot;disable&quot;, cap))
</ins><span class="cx">         return;
</span><span class="cx">     if (cap == GraphicsContext3D::STENCIL_TEST) {
</span><span class="cx">         m_stencilEnabled = false;
</span><span class="lines">@@ -1655,7 +1707,7 @@
</span><span class="cx"> void WebGLRenderingContext::disableVertexAttribArray(GC3Duint index, ExceptionCode&amp; ec)
</span><span class="cx"> {
</span><span class="cx">     UNUSED_PARAM(ec);
</span><del>-    if (isContextLost())
</del><ins>+    if (isContextLostOrPending())
</ins><span class="cx">         return;
</span><span class="cx">     if (index &gt;= m_maxVertexAttribs) {
</span><span class="cx">         synthesizeGLError(GraphicsContext3D::INVALID_VALUE, &quot;disableVertexAttribArray&quot;, &quot;index out of range&quot;);
</span><span class="lines">@@ -1886,7 +1938,7 @@
</span><span class="cx"> 
</span><span class="cx"> bool WebGLRenderingContext::validateDrawArrays(const char* functionName, GC3Denum mode, GC3Dint first, GC3Dsizei count, GC3Dsizei primcount)
</span><span class="cx"> {
</span><del>-    if (isContextLost() || !validateDrawMode(functionName, mode))
</del><ins>+    if (isContextLostOrPending() || !validateDrawMode(functionName, mode))
</ins><span class="cx">         return false;
</span><span class="cx"> 
</span><span class="cx">     if (!validateStencilSettings(functionName))
</span><span class="lines">@@ -1957,7 +2009,7 @@
</span><span class="cx"> 
</span><span class="cx"> bool WebGLRenderingContext::validateDrawElements(const char* functionName, GC3Denum mode, GC3Dsizei count, GC3Denum type, long long offset, unsigned&amp; numElements)
</span><span class="cx"> {
</span><del>-    if (isContextLost() || !validateDrawMode(functionName, mode))
</del><ins>+    if (isContextLostOrPending() || !validateDrawMode(functionName, mode))
</ins><span class="cx">         return false;
</span><span class="cx"> 
</span><span class="cx">     if (!validateStencilSettings(functionName))
</span><span class="lines">@@ -2050,7 +2102,7 @@
</span><span class="cx"> 
</span><span class="cx"> void WebGLRenderingContext::enable(GC3Denum cap)
</span><span class="cx"> {
</span><del>-    if (isContextLost() || !validateCapability(&quot;enable&quot;, cap))
</del><ins>+    if (isContextLostOrPending() || !validateCapability(&quot;enable&quot;, cap))
</ins><span class="cx">         return;
</span><span class="cx">     if (cap == GraphicsContext3D::STENCIL_TEST) {
</span><span class="cx">         m_stencilEnabled = true;
</span><span class="lines">@@ -2068,7 +2120,7 @@
</span><span class="cx"> void WebGLRenderingContext::enableVertexAttribArray(GC3Duint index, ExceptionCode&amp; ec)
</span><span class="cx"> {
</span><span class="cx">     UNUSED_PARAM(ec);
</span><del>-    if (isContextLost())
</del><ins>+    if (isContextLostOrPending())
</ins><span class="cx">         return;
</span><span class="cx">     if (index &gt;= m_maxVertexAttribs) {
</span><span class="cx">         synthesizeGLError(GraphicsContext3D::INVALID_VALUE, &quot;enableVertexAttribArray&quot;, &quot;index out of range&quot;);
</span><span class="lines">@@ -2083,14 +2135,14 @@
</span><span class="cx"> 
</span><span class="cx"> void WebGLRenderingContext::finish()
</span><span class="cx"> {
</span><del>-    if (isContextLost())
</del><ins>+    if (isContextLostOrPending())
</ins><span class="cx">         return;
</span><span class="cx">     m_context-&gt;finish();
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebGLRenderingContext::flush()
</span><span class="cx"> {
</span><del>-    if (isContextLost())
</del><ins>+    if (isContextLostOrPending())
</ins><span class="cx">         return;
</span><span class="cx">     m_context-&gt;flush();
</span><span class="cx"> }
</span><span class="lines">@@ -2098,7 +2150,7 @@
</span><span class="cx"> void WebGLRenderingContext::framebufferRenderbuffer(GC3Denum target, GC3Denum attachment, GC3Denum renderbuffertarget, WebGLRenderbuffer* buffer, ExceptionCode&amp; ec)
</span><span class="cx"> {
</span><span class="cx">     UNUSED_PARAM(ec);
</span><del>-    if (isContextLost() || !validateFramebufferFuncParameters(&quot;framebufferRenderbuffer&quot;, target, attachment))
</del><ins>+    if (isContextLostOrPending() || !validateFramebufferFuncParameters(&quot;framebufferRenderbuffer&quot;, target, attachment))
</ins><span class="cx">         return;
</span><span class="cx">     if (renderbuffertarget != GraphicsContext3D::RENDERBUFFER) {
</span><span class="cx">         synthesizeGLError(GraphicsContext3D::INVALID_ENUM, &quot;framebufferRenderbuffer&quot;, &quot;invalid target&quot;);
</span><span class="lines">@@ -2131,7 +2183,7 @@
</span><span class="cx"> void WebGLRenderingContext::framebufferTexture2D(GC3Denum target, GC3Denum attachment, GC3Denum textarget, WebGLTexture* texture, GC3Dint level, ExceptionCode&amp; ec)
</span><span class="cx"> {
</span><span class="cx">     UNUSED_PARAM(ec);
</span><del>-    if (isContextLost() || !validateFramebufferFuncParameters(&quot;framebufferTexture2D&quot;, target, attachment))
</del><ins>+    if (isContextLostOrPending() || !validateFramebufferFuncParameters(&quot;framebufferTexture2D&quot;, target, attachment))
</ins><span class="cx">         return;
</span><span class="cx">     if (level) {
</span><span class="cx">         synthesizeGLError(GraphicsContext3D::INVALID_VALUE, &quot;framebufferTexture2D&quot;, &quot;level not 0&quot;);
</span><span class="lines">@@ -2169,14 +2221,14 @@
</span><span class="cx"> 
</span><span class="cx"> void WebGLRenderingContext::frontFace(GC3Denum mode)
</span><span class="cx"> {
</span><del>-    if (isContextLost())
</del><ins>+    if (isContextLostOrPending())
</ins><span class="cx">         return;
</span><span class="cx">     m_context-&gt;frontFace(mode);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebGLRenderingContext::generateMipmap(GC3Denum target)
</span><span class="cx"> {
</span><del>-    if (isContextLost())
</del><ins>+    if (isContextLostOrPending())
</ins><span class="cx">         return;
</span><span class="cx">     WebGLTexture* tex = validateTextureBinding(&quot;generateMipmap&quot;, target, false);
</span><span class="cx">     if (!tex)
</span><span class="lines">@@ -2213,7 +2265,7 @@
</span><span class="cx"> PassRefPtr&lt;WebGLActiveInfo&gt; WebGLRenderingContext::getActiveAttrib(WebGLProgram* program, GC3Duint index, ExceptionCode&amp; ec)
</span><span class="cx"> {
</span><span class="cx">     UNUSED_PARAM(ec);
</span><del>-    if (isContextLost() || !validateWebGLObject(&quot;getActiveAttrib&quot;, program))
</del><ins>+    if (isContextLostOrPending() || !validateWebGLObject(&quot;getActiveAttrib&quot;, program))
</ins><span class="cx">         return 0;
</span><span class="cx">     ActiveInfo info;
</span><span class="cx">     if (!m_context-&gt;getActiveAttrib(objectOrZero(program), index, info))
</span><span class="lines">@@ -2227,7 +2279,7 @@
</span><span class="cx"> PassRefPtr&lt;WebGLActiveInfo&gt; WebGLRenderingContext::getActiveUniform(WebGLProgram* program, GC3Duint index, ExceptionCode&amp; ec)
</span><span class="cx"> {
</span><span class="cx">     UNUSED_PARAM(ec);
</span><del>-    if (isContextLost() || !validateWebGLObject(&quot;getActiveUniform&quot;, program))
</del><ins>+    if (isContextLostOrPending() || !validateWebGLObject(&quot;getActiveUniform&quot;, program))
</ins><span class="cx">         return 0;
</span><span class="cx">     ActiveInfo info;
</span><span class="cx">     if (!m_context-&gt;getActiveUniform(objectOrZero(program), index, info))
</span><span class="lines">@@ -2245,7 +2297,7 @@
</span><span class="cx"> {
</span><span class="cx">     UNUSED_PARAM(ec);
</span><span class="cx">     shaderObjects.clear();
</span><del>-    if (isContextLost() || !validateWebGLObject(&quot;getAttachedShaders&quot;, program))
</del><ins>+    if (isContextLostOrPending() || !validateWebGLObject(&quot;getAttachedShaders&quot;, program))
</ins><span class="cx">         return false;
</span><span class="cx"> 
</span><span class="cx">     const GC3Denum shaderType[] = {
</span><span class="lines">@@ -2262,7 +2314,7 @@
</span><span class="cx"> 
</span><span class="cx"> GC3Dint WebGLRenderingContext::getAttribLocation(WebGLProgram* program, const String&amp; name)
</span><span class="cx"> {
</span><del>-    if (isContextLost() || !validateWebGLObject(&quot;getAttribLocation&quot;, program))
</del><ins>+    if (isContextLostOrPending() || !validateWebGLObject(&quot;getAttribLocation&quot;, program))
</ins><span class="cx">         return -1;
</span><span class="cx">     if (!validateLocationLength(&quot;getAttribLocation&quot;, name))
</span><span class="cx">         return -1;
</span><span class="lines">@@ -2280,7 +2332,7 @@
</span><span class="cx"> WebGLGetInfo WebGLRenderingContext::getBufferParameter(GC3Denum target, GC3Denum pname, ExceptionCode&amp; ec)
</span><span class="cx"> {
</span><span class="cx">     UNUSED_PARAM(ec);
</span><del>-    if (isContextLost())
</del><ins>+    if (isContextLostOrPending())
</ins><span class="cx">         return WebGLGetInfo();
</span><span class="cx">     if (target != GraphicsContext3D::ARRAY_BUFFER &amp;&amp; target != GraphicsContext3D::ELEMENT_ARRAY_BUFFER) {
</span><span class="cx">         synthesizeGLError(GraphicsContext3D::INVALID_ENUM, &quot;getBufferParameter&quot;, &quot;invalid target&quot;);
</span><span class="lines">@@ -2301,7 +2353,7 @@
</span><span class="cx"> 
</span><span class="cx"> PassRefPtr&lt;WebGLContextAttributes&gt; WebGLRenderingContext::getContextAttributes()
</span><span class="cx"> {
</span><del>-    if (isContextLost())
</del><ins>+    if (isContextLostOrPending())
</ins><span class="cx">         return 0;
</span><span class="cx">     // We always need to return a new WebGLContextAttributes object to
</span><span class="cx">     // prevent the user from mutating any cached version.
</span><span class="lines">@@ -2329,7 +2381,7 @@
</span><span class="cx"> 
</span><span class="cx"> WebGLExtension* WebGLRenderingContext::getExtension(const String&amp; name)
</span><span class="cx"> {
</span><del>-    if (isContextLost())
</del><ins>+    if (isContextLostOrPending())
</ins><span class="cx">         return 0;
</span><span class="cx"> 
</span><span class="cx">     if (equalIgnoringCase(name, &quot;WEBKIT_EXT_texture_filter_anisotropic&quot;)
</span><span class="lines">@@ -2460,7 +2512,7 @@
</span><span class="cx"> WebGLGetInfo WebGLRenderingContext::getFramebufferAttachmentParameter(GC3Denum target, GC3Denum attachment, GC3Denum pname, ExceptionCode&amp; ec)
</span><span class="cx"> {
</span><span class="cx">     UNUSED_PARAM(ec);
</span><del>-    if (isContextLost() || !validateFramebufferFuncParameters(&quot;getFramebufferAttachmentParameter&quot;, target, attachment))
</del><ins>+    if (isContextLostOrPending() || !validateFramebufferFuncParameters(&quot;getFramebufferAttachmentParameter&quot;, target, attachment))
</ins><span class="cx">         return WebGLGetInfo();
</span><span class="cx"> 
</span><span class="cx">     if (!m_framebufferBinding || !m_framebufferBinding-&gt;object()) {
</span><span class="lines">@@ -2512,7 +2564,7 @@
</span><span class="cx"> WebGLGetInfo WebGLRenderingContext::getParameter(GC3Denum pname, ExceptionCode&amp; ec)
</span><span class="cx"> {
</span><span class="cx">     UNUSED_PARAM(ec);
</span><del>-    if (isContextLost())
</del><ins>+    if (isContextLostOrPending())
</ins><span class="cx">         return WebGLGetInfo();
</span><span class="cx">     const int intZero = 0;
</span><span class="cx">     switch (pname) {
</span><span class="lines">@@ -2750,7 +2802,7 @@
</span><span class="cx"> WebGLGetInfo WebGLRenderingContext::getProgramParameter(WebGLProgram* program, GC3Denum pname, ExceptionCode&amp; ec)
</span><span class="cx"> {
</span><span class="cx">     UNUSED_PARAM(ec);
</span><del>-    if (isContextLost() || !validateWebGLObject(&quot;getProgramParameter&quot;, program))
</del><ins>+    if (isContextLostOrPending() || !validateWebGLObject(&quot;getProgramParameter&quot;, program))
</ins><span class="cx">         return WebGLGetInfo();
</span><span class="cx"> 
</span><span class="cx">     GC3Dint value = 0;
</span><span class="lines">@@ -2778,7 +2830,7 @@
</span><span class="cx"> String WebGLRenderingContext::getProgramInfoLog(WebGLProgram* program, ExceptionCode&amp; ec)
</span><span class="cx"> {
</span><span class="cx">     UNUSED_PARAM(ec);
</span><del>-    if (isContextLost())
</del><ins>+    if (isContextLostOrPending())
</ins><span class="cx">         return String();
</span><span class="cx">     if (!validateWebGLObject(&quot;getProgramInfoLog&quot;, program))
</span><span class="cx">         return &quot;&quot;;
</span><span class="lines">@@ -2788,7 +2840,7 @@
</span><span class="cx"> WebGLGetInfo WebGLRenderingContext::getRenderbufferParameter(GC3Denum target, GC3Denum pname, ExceptionCode&amp; ec)
</span><span class="cx"> {
</span><span class="cx">     UNUSED_PARAM(ec);
</span><del>-    if (isContextLost())
</del><ins>+    if (isContextLostOrPending())
</ins><span class="cx">         return WebGLGetInfo();
</span><span class="cx">     if (target != GraphicsContext3D::RENDERBUFFER) {
</span><span class="cx">         synthesizeGLError(GraphicsContext3D::INVALID_ENUM, &quot;getRenderbufferParameter&quot;, &quot;invalid target&quot;);
</span><span class="lines">@@ -2854,7 +2906,7 @@
</span><span class="cx"> WebGLGetInfo WebGLRenderingContext::getShaderParameter(WebGLShader* shader, GC3Denum pname, ExceptionCode&amp; ec)
</span><span class="cx"> {
</span><span class="cx">     UNUSED_PARAM(ec);
</span><del>-    if (isContextLost() || !validateWebGLObject(&quot;getShaderParameter&quot;, shader))
</del><ins>+    if (isContextLostOrPending() || !validateWebGLObject(&quot;getShaderParameter&quot;, shader))
</ins><span class="cx">         return WebGLGetInfo();
</span><span class="cx">     GC3Dint value = 0;
</span><span class="cx">     switch (pname) {
</span><span class="lines">@@ -2875,7 +2927,7 @@
</span><span class="cx"> String WebGLRenderingContext::getShaderInfoLog(WebGLShader* shader, ExceptionCode&amp; ec)
</span><span class="cx"> {
</span><span class="cx">     UNUSED_PARAM(ec);
</span><del>-    if (isContextLost())
</del><ins>+    if (isContextLostOrPending())
</ins><span class="cx">         return String();
</span><span class="cx">     if (!validateWebGLObject(&quot;getShaderInfoLog&quot;, shader))
</span><span class="cx">         return &quot;&quot;;
</span><span class="lines">@@ -2885,7 +2937,7 @@
</span><span class="cx"> PassRefPtr&lt;WebGLShaderPrecisionFormat&gt; WebGLRenderingContext::getShaderPrecisionFormat(GC3Denum shaderType, GC3Denum precisionType, ExceptionCode&amp; ec)
</span><span class="cx"> {
</span><span class="cx">     UNUSED_PARAM(ec);
</span><del>-    if (isContextLost())
</del><ins>+    if (isContextLostOrPending())
</ins><span class="cx">         return 0;
</span><span class="cx">     switch (shaderType) {
</span><span class="cx">     case GraphicsContext3D::VERTEX_SHADER:
</span><span class="lines">@@ -2917,7 +2969,7 @@
</span><span class="cx"> String WebGLRenderingContext::getShaderSource(WebGLShader* shader, ExceptionCode&amp; ec)
</span><span class="cx"> {
</span><span class="cx">     UNUSED_PARAM(ec);
</span><del>-    if (isContextLost())
</del><ins>+    if (isContextLostOrPending())
</ins><span class="cx">         return String();
</span><span class="cx">     if (!validateWebGLObject(&quot;getShaderSource&quot;, shader))
</span><span class="cx">         return &quot;&quot;;
</span><span class="lines">@@ -2969,7 +3021,7 @@
</span><span class="cx"> WebGLGetInfo WebGLRenderingContext::getTexParameter(GC3Denum target, GC3Denum pname, ExceptionCode&amp; ec)
</span><span class="cx"> {
</span><span class="cx">     UNUSED_PARAM(ec);
</span><del>-    if (isContextLost())
</del><ins>+    if (isContextLostOrPending())
</ins><span class="cx">         return WebGLGetInfo();
</span><span class="cx">     WebGLTexture* tex = validateTextureBinding(&quot;getTexParameter&quot;, target, false);
</span><span class="cx">     if (!tex)
</span><span class="lines">@@ -2998,7 +3050,7 @@
</span><span class="cx"> WebGLGetInfo WebGLRenderingContext::getUniform(WebGLProgram* program, const WebGLUniformLocation* uniformLocation, ExceptionCode&amp; ec)
</span><span class="cx"> {
</span><span class="cx">     UNUSED_PARAM(ec);
</span><del>-    if (isContextLost() || !validateWebGLObject(&quot;getUniform&quot;, program))
</del><ins>+    if (isContextLostOrPending() || !validateWebGLObject(&quot;getUniform&quot;, program))
</ins><span class="cx">         return WebGLGetInfo();
</span><span class="cx">     if (!uniformLocation || uniformLocation-&gt;program() != program) {
</span><span class="cx">         synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, &quot;getUniform&quot;, &quot;no uniformlocation or not valid for this program&quot;);
</span><span class="lines">@@ -3126,7 +3178,7 @@
</span><span class="cx"> PassRefPtr&lt;WebGLUniformLocation&gt; WebGLRenderingContext::getUniformLocation(WebGLProgram* program, const String&amp; name, ExceptionCode&amp; ec)
</span><span class="cx"> {
</span><span class="cx">     UNUSED_PARAM(ec);
</span><del>-    if (isContextLost() || !validateWebGLObject(&quot;getUniformLocation&quot;, program))
</del><ins>+    if (isContextLostOrPending() || !validateWebGLObject(&quot;getUniformLocation&quot;, program))
</ins><span class="cx">         return nullptr;
</span><span class="cx">     if (!validateLocationLength(&quot;getUniformLocation&quot;, name))
</span><span class="cx">         return nullptr;
</span><span class="lines">@@ -3166,7 +3218,7 @@
</span><span class="cx"> {
</span><span class="cx">     UNUSED_PARAM(ec);
</span><span class="cx"> 
</span><del>-    if (isContextLost())
</del><ins>+    if (isContextLostOrPending())
</ins><span class="cx">         return WebGLGetInfo();
</span><span class="cx"> 
</span><span class="cx">     if (index &gt;= m_maxVertexAttribs) {
</span><span class="lines">@@ -3206,7 +3258,7 @@
</span><span class="cx"> 
</span><span class="cx"> long long WebGLRenderingContext::getVertexAttribOffset(GC3Duint index, GC3Denum pname)
</span><span class="cx"> {
</span><del>-    if (isContextLost())
</del><ins>+    if (isContextLostOrPending())
</ins><span class="cx">         return 0;
</span><span class="cx">     GC3Dsizeiptr result = m_context-&gt;getVertexAttribOffset(index, pname);
</span><span class="cx">     return static_cast&lt;long long&gt;(result);
</span><span class="lines">@@ -3214,7 +3266,7 @@
</span><span class="cx"> 
</span><span class="cx"> void WebGLRenderingContext::hint(GC3Denum target, GC3Denum mode)
</span><span class="cx"> {
</span><del>-    if (isContextLost())
</del><ins>+    if (isContextLostOrPending())
</ins><span class="cx">         return;
</span><span class="cx">     bool isValid = false;
</span><span class="cx">     switch (target) {
</span><span class="lines">@@ -3235,7 +3287,7 @@
</span><span class="cx"> 
</span><span class="cx"> GC3Dboolean WebGLRenderingContext::isBuffer(WebGLBuffer* buffer)
</span><span class="cx"> {
</span><del>-    if (!buffer || isContextLost())
</del><ins>+    if (!buffer || isContextLostOrPending())
</ins><span class="cx">         return 0;
</span><span class="cx"> 
</span><span class="cx">     if (!buffer-&gt;hasEverBeenBound())
</span><span class="lines">@@ -3249,9 +3301,27 @@
</span><span class="cx">     return m_contextLost;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+bool WebGLRenderingContext::isContextLostOrPending()
+{
+    if (m_isPendingPolicyResolution &amp;&amp; !m_hasRequestedPolicyResolution) {
+        LOG(WebGL, &quot;Context is being used. Attempt to resolve the policy.&quot;);
+        Document&amp; document = canvas()-&gt;document().topDocument();
+        Page* page = document.page();
+        if (page &amp;&amp; !document.url().isLocalFile())
+            page-&gt;mainFrame().loader().client().resolveWebGLPolicyForURL(document.url());
+        // FIXME: We don't currently do anything with the result from resolution. A more
+        // complete implementation might try to construct a real context, etc and proceed
+        // with normal operation.
+        // https://bugs.webkit.org/show_bug.cgi?id=129122
+        m_hasRequestedPolicyResolution = true;
+    }
+
+    return m_contextLost || m_isPendingPolicyResolution;
+}
+
</ins><span class="cx"> GC3Dboolean WebGLRenderingContext::isEnabled(GC3Denum cap)
</span><span class="cx"> {
</span><del>-    if (isContextLost() || !validateCapability(&quot;isEnabled&quot;, cap))
</del><ins>+    if (isContextLostOrPending() || !validateCapability(&quot;isEnabled&quot;, cap))
</ins><span class="cx">         return 0;
</span><span class="cx">     if (cap == GraphicsContext3D::STENCIL_TEST)
</span><span class="cx">         return m_stencilEnabled;
</span><span class="lines">@@ -3260,7 +3330,7 @@
</span><span class="cx"> 
</span><span class="cx"> GC3Dboolean WebGLRenderingContext::isFramebuffer(WebGLFramebuffer* framebuffer)
</span><span class="cx"> {
</span><del>-    if (!framebuffer || isContextLost())
</del><ins>+    if (!framebuffer || isContextLostOrPending())
</ins><span class="cx">         return 0;
</span><span class="cx"> 
</span><span class="cx">     if (!framebuffer-&gt;hasEverBeenBound())
</span><span class="lines">@@ -3271,7 +3341,7 @@
</span><span class="cx"> 
</span><span class="cx"> GC3Dboolean WebGLRenderingContext::isProgram(WebGLProgram* program)
</span><span class="cx"> {
</span><del>-    if (!program || isContextLost())
</del><ins>+    if (!program || isContextLostOrPending())
</ins><span class="cx">         return 0;
</span><span class="cx"> 
</span><span class="cx">     return m_context-&gt;isProgram(program-&gt;object());
</span><span class="lines">@@ -3279,7 +3349,7 @@
</span><span class="cx"> 
</span><span class="cx"> GC3Dboolean WebGLRenderingContext::isRenderbuffer(WebGLRenderbuffer* renderbuffer)
</span><span class="cx"> {
</span><del>-    if (!renderbuffer || isContextLost())
</del><ins>+    if (!renderbuffer || isContextLostOrPending())
</ins><span class="cx">         return 0;
</span><span class="cx"> 
</span><span class="cx">     if (!renderbuffer-&gt;hasEverBeenBound())
</span><span class="lines">@@ -3290,7 +3360,7 @@
</span><span class="cx"> 
</span><span class="cx"> GC3Dboolean WebGLRenderingContext::isShader(WebGLShader* shader)
</span><span class="cx"> {
</span><del>-    if (!shader || isContextLost())
</del><ins>+    if (!shader || isContextLostOrPending())
</ins><span class="cx">         return 0;
</span><span class="cx"> 
</span><span class="cx">     return m_context-&gt;isShader(shader-&gt;object());
</span><span class="lines">@@ -3298,7 +3368,7 @@
</span><span class="cx"> 
</span><span class="cx"> GC3Dboolean WebGLRenderingContext::isTexture(WebGLTexture* texture)
</span><span class="cx"> {
</span><del>-    if (!texture || isContextLost())
</del><ins>+    if (!texture || isContextLostOrPending())
</ins><span class="cx">         return 0;
</span><span class="cx"> 
</span><span class="cx">     if (!texture-&gt;hasEverBeenBound())
</span><span class="lines">@@ -3309,7 +3379,7 @@
</span><span class="cx"> 
</span><span class="cx"> void WebGLRenderingContext::lineWidth(GC3Dfloat width)
</span><span class="cx"> {
</span><del>-    if (isContextLost())
</del><ins>+    if (isContextLostOrPending())
</ins><span class="cx">         return;
</span><span class="cx">     m_context-&gt;lineWidth(width);
</span><span class="cx"> }
</span><span class="lines">@@ -3317,7 +3387,7 @@
</span><span class="cx"> void WebGLRenderingContext::linkProgram(WebGLProgram* program, ExceptionCode&amp; ec)
</span><span class="cx"> {
</span><span class="cx">     UNUSED_PARAM(ec);
</span><del>-    if (isContextLost() || !validateWebGLObject(&quot;linkProgram&quot;, program))
</del><ins>+    if (isContextLostOrPending() || !validateWebGLObject(&quot;linkProgram&quot;, program))
</ins><span class="cx">         return;
</span><span class="cx">     if (!isGLES2Compliant()) {
</span><span class="cx">         WebGLShader* vertexShader = program-&gt;getAttachedShader(GraphicsContext3D::VERTEX_SHADER);
</span><span class="lines">@@ -3334,7 +3404,7 @@
</span><span class="cx"> 
</span><span class="cx"> void WebGLRenderingContext::pixelStorei(GC3Denum pname, GC3Dint param)
</span><span class="cx"> {
</span><del>-    if (isContextLost())
</del><ins>+    if (isContextLostOrPending())
</ins><span class="cx">         return;
</span><span class="cx">     switch (pname) {
</span><span class="cx">     case GraphicsContext3D::UNPACK_FLIP_Y_WEBGL:
</span><span class="lines">@@ -3372,14 +3442,14 @@
</span><span class="cx"> 
</span><span class="cx"> void WebGLRenderingContext::polygonOffset(GC3Dfloat factor, GC3Dfloat units)
</span><span class="cx"> {
</span><del>-    if (isContextLost())
</del><ins>+    if (isContextLostOrPending())
</ins><span class="cx">         return;
</span><span class="cx">     m_context-&gt;polygonOffset(factor, units);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebGLRenderingContext::readPixels(GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei height, GC3Denum format, GC3Denum type, ArrayBufferView* pixels, ExceptionCode&amp;)
</span><span class="cx"> {
</span><del>-    if (isContextLost())
</del><ins>+    if (isContextLostOrPending())
</ins><span class="cx">         return;
</span><span class="cx">     // Due to WebGL's same-origin restrictions, it is not possible to
</span><span class="cx">     // taint the origin using the WebGL API.
</span><span class="lines">@@ -3469,14 +3539,14 @@
</span><span class="cx"> 
</span><span class="cx"> void WebGLRenderingContext::releaseShaderCompiler()
</span><span class="cx"> {
</span><del>-    if (isContextLost())
</del><ins>+    if (isContextLostOrPending())
</ins><span class="cx">         return;
</span><span class="cx">     m_context-&gt;releaseShaderCompiler();
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebGLRenderingContext::renderbufferStorage(GC3Denum target, GC3Denum internalformat, GC3Dsizei width, GC3Dsizei height)
</span><span class="cx"> {
</span><del>-    if (isContextLost())
</del><ins>+    if (isContextLostOrPending())
</ins><span class="cx">         return;
</span><span class="cx">     if (target != GraphicsContext3D::RENDERBUFFER) {
</span><span class="cx">         synthesizeGLError(GraphicsContext3D::INVALID_ENUM, &quot;renderbufferStorage&quot;, &quot;invalid target&quot;);
</span><span class="lines">@@ -3516,14 +3586,14 @@
</span><span class="cx"> 
</span><span class="cx"> void WebGLRenderingContext::sampleCoverage(GC3Dfloat value, GC3Dboolean invert)
</span><span class="cx"> {
</span><del>-    if (isContextLost())
</del><ins>+    if (isContextLostOrPending())
</ins><span class="cx">         return;
</span><span class="cx">     m_context-&gt;sampleCoverage(value, invert);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebGLRenderingContext::scissor(GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei height)
</span><span class="cx"> {
</span><del>-    if (isContextLost())
</del><ins>+    if (isContextLostOrPending())
</ins><span class="cx">         return;
</span><span class="cx">     if (!validateSize(&quot;scissor&quot;, width, height))
</span><span class="cx">         return;
</span><span class="lines">@@ -3533,7 +3603,7 @@
</span><span class="cx"> void WebGLRenderingContext::shaderSource(WebGLShader* shader, const String&amp; string, ExceptionCode&amp; ec)
</span><span class="cx"> {
</span><span class="cx">     UNUSED_PARAM(ec);
</span><del>-    if (isContextLost() || !validateWebGLObject(&quot;shaderSource&quot;, shader))
</del><ins>+    if (isContextLostOrPending() || !validateWebGLObject(&quot;shaderSource&quot;, shader))
</ins><span class="cx">         return;
</span><span class="cx">     String stringWithoutComments = StripComments(string).result();
</span><span class="cx">     if (!validateString(&quot;shaderSource&quot;, stringWithoutComments))
</span><span class="lines">@@ -3544,7 +3614,7 @@
</span><span class="cx"> 
</span><span class="cx"> void WebGLRenderingContext::stencilFunc(GC3Denum func, GC3Dint ref, GC3Duint mask)
</span><span class="cx"> {
</span><del>-    if (isContextLost())
</del><ins>+    if (isContextLostOrPending())
</ins><span class="cx">         return;
</span><span class="cx">     if (!validateStencilFunc(&quot;stencilFunc&quot;, func))
</span><span class="cx">         return;
</span><span class="lines">@@ -3557,7 +3627,7 @@
</span><span class="cx"> 
</span><span class="cx"> void WebGLRenderingContext::stencilFuncSeparate(GC3Denum face, GC3Denum func, GC3Dint ref, GC3Duint mask)
</span><span class="cx"> {
</span><del>-    if (isContextLost())
</del><ins>+    if (isContextLostOrPending())
</ins><span class="cx">         return;
</span><span class="cx">     if (!validateStencilFunc(&quot;stencilFuncSeparate&quot;, func))
</span><span class="cx">         return;
</span><span class="lines">@@ -3585,7 +3655,7 @@
</span><span class="cx"> 
</span><span class="cx"> void WebGLRenderingContext::stencilMask(GC3Duint mask)
</span><span class="cx"> {
</span><del>-    if (isContextLost())
</del><ins>+    if (isContextLostOrPending())
</ins><span class="cx">         return;
</span><span class="cx">     m_stencilMask = mask;
</span><span class="cx">     m_stencilMaskBack = mask;
</span><span class="lines">@@ -3594,7 +3664,7 @@
</span><span class="cx"> 
</span><span class="cx"> void WebGLRenderingContext::stencilMaskSeparate(GC3Denum face, GC3Duint mask)
</span><span class="cx"> {
</span><del>-    if (isContextLost())
</del><ins>+    if (isContextLostOrPending())
</ins><span class="cx">         return;
</span><span class="cx">     switch (face) {
</span><span class="cx">     case GraphicsContext3D::FRONT_AND_BACK:
</span><span class="lines">@@ -3616,14 +3686,14 @@
</span><span class="cx"> 
</span><span class="cx"> void WebGLRenderingContext::stencilOp(GC3Denum fail, GC3Denum zfail, GC3Denum zpass)
</span><span class="cx"> {
</span><del>-    if (isContextLost())
</del><ins>+    if (isContextLostOrPending())
</ins><span class="cx">         return;
</span><span class="cx">     m_context-&gt;stencilOp(fail, zfail, zpass);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebGLRenderingContext::stencilOpSeparate(GC3Denum face, GC3Denum fail, GC3Denum zfail, GC3Denum zpass)
</span><span class="cx"> {
</span><del>-    if (isContextLost())
</del><ins>+    if (isContextLostOrPending())
</ins><span class="cx">         return;
</span><span class="cx">     m_context-&gt;stencilOpSeparate(face, fail, zfail, zpass);
</span><span class="cx"> }
</span><span class="lines">@@ -3734,7 +3804,7 @@
</span><span class="cx">                                        GC3Dsizei width, GC3Dsizei height, GC3Dint border,
</span><span class="cx">                                        GC3Denum format, GC3Denum type, ArrayBufferView* pixels, ExceptionCode&amp; ec)
</span><span class="cx"> {
</span><del>-    if (isContextLost() || !validateTexFuncData(&quot;texImage2D&quot;, level, width, height, format, type, pixels, NullAllowed)
</del><ins>+    if (isContextLostOrPending() || !validateTexFuncData(&quot;texImage2D&quot;, level, width, height, format, type, pixels, NullAllowed)
</ins><span class="cx">         || !validateTexFunc(&quot;texImage2D&quot;, NotTexSubImage2D, SourceArrayBufferView, target, level, internalformat, width, height, border, format, type, 0, 0))
</span><span class="cx">         return;
</span><span class="cx">     void* data = pixels ? pixels-&gt;baseAddress() : 0;
</span><span class="lines">@@ -3762,7 +3832,7 @@
</span><span class="cx">                                        GC3Denum format, GC3Denum type, ImageData* pixels, ExceptionCode&amp; ec)
</span><span class="cx"> {
</span><span class="cx">     ec = 0;
</span><del>-    if (isContextLost() || !pixels || !validateTexFunc(&quot;texImage2D&quot;, NotTexSubImage2D, SourceImageData, target, level, internalformat, pixels-&gt;width(), pixels-&gt;height(), 0, format, type, 0, 0))
</del><ins>+    if (isContextLostOrPending() || !pixels || !validateTexFunc(&quot;texImage2D&quot;, NotTexSubImage2D, SourceImageData, target, level, internalformat, pixels-&gt;width(), pixels-&gt;height(), 0, format, type, 0, 0))
</ins><span class="cx">         return;
</span><span class="cx">     Vector&lt;uint8_t&gt; data;
</span><span class="cx">     bool needConversion = true;
</span><span class="lines">@@ -3803,7 +3873,7 @@
</span><span class="cx">                                        GC3Denum format, GC3Denum type, HTMLImageElement* image, ExceptionCode&amp; ec)
</span><span class="cx"> {
</span><span class="cx">     ec = 0;
</span><del>-    if (isContextLost() || !validateHTMLImageElement(&quot;texImage2D&quot;, image, ec))
</del><ins>+    if (isContextLostOrPending() || !validateHTMLImageElement(&quot;texImage2D&quot;, image, ec))
</ins><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     RefPtr&lt;Image&gt; imageForRender = image-&gt;cachedImage()-&gt;imageForRenderer(image-&gt;renderer());
</span><span class="lines">@@ -3820,7 +3890,7 @@
</span><span class="cx">                                        GC3Denum format, GC3Denum type, HTMLCanvasElement* canvas, ExceptionCode&amp; ec)
</span><span class="cx"> {
</span><span class="cx">     ec = 0;
</span><del>-    if (isContextLost() || !validateHTMLCanvasElement(&quot;texImage2D&quot;, canvas, ec) || !validateTexFunc(&quot;texImage2D&quot;, NotTexSubImage2D, SourceHTMLCanvasElement, target, level, internalformat, canvas-&gt;width(), canvas-&gt;height(), 0, format, type, 0, 0))
</del><ins>+    if (isContextLostOrPending() || !validateHTMLCanvasElement(&quot;texImage2D&quot;, canvas, ec) || !validateTexFunc(&quot;texImage2D&quot;, NotTexSubImage2D, SourceHTMLCanvasElement, target, level, internalformat, canvas-&gt;width(), canvas-&gt;height(), 0, format, type, 0, 0))
</ins><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     WebGLTexture* texture = validateTextureBinding(&quot;texImage2D&quot;, target, true);
</span><span class="lines">@@ -3864,7 +3934,7 @@
</span><span class="cx">                                        GC3Denum format, GC3Denum type, HTMLVideoElement* video, ExceptionCode&amp; ec)
</span><span class="cx"> {
</span><span class="cx">     ec = 0;
</span><del>-    if (isContextLost() || !validateHTMLVideoElement(&quot;texImage2D&quot;, video, ec)
</del><ins>+    if (isContextLostOrPending() || !validateHTMLVideoElement(&quot;texImage2D&quot;, video, ec)
</ins><span class="cx">         || !validateTexFunc(&quot;texImage2D&quot;, NotTexSubImage2D, SourceHTMLVideoElement, target, level, internalformat, video-&gt;videoWidth(), video-&gt;videoHeight(), 0, format, type, 0, 0))
</span><span class="cx">         return;
</span><span class="cx"> 
</span><span class="lines">@@ -3894,7 +3964,7 @@
</span><span class="cx"> 
</span><span class="cx"> void WebGLRenderingContext::texParameter(GC3Denum target, GC3Denum pname, GC3Dfloat paramf, GC3Dint parami, bool isFloat)
</span><span class="cx"> {
</span><del>-    if (isContextLost())
</del><ins>+    if (isContextLostOrPending())
</ins><span class="cx">         return;
</span><span class="cx">     WebGLTexture* tex = validateTextureBinding(&quot;texParameter&quot;, target, false);
</span><span class="cx">     if (!tex)
</span><span class="lines">@@ -3996,7 +4066,7 @@
</span><span class="cx">                                           GC3Dsizei width, GC3Dsizei height,
</span><span class="cx">                                           GC3Denum format, GC3Denum type, ArrayBufferView* pixels, ExceptionCode&amp; ec)
</span><span class="cx"> {
</span><del>-    if (isContextLost() || !validateTexFuncData(&quot;texSubImage2D&quot;, level, width, height, format, type, pixels, NullNotAllowed)
</del><ins>+    if (isContextLostOrPending() || !validateTexFuncData(&quot;texSubImage2D&quot;, level, width, height, format, type, pixels, NullNotAllowed)
</ins><span class="cx">         || !validateTexFunc(&quot;texSubImage2D&quot;, TexSubImage2D, SourceArrayBufferView, target, level, format, width, height, 0, format, type, xoffset, yoffset))
</span><span class="cx">         return;
</span><span class="cx">     void* data = pixels-&gt;baseAddress();
</span><span class="lines">@@ -4023,7 +4093,7 @@
</span><span class="cx">                                           GC3Denum format, GC3Denum type, ImageData* pixels, ExceptionCode&amp; ec)
</span><span class="cx"> {
</span><span class="cx">     ec = 0;
</span><del>-    if (isContextLost() || !pixels || !validateTexFunc(&quot;texSubImage2D&quot;, TexSubImage2D, SourceImageData, target, level, format,  pixels-&gt;width(), pixels-&gt;height(), 0, format, type, xoffset, yoffset))
</del><ins>+    if (isContextLostOrPending() || !pixels || !validateTexFunc(&quot;texSubImage2D&quot;, TexSubImage2D, SourceImageData, target, level, format,  pixels-&gt;width(), pixels-&gt;height(), 0, format, type, xoffset, yoffset))
</ins><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     Vector&lt;uint8_t&gt; data;
</span><span class="lines">@@ -4049,7 +4119,7 @@
</span><span class="cx">                                           GC3Denum format, GC3Denum type, HTMLImageElement* image, ExceptionCode&amp; ec)
</span><span class="cx"> {
</span><span class="cx">     ec = 0;
</span><del>-    if (isContextLost() || !validateHTMLImageElement(&quot;texSubImage2D&quot;, image, ec))
</del><ins>+    if (isContextLostOrPending() || !validateHTMLImageElement(&quot;texSubImage2D&quot;, image, ec))
</ins><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     RefPtr&lt;Image&gt; imageForRender = image-&gt;cachedImage()-&gt;imageForRenderer(image-&gt;renderer());
</span><span class="lines">@@ -4066,7 +4136,7 @@
</span><span class="cx">                                           GC3Denum format, GC3Denum type, HTMLCanvasElement* canvas, ExceptionCode&amp; ec)
</span><span class="cx"> {
</span><span class="cx">     ec = 0;
</span><del>-    if (isContextLost() || !validateHTMLCanvasElement(&quot;texSubImage2D&quot;, canvas, ec)
</del><ins>+    if (isContextLostOrPending() || !validateHTMLCanvasElement(&quot;texSubImage2D&quot;, canvas, ec)
</ins><span class="cx">         || !validateTexFunc(&quot;texSubImage2D&quot;, TexSubImage2D, SourceHTMLCanvasElement, target, level, format, canvas-&gt;width(), canvas-&gt;height(), 0, format, type, xoffset, yoffset))
</span><span class="cx">         return;
</span><span class="cx"> 
</span><span class="lines">@@ -4082,7 +4152,7 @@
</span><span class="cx">                                           GC3Denum format, GC3Denum type, HTMLVideoElement* video, ExceptionCode&amp; ec)
</span><span class="cx"> {
</span><span class="cx">     ec = 0;
</span><del>-    if (isContextLost() || !validateHTMLVideoElement(&quot;texSubImage2D&quot;, video, ec)
</del><ins>+    if (isContextLostOrPending() || !validateHTMLVideoElement(&quot;texSubImage2D&quot;, video, ec)
</ins><span class="cx">         || !validateTexFunc(&quot;texSubImage2D&quot;, TexSubImage2D, SourceHTMLVideoElement, target, level, format, video-&gt;videoWidth(), video-&gt;videoHeight(), 0, format, type, xoffset, yoffset))
</span><span class="cx">         return;
</span><span class="cx"> 
</span><span class="lines">@@ -4096,7 +4166,7 @@
</span><span class="cx"> void WebGLRenderingContext::uniform1f(const WebGLUniformLocation* location, GC3Dfloat x, ExceptionCode&amp; ec)
</span><span class="cx"> {
</span><span class="cx">     UNUSED_PARAM(ec);
</span><del>-    if (isContextLost() || !location)
</del><ins>+    if (isContextLostOrPending() || !location)
</ins><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     if (location-&gt;program() != m_currentProgram) {
</span><span class="lines">@@ -4110,7 +4180,7 @@
</span><span class="cx"> void WebGLRenderingContext::uniform1fv(const WebGLUniformLocation* location, Float32Array* v, ExceptionCode&amp; ec)
</span><span class="cx"> {
</span><span class="cx">     UNUSED_PARAM(ec);
</span><del>-    if (isContextLost() || !validateUniformParameters(&quot;uniform1fv&quot;, location, v, 1))
</del><ins>+    if (isContextLostOrPending() || !validateUniformParameters(&quot;uniform1fv&quot;, location, v, 1))
</ins><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     m_context-&gt;uniform1fv(location-&gt;location(), v-&gt;length(), v-&gt;data());
</span><span class="lines">@@ -4119,7 +4189,7 @@
</span><span class="cx"> void WebGLRenderingContext::uniform1fv(const WebGLUniformLocation* location, GC3Dfloat* v, GC3Dsizei size, ExceptionCode&amp; ec)
</span><span class="cx"> {
</span><span class="cx">     UNUSED_PARAM(ec);
</span><del>-    if (isContextLost() || !validateUniformParameters(&quot;uniform1fv&quot;, location, v, size, 1))
</del><ins>+    if (isContextLostOrPending() || !validateUniformParameters(&quot;uniform1fv&quot;, location, v, size, 1))
</ins><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     m_context-&gt;uniform1fv(location-&gt;location(), size, v);
</span><span class="lines">@@ -4128,7 +4198,7 @@
</span><span class="cx"> void WebGLRenderingContext::uniform1i(const WebGLUniformLocation* location, GC3Dint x, ExceptionCode&amp; ec)
</span><span class="cx"> {
</span><span class="cx">     UNUSED_PARAM(ec);
</span><del>-    if (isContextLost() || !location)
</del><ins>+    if (isContextLostOrPending() || !location)
</ins><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     if (location-&gt;program() != m_currentProgram) {
</span><span class="lines">@@ -4147,7 +4217,7 @@
</span><span class="cx"> void WebGLRenderingContext::uniform1iv(const WebGLUniformLocation* location, Int32Array* v, ExceptionCode&amp; ec)
</span><span class="cx"> {
</span><span class="cx">     UNUSED_PARAM(ec);
</span><del>-    if (isContextLost() || !validateUniformParameters(&quot;uniform1iv&quot;, location, v, 1))
</del><ins>+    if (isContextLostOrPending() || !validateUniformParameters(&quot;uniform1iv&quot;, location, v, 1))
</ins><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     if (location-&gt;type() == GraphicsContext3D::SAMPLER_2D || location-&gt;type() == GraphicsContext3D::SAMPLER_CUBE)
</span><span class="lines">@@ -4165,7 +4235,7 @@
</span><span class="cx"> void WebGLRenderingContext::uniform1iv(const WebGLUniformLocation* location, GC3Dint* v, GC3Dsizei size, ExceptionCode&amp; ec)
</span><span class="cx"> {
</span><span class="cx">     UNUSED_PARAM(ec);
</span><del>-    if (isContextLost() || !validateUniformParameters(&quot;uniform1iv&quot;, location, v, size, 1))
</del><ins>+    if (isContextLostOrPending() || !validateUniformParameters(&quot;uniform1iv&quot;, location, v, size, 1))
</ins><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     if (location-&gt;type() == GraphicsContext3D::SAMPLER_2D || location-&gt;type() == GraphicsContext3D::SAMPLER_CUBE)
</span><span class="lines">@@ -4182,7 +4252,7 @@
</span><span class="cx"> void WebGLRenderingContext::uniform2f(const WebGLUniformLocation* location, GC3Dfloat x, GC3Dfloat y, ExceptionCode&amp; ec)
</span><span class="cx"> {
</span><span class="cx">     UNUSED_PARAM(ec);
</span><del>-    if (isContextLost() || !location)
</del><ins>+    if (isContextLostOrPending() || !location)
</ins><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     if (location-&gt;program() != m_currentProgram) {
</span><span class="lines">@@ -4196,7 +4266,7 @@
</span><span class="cx"> void WebGLRenderingContext::uniform2fv(const WebGLUniformLocation* location, Float32Array* v, ExceptionCode&amp; ec)
</span><span class="cx"> {
</span><span class="cx">     UNUSED_PARAM(ec);
</span><del>-    if (isContextLost() || !validateUniformParameters(&quot;uniform2fv&quot;, location, v, 2))
</del><ins>+    if (isContextLostOrPending() || !validateUniformParameters(&quot;uniform2fv&quot;, location, v, 2))
</ins><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     m_context-&gt;uniform2fv(location-&gt;location(), v-&gt;length() / 2, v-&gt;data());
</span><span class="lines">@@ -4205,7 +4275,7 @@
</span><span class="cx"> void WebGLRenderingContext::uniform2fv(const WebGLUniformLocation* location, GC3Dfloat* v, GC3Dsizei size, ExceptionCode&amp; ec)
</span><span class="cx"> {
</span><span class="cx">     UNUSED_PARAM(ec);
</span><del>-    if (isContextLost() || !validateUniformParameters(&quot;uniform2fv&quot;, location, v, size, 2))
</del><ins>+    if (isContextLostOrPending() || !validateUniformParameters(&quot;uniform2fv&quot;, location, v, size, 2))
</ins><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     m_context-&gt;uniform2fv(location-&gt;location(), size / 2, v);
</span><span class="lines">@@ -4214,7 +4284,7 @@
</span><span class="cx"> void WebGLRenderingContext::uniform2i(const WebGLUniformLocation* location, GC3Dint x, GC3Dint y, ExceptionCode&amp; ec)
</span><span class="cx"> {
</span><span class="cx">     UNUSED_PARAM(ec);
</span><del>-    if (isContextLost() || !location)
</del><ins>+    if (isContextLostOrPending() || !location)
</ins><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     if (location-&gt;program() != m_currentProgram) {
</span><span class="lines">@@ -4228,7 +4298,7 @@
</span><span class="cx"> void WebGLRenderingContext::uniform2iv(const WebGLUniformLocation* location, Int32Array* v, ExceptionCode&amp; ec)
</span><span class="cx"> {
</span><span class="cx">     UNUSED_PARAM(ec);
</span><del>-    if (isContextLost() || !validateUniformParameters(&quot;uniform2iv&quot;, location, v, 2))
</del><ins>+    if (isContextLostOrPending() || !validateUniformParameters(&quot;uniform2iv&quot;, location, v, 2))
</ins><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     m_context-&gt;uniform2iv(location-&gt;location(), v-&gt;length() / 2, v-&gt;data());
</span><span class="lines">@@ -4237,7 +4307,7 @@
</span><span class="cx"> void WebGLRenderingContext::uniform2iv(const WebGLUniformLocation* location, GC3Dint* v, GC3Dsizei size, ExceptionCode&amp; ec)
</span><span class="cx"> {
</span><span class="cx">     UNUSED_PARAM(ec);
</span><del>-    if (isContextLost() || !validateUniformParameters(&quot;uniform2iv&quot;, location, v, size, 2))
</del><ins>+    if (isContextLostOrPending() || !validateUniformParameters(&quot;uniform2iv&quot;, location, v, size, 2))
</ins><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     m_context-&gt;uniform2iv(location-&gt;location(), size / 2, v);
</span><span class="lines">@@ -4246,7 +4316,7 @@
</span><span class="cx"> void WebGLRenderingContext::uniform3f(const WebGLUniformLocation* location, GC3Dfloat x, GC3Dfloat y, GC3Dfloat z, ExceptionCode&amp; ec)
</span><span class="cx"> {
</span><span class="cx">     UNUSED_PARAM(ec);
</span><del>-    if (isContextLost() || !location)
</del><ins>+    if (isContextLostOrPending() || !location)
</ins><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     if (location-&gt;program() != m_currentProgram) {
</span><span class="lines">@@ -4260,7 +4330,7 @@
</span><span class="cx"> void WebGLRenderingContext::uniform3fv(const WebGLUniformLocation* location, Float32Array* v, ExceptionCode&amp; ec)
</span><span class="cx"> {
</span><span class="cx">     UNUSED_PARAM(ec);
</span><del>-    if (isContextLost() || !validateUniformParameters(&quot;uniform3fv&quot;, location, v, 3))
</del><ins>+    if (isContextLostOrPending() || !validateUniformParameters(&quot;uniform3fv&quot;, location, v, 3))
</ins><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     m_context-&gt;uniform3fv(location-&gt;location(), v-&gt;length() / 3, v-&gt;data());
</span><span class="lines">@@ -4269,7 +4339,7 @@
</span><span class="cx"> void WebGLRenderingContext::uniform3fv(const WebGLUniformLocation* location, GC3Dfloat* v, GC3Dsizei size, ExceptionCode&amp; ec)
</span><span class="cx"> {
</span><span class="cx">     UNUSED_PARAM(ec);
</span><del>-    if (isContextLost() || !validateUniformParameters(&quot;uniform3fv&quot;, location, v, size, 3))
</del><ins>+    if (isContextLostOrPending() || !validateUniformParameters(&quot;uniform3fv&quot;, location, v, size, 3))
</ins><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     m_context-&gt;uniform3fv(location-&gt;location(), size / 3, v);
</span><span class="lines">@@ -4278,7 +4348,7 @@
</span><span class="cx"> void WebGLRenderingContext::uniform3i(const WebGLUniformLocation* location, GC3Dint x, GC3Dint y, GC3Dint z, ExceptionCode&amp; ec)
</span><span class="cx"> {
</span><span class="cx">     UNUSED_PARAM(ec);
</span><del>-    if (isContextLost() || !location)
</del><ins>+    if (isContextLostOrPending() || !location)
</ins><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     if (location-&gt;program() != m_currentProgram) {
</span><span class="lines">@@ -4292,7 +4362,7 @@
</span><span class="cx"> void WebGLRenderingContext::uniform3iv(const WebGLUniformLocation* location, Int32Array* v, ExceptionCode&amp; ec)
</span><span class="cx"> {
</span><span class="cx">     UNUSED_PARAM(ec);
</span><del>-    if (isContextLost() || !validateUniformParameters(&quot;uniform3iv&quot;, location, v, 3))
</del><ins>+    if (isContextLostOrPending() || !validateUniformParameters(&quot;uniform3iv&quot;, location, v, 3))
</ins><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     m_context-&gt;uniform3iv(location-&gt;location(), v-&gt;length() / 3, v-&gt;data());
</span><span class="lines">@@ -4301,7 +4371,7 @@
</span><span class="cx"> void WebGLRenderingContext::uniform3iv(const WebGLUniformLocation* location, GC3Dint* v, GC3Dsizei size, ExceptionCode&amp; ec)
</span><span class="cx"> {
</span><span class="cx">     UNUSED_PARAM(ec);
</span><del>-    if (isContextLost() || !validateUniformParameters(&quot;uniform3iv&quot;, location, v, size, 3))
</del><ins>+    if (isContextLostOrPending() || !validateUniformParameters(&quot;uniform3iv&quot;, location, v, size, 3))
</ins><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     m_context-&gt;uniform3iv(location-&gt;location(), size / 3, v);
</span><span class="lines">@@ -4310,7 +4380,7 @@
</span><span class="cx"> void WebGLRenderingContext::uniform4f(const WebGLUniformLocation* location, GC3Dfloat x, GC3Dfloat y, GC3Dfloat z, GC3Dfloat w, ExceptionCode&amp; ec)
</span><span class="cx"> {
</span><span class="cx">     UNUSED_PARAM(ec);
</span><del>-    if (isContextLost() || !location)
</del><ins>+    if (isContextLostOrPending() || !location)
</ins><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     if (location-&gt;program() != m_currentProgram) {
</span><span class="lines">@@ -4324,7 +4394,7 @@
</span><span class="cx"> void WebGLRenderingContext::uniform4fv(const WebGLUniformLocation* location, Float32Array* v, ExceptionCode&amp; ec)
</span><span class="cx"> {
</span><span class="cx">     UNUSED_PARAM(ec);
</span><del>-    if (isContextLost() || !validateUniformParameters(&quot;uniform4fv&quot;, location, v, 4))
</del><ins>+    if (isContextLostOrPending() || !validateUniformParameters(&quot;uniform4fv&quot;, location, v, 4))
</ins><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     m_context-&gt;uniform4fv(location-&gt;location(), v-&gt;length() / 4, v-&gt;data());
</span><span class="lines">@@ -4333,7 +4403,7 @@
</span><span class="cx"> void WebGLRenderingContext::uniform4fv(const WebGLUniformLocation* location, GC3Dfloat* v, GC3Dsizei size, ExceptionCode&amp; ec)
</span><span class="cx"> {
</span><span class="cx">     UNUSED_PARAM(ec);
</span><del>-    if (isContextLost() || !validateUniformParameters(&quot;uniform4fv&quot;, location, v, size, 4))
</del><ins>+    if (isContextLostOrPending() || !validateUniformParameters(&quot;uniform4fv&quot;, location, v, size, 4))
</ins><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     m_context-&gt;uniform4fv(location-&gt;location(), size / 4, v);
</span><span class="lines">@@ -4342,7 +4412,7 @@
</span><span class="cx"> void WebGLRenderingContext::uniform4i(const WebGLUniformLocation* location, GC3Dint x, GC3Dint y, GC3Dint z, GC3Dint w, ExceptionCode&amp; ec)
</span><span class="cx"> {
</span><span class="cx">     UNUSED_PARAM(ec);
</span><del>-    if (isContextLost() || !location)
</del><ins>+    if (isContextLostOrPending() || !location)
</ins><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     if (location-&gt;program() != m_currentProgram) {
</span><span class="lines">@@ -4356,7 +4426,7 @@
</span><span class="cx"> void WebGLRenderingContext::uniform4iv(const WebGLUniformLocation* location, Int32Array* v, ExceptionCode&amp; ec)
</span><span class="cx"> {
</span><span class="cx">     UNUSED_PARAM(ec);
</span><del>-    if (isContextLost() || !validateUniformParameters(&quot;uniform4iv&quot;, location, v, 4))
</del><ins>+    if (isContextLostOrPending() || !validateUniformParameters(&quot;uniform4iv&quot;, location, v, 4))
</ins><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     m_context-&gt;uniform4iv(location-&gt;location(), v-&gt;length() / 4, v-&gt;data());
</span><span class="lines">@@ -4365,7 +4435,7 @@
</span><span class="cx"> void WebGLRenderingContext::uniform4iv(const WebGLUniformLocation* location, GC3Dint* v, GC3Dsizei size, ExceptionCode&amp; ec)
</span><span class="cx"> {
</span><span class="cx">     UNUSED_PARAM(ec);
</span><del>-    if (isContextLost() || !validateUniformParameters(&quot;uniform4iv&quot;, location, v, size, 4))
</del><ins>+    if (isContextLostOrPending() || !validateUniformParameters(&quot;uniform4iv&quot;, location, v, size, 4))
</ins><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     m_context-&gt;uniform4iv(location-&gt;location(), size / 4, v);
</span><span class="lines">@@ -4374,7 +4444,7 @@
</span><span class="cx"> void WebGLRenderingContext::uniformMatrix2fv(const WebGLUniformLocation* location, GC3Dboolean transpose, Float32Array* v, ExceptionCode&amp; ec)
</span><span class="cx"> {
</span><span class="cx">     UNUSED_PARAM(ec);
</span><del>-    if (isContextLost() || !validateUniformMatrixParameters(&quot;uniformMatrix2fv&quot;, location, transpose, v, 4))
</del><ins>+    if (isContextLostOrPending() || !validateUniformMatrixParameters(&quot;uniformMatrix2fv&quot;, location, transpose, v, 4))
</ins><span class="cx">         return;
</span><span class="cx">     m_context-&gt;uniformMatrix2fv(location-&gt;location(), v-&gt;length() / 4, transpose, v-&gt;data());
</span><span class="cx"> }
</span><span class="lines">@@ -4382,7 +4452,7 @@
</span><span class="cx"> void WebGLRenderingContext::uniformMatrix2fv(const WebGLUniformLocation* location, GC3Dboolean transpose, GC3Dfloat* v, GC3Dsizei size, ExceptionCode&amp; ec)
</span><span class="cx"> {
</span><span class="cx">     UNUSED_PARAM(ec);
</span><del>-    if (isContextLost() || !validateUniformMatrixParameters(&quot;uniformMatrix2fv&quot;, location, transpose, v, size, 4))
</del><ins>+    if (isContextLostOrPending() || !validateUniformMatrixParameters(&quot;uniformMatrix2fv&quot;, location, transpose, v, size, 4))
</ins><span class="cx">         return;
</span><span class="cx">     m_context-&gt;uniformMatrix2fv(location-&gt;location(), size / 4, transpose, v);
</span><span class="cx"> }
</span><span class="lines">@@ -4390,7 +4460,7 @@
</span><span class="cx"> void WebGLRenderingContext::uniformMatrix3fv(const WebGLUniformLocation* location, GC3Dboolean transpose, Float32Array* v, ExceptionCode&amp; ec)
</span><span class="cx"> {
</span><span class="cx">     UNUSED_PARAM(ec);
</span><del>-    if (isContextLost() || !validateUniformMatrixParameters(&quot;uniformMatrix3fv&quot;, location, transpose, v, 9))
</del><ins>+    if (isContextLostOrPending() || !validateUniformMatrixParameters(&quot;uniformMatrix3fv&quot;, location, transpose, v, 9))
</ins><span class="cx">         return;
</span><span class="cx">     m_context-&gt;uniformMatrix3fv(location-&gt;location(), v-&gt;length() / 9, transpose, v-&gt;data());
</span><span class="cx"> }
</span><span class="lines">@@ -4398,7 +4468,7 @@
</span><span class="cx"> void WebGLRenderingContext::uniformMatrix3fv(const WebGLUniformLocation* location, GC3Dboolean transpose, GC3Dfloat* v, GC3Dsizei size, ExceptionCode&amp; ec)
</span><span class="cx"> {
</span><span class="cx">     UNUSED_PARAM(ec);
</span><del>-    if (isContextLost() || !validateUniformMatrixParameters(&quot;uniformMatrix3fv&quot;, location, transpose, v, size, 9))
</del><ins>+    if (isContextLostOrPending() || !validateUniformMatrixParameters(&quot;uniformMatrix3fv&quot;, location, transpose, v, size, 9))
</ins><span class="cx">         return;
</span><span class="cx">     m_context-&gt;uniformMatrix3fv(location-&gt;location(), size / 9, transpose, v);
</span><span class="cx"> }
</span><span class="lines">@@ -4406,7 +4476,7 @@
</span><span class="cx"> void WebGLRenderingContext::uniformMatrix4fv(const WebGLUniformLocation* location, GC3Dboolean transpose, Float32Array* v, ExceptionCode&amp; ec)
</span><span class="cx"> {
</span><span class="cx">     UNUSED_PARAM(ec);
</span><del>-    if (isContextLost() || !validateUniformMatrixParameters(&quot;uniformMatrix4fv&quot;, location, transpose, v, 16))
</del><ins>+    if (isContextLostOrPending() || !validateUniformMatrixParameters(&quot;uniformMatrix4fv&quot;, location, transpose, v, 16))
</ins><span class="cx">         return;
</span><span class="cx">     m_context-&gt;uniformMatrix4fv(location-&gt;location(), v-&gt;length() / 16, transpose, v-&gt;data());
</span><span class="cx"> }
</span><span class="lines">@@ -4414,7 +4484,7 @@
</span><span class="cx"> void WebGLRenderingContext::uniformMatrix4fv(const WebGLUniformLocation* location, GC3Dboolean transpose, GC3Dfloat* v, GC3Dsizei size, ExceptionCode&amp; ec)
</span><span class="cx"> {
</span><span class="cx">     UNUSED_PARAM(ec);
</span><del>-    if (isContextLost() || !validateUniformMatrixParameters(&quot;uniformMatrix4fv&quot;, location, transpose, v, size, 16))
</del><ins>+    if (isContextLostOrPending() || !validateUniformMatrixParameters(&quot;uniformMatrix4fv&quot;, location, transpose, v, size, 16))
</ins><span class="cx">         return;
</span><span class="cx">     m_context-&gt;uniformMatrix4fv(location-&gt;location(), size / 16, transpose, v);
</span><span class="cx"> }
</span><span class="lines">@@ -4444,7 +4514,7 @@
</span><span class="cx"> void WebGLRenderingContext::validateProgram(WebGLProgram* program, ExceptionCode&amp; ec)
</span><span class="cx"> {
</span><span class="cx">     UNUSED_PARAM(ec);
</span><del>-    if (isContextLost() || !validateWebGLObject(&quot;validateProgram&quot;, program))
</del><ins>+    if (isContextLostOrPending() || !validateWebGLObject(&quot;validateProgram&quot;, program))
</ins><span class="cx">         return;
</span><span class="cx">     m_context-&gt;validateProgram(objectOrZero(program));
</span><span class="cx"> }
</span><span class="lines">@@ -4512,7 +4582,7 @@
</span><span class="cx"> void WebGLRenderingContext::vertexAttribPointer(GC3Duint index, GC3Dint size, GC3Denum type, GC3Dboolean normalized, GC3Dsizei stride, long long offset, ExceptionCode&amp; ec)
</span><span class="cx"> {
</span><span class="cx">     UNUSED_PARAM(ec);
</span><del>-    if (isContextLost())
</del><ins>+    if (isContextLostOrPending())
</ins><span class="cx">         return;
</span><span class="cx">     switch (type) {
</span><span class="cx">     case GraphicsContext3D::BYTE:
</span><span class="lines">@@ -4555,7 +4625,7 @@
</span><span class="cx"> 
</span><span class="cx"> void WebGLRenderingContext::viewport(GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei height)
</span><span class="cx"> {
</span><del>-    if (isContextLost())
</del><ins>+    if (isContextLostOrPending())
</ins><span class="cx">         return;
</span><span class="cx">     if (!validateSize(&quot;viewport&quot;, width, height))
</span><span class="cx">         return;
</span><span class="lines">@@ -4564,7 +4634,7 @@
</span><span class="cx"> 
</span><span class="cx"> void WebGLRenderingContext::forceLostContext(WebGLRenderingContext::LostContextMode mode)
</span><span class="cx"> {
</span><del>-    if (isContextLost()) {
</del><ins>+    if (isContextLostOrPending()) {
</ins><span class="cx">         synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, &quot;loseContext&quot;, &quot;context already lost&quot;);
</span><span class="cx">         return;
</span><span class="cx">     }
</span><span class="lines">@@ -4617,7 +4687,7 @@
</span><span class="cx"> 
</span><span class="cx"> void WebGLRenderingContext::forceRestoreContext()
</span><span class="cx"> {
</span><del>-    if (!isContextLost()) {
</del><ins>+    if (!isContextLostOrPending()) {
</ins><span class="cx">         synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, &quot;restoreContext&quot;, &quot;context not lost&quot;);
</span><span class="cx">         return;
</span><span class="cx">     }
</span><span class="lines">@@ -4634,33 +4704,48 @@
</span><span class="cx"> 
</span><span class="cx"> PlatformLayer* WebGLRenderingContext::platformLayer() const
</span><span class="cx"> {
</span><del>-    return (!isContextLost()) ? m_context-&gt;platformLayer() : 0;
</del><ins>+    return (!isContextLost() &amp;&amp; !m_isPendingPolicyResolution) ? m_context-&gt;platformLayer() : 0;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebGLRenderingContext::removeSharedObject(WebGLSharedObject* object)
</span><span class="cx"> {
</span><ins>+    if (m_isPendingPolicyResolution)
+        return;
+
</ins><span class="cx">     m_contextGroup-&gt;removeObject(object);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebGLRenderingContext::addSharedObject(WebGLSharedObject* object)
</span><span class="cx"> {
</span><ins>+    if (m_isPendingPolicyResolution)
+        return;
+
</ins><span class="cx">     ASSERT(!isContextLost());
</span><span class="cx">     m_contextGroup-&gt;addObject(object);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebGLRenderingContext::removeContextObject(WebGLContextObject* object)
</span><span class="cx"> {
</span><ins>+    if (m_isPendingPolicyResolution)
+        return;
+
</ins><span class="cx">     m_contextObjects.remove(object);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebGLRenderingContext::addContextObject(WebGLContextObject* object)
</span><span class="cx"> {
</span><ins>+    if (m_isPendingPolicyResolution)
+        return;
+
</ins><span class="cx">     ASSERT(!isContextLost());
</span><span class="cx">     m_contextObjects.add(object);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebGLRenderingContext::detachAndRemoveAllObjects()
</span><span class="cx"> {
</span><ins>+    if (m_isPendingPolicyResolution)
+        return;
+
</ins><span class="cx">     while (m_contextObjects.size() &gt; 0) {
</span><span class="cx">         HashSet&lt;WebGLContextObject*&gt;::iterator it = m_contextObjects.begin();
</span><span class="cx">         (*it)-&gt;detachContext();
</span><span class="lines">@@ -4674,7 +4759,7 @@
</span><span class="cx"> 
</span><span class="cx"> void WebGLRenderingContext::stop()
</span><span class="cx"> {
</span><del>-    if (!isContextLost()) {
</del><ins>+    if (!isContextLost() &amp;&amp; !m_isPendingPolicyResolution) {
</ins><span class="cx">         forceLostContext(SyntheticLostContext);
</span><span class="cx">         destroyGraphicsContext3D();
</span><span class="cx">     }
</span><span class="lines">@@ -5591,7 +5676,7 @@
</span><span class="cx"> 
</span><span class="cx"> void WebGLRenderingContext::vertexAttribfImpl(const char* functionName, GC3Duint index, GC3Dsizei expectedSize, GC3Dfloat v0, GC3Dfloat v1, GC3Dfloat v2, GC3Dfloat v3)
</span><span class="cx"> {
</span><del>-    if (isContextLost())
</del><ins>+    if (isContextLostOrPending())
</ins><span class="cx">         return;
</span><span class="cx">     if (index &gt;= m_maxVertexAttribs) {
</span><span class="cx">         synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, &quot;index out of range&quot;);
</span><span class="lines">@@ -5623,7 +5708,7 @@
</span><span class="cx"> 
</span><span class="cx"> void WebGLRenderingContext::vertexAttribfvImpl(const char* functionName, GC3Duint index, Float32Array* v, GC3Dsizei expectedSize)
</span><span class="cx"> {
</span><del>-    if (isContextLost())
</del><ins>+    if (isContextLostOrPending())
</ins><span class="cx">         return;
</span><span class="cx">     if (!v) {
</span><span class="cx">         synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, &quot;no array&quot;);
</span><span class="lines">@@ -5634,7 +5719,7 @@
</span><span class="cx"> 
</span><span class="cx"> void WebGLRenderingContext::vertexAttribfvImpl(const char* functionName, GC3Duint index, GC3Dfloat* v, GC3Dsizei size, GC3Dsizei expectedSize)
</span><span class="cx"> {
</span><del>-    if (isContextLost())
</del><ins>+    if (isContextLostOrPending())
</ins><span class="cx">         return;
</span><span class="cx">     if (!v) {
</span><span class="cx">         synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, &quot;no array&quot;);
</span><span class="lines">@@ -6067,7 +6152,7 @@
</span><span class="cx"> 
</span><span class="cx"> void WebGLRenderingContext::vertexAttribDivisor(GC3Duint index, GC3Duint divisor)
</span><span class="cx"> {
</span><del>-    if (isContextLost())
</del><ins>+    if (isContextLostOrPending())
</ins><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     if (index &gt;= m_maxVertexAttribs) {
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlcanvasWebGLRenderingContexth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/canvas/WebGLRenderingContext.h (164451 => 164452)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/canvas/WebGLRenderingContext.h        2014-02-20 23:11:52 UTC (rev 164451)
+++ trunk/Source/WebCore/html/canvas/WebGLRenderingContext.h        2014-02-20 23:12:18 UTC (rev 164452)
</span><span class="lines">@@ -339,6 +339,7 @@
</span><span class="cx">     friend class WebGLRenderingContextErrorMessageCallback;
</span><span class="cx">     friend class WebGLVertexArrayObjectOES;
</span><span class="cx"> 
</span><ins>+    WebGLRenderingContext(HTMLCanvasElement*, GraphicsContext3D::Attributes);
</ins><span class="cx">     WebGLRenderingContext(HTMLCanvasElement*, PassRefPtr&lt;GraphicsContext3D&gt;, GraphicsContext3D::Attributes);
</span><span class="cx">     void initializeNewContext();
</span><span class="cx">     void setupFlags();
</span><span class="lines">@@ -524,6 +525,13 @@
</span><span class="cx">     bool m_synthesizedErrorsToConsole;
</span><span class="cx">     int m_numGLErrorsToConsoleAllowed;
</span><span class="cx"> 
</span><ins>+    // A WebGLRenderingContext can be created in a state where it appears as
+    // a valid and active context, but will not execute any important operations
+    // until its load policy is completely resolved.
+    bool m_isPendingPolicyResolution;
+    bool m_hasRequestedPolicyResolution;
+    bool isContextLostOrPending();
+
</ins><span class="cx">     // Enabled extension objects.
</span><span class="cx">     OwnPtr&lt;EXTDrawBuffers&gt; m_extDrawBuffers;
</span><span class="cx">     OwnPtr&lt;EXTTextureFilterAnisotropic&gt; m_extTextureFilterAnisotropic;
</span></span></pre>
</div>
</div>

</body>
</html>