<!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>[164744] 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/164744">164744</a></dd>
<dt>Author</dt> <dd>dino@apple.com</dd>
<dt>Date</dt> <dd>2014-02-26 13:31:38 -0800 (Wed, 26 Feb 2014)</dd>
</dl>
<h3>Log Message</h3>
<pre>[WebGL] Protect more WebGL entry points for pending contexts
https://bugs.webkit.org/show_bug.cgi?id=129386
Reviewed by Tim Horton.
There are entry points into a WebGLRenderingContext that don't
come from the web-exposed API directly, such as drawImage with
the WebGL canvas. Protect these by returning early if we're
a pending context.
Also a bunch of drive-by 0 -> nullptr changes.
* html/canvas/WebGLRenderingContext.cpp:
(WebCore::WebGLRenderingContext::markLayerComposited):
(WebCore::WebGLRenderingContext::paintRenderingResultsToCanvas):
(WebCore::WebGLRenderingContext::paintRenderingResultsToImageData):
(WebCore::WebGLRenderingContext::reshape):
(WebCore::WebGLRenderingContext::createBuffer):
(WebCore::WebGLRenderingContext::createFramebuffer):
(WebCore::WebGLRenderingContext::createTexture):
(WebCore::WebGLRenderingContext::createProgram):
(WebCore::WebGLRenderingContext::createRenderbuffer):
(WebCore::WebGLRenderingContext::createShader):
(WebCore::WebGLRenderingContext::getActiveAttrib):
(WebCore::WebGLRenderingContext::getActiveUniform):
(WebCore::WebGLRenderingContext::getContextAttributes):
(WebCore::WebGLRenderingContext::getError):
(WebCore::WebGLRenderingContext::getExtension):
(WebCore::WebGLRenderingContext::getShaderPrecisionFormat):
(WebCore::WebGLRenderingContext::getUniformLocation):
(WebCore::WebGLRenderingContext::drawImageIntoBuffer):
(WebCore::WebGLRenderingContext::videoFrameToImage):
(WebCore::WebGLRenderingContext::validateBufferDataParameters):
(WebCore::WebGLRenderingContext::LRUImageBufferCache::imageBuffer):</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorehtmlcanvasWebGLRenderingContextcpp">trunk/Source/WebCore/html/canvas/WebGLRenderingContext.cpp</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (164743 => 164744)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2014-02-26 21:27:10 UTC (rev 164743)
+++ trunk/Source/WebCore/ChangeLog        2014-02-26 21:31:38 UTC (rev 164744)
</span><span class="lines">@@ -1,3 +1,40 @@
</span><ins>+2014-02-26 Dean Jackson <dino@apple.com>
+
+ [WebGL] Protect more WebGL entry points for pending contexts
+ https://bugs.webkit.org/show_bug.cgi?id=129386
+
+ Reviewed by Tim Horton.
+
+ There are entry points into a WebGLRenderingContext that don't
+ come from the web-exposed API directly, such as drawImage with
+ the WebGL canvas. Protect these by returning early if we're
+ a pending context.
+
+ Also a bunch of drive-by 0 -> nullptr changes.
+
+ * html/canvas/WebGLRenderingContext.cpp:
+ (WebCore::WebGLRenderingContext::markLayerComposited):
+ (WebCore::WebGLRenderingContext::paintRenderingResultsToCanvas):
+ (WebCore::WebGLRenderingContext::paintRenderingResultsToImageData):
+ (WebCore::WebGLRenderingContext::reshape):
+ (WebCore::WebGLRenderingContext::createBuffer):
+ (WebCore::WebGLRenderingContext::createFramebuffer):
+ (WebCore::WebGLRenderingContext::createTexture):
+ (WebCore::WebGLRenderingContext::createProgram):
+ (WebCore::WebGLRenderingContext::createRenderbuffer):
+ (WebCore::WebGLRenderingContext::createShader):
+ (WebCore::WebGLRenderingContext::getActiveAttrib):
+ (WebCore::WebGLRenderingContext::getActiveUniform):
+ (WebCore::WebGLRenderingContext::getContextAttributes):
+ (WebCore::WebGLRenderingContext::getError):
+ (WebCore::WebGLRenderingContext::getExtension):
+ (WebCore::WebGLRenderingContext::getShaderPrecisionFormat):
+ (WebCore::WebGLRenderingContext::getUniformLocation):
+ (WebCore::WebGLRenderingContext::drawImageIntoBuffer):
+ (WebCore::WebGLRenderingContext::videoFrameToImage):
+ (WebCore::WebGLRenderingContext::validateBufferDataParameters):
+ (WebCore::WebGLRenderingContext::LRUImageBufferCache::imageBuffer):
+
</ins><span class="cx"> 2014-02-26 Bem Jones-Bey <bjonesbe@adobe.com>
</span><span class="cx">
</span><span class="cx"> [CSS Shapes] inset and inset-rectangle trigger assert with replaced element and large percentage dimension
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlcanvasWebGLRenderingContextcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/canvas/WebGLRenderingContext.cpp (164743 => 164744)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/canvas/WebGLRenderingContext.cpp        2014-02-26 21:27:10 UTC (rev 164743)
+++ trunk/Source/WebCore/html/canvas/WebGLRenderingContext.cpp        2014-02-26 21:31:38 UTC (rev 164744)
</span><span class="lines">@@ -764,11 +764,16 @@
</span><span class="cx">
</span><span class="cx"> void WebGLRenderingContext::markLayerComposited()
</span><span class="cx"> {
</span><ins>+ if (isContextLostOrPending())
+ return;
</ins><span class="cx"> m_context->markLayerComposited();
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void WebGLRenderingContext::paintRenderingResultsToCanvas()
</span><span class="cx"> {
</span><ins>+ if (isContextLostOrPending())
+ return;
+
</ins><span class="cx"> if (canvas()->document().printing())
</span><span class="cx"> canvas()->clearPresentationCopy();
</span><span class="cx">
</span><span class="lines">@@ -802,6 +807,8 @@
</span><span class="cx">
</span><span class="cx"> PassRefPtr<ImageData> WebGLRenderingContext::paintRenderingResultsToImageData()
</span><span class="cx"> {
</span><ins>+ if (isContextLostOrPending())
+ return nullptr;
</ins><span class="cx"> clearIfComposited();
</span><span class="cx"> if (m_drawingBuffer)
</span><span class="cx"> m_drawingBuffer->commit();
</span><span class="lines">@@ -819,6 +826,9 @@
</span><span class="cx">
</span><span class="cx"> void WebGLRenderingContext::reshape(int width, int height)
</span><span class="cx"> {
</span><ins>+ if (isContextLostOrPending())
+ return;
+
</ins><span class="cx"> // This is an approximation because at WebGLRenderingContext level we don't
</span><span class="cx"> // know if the underlying FBO uses textures or renderbuffers.
</span><span class="cx"> GC3Dint maxSize = std::min(m_maxTextureSize, m_maxRenderbufferSize);
</span><span class="lines">@@ -1508,7 +1518,7 @@
</span><span class="cx"> PassRefPtr<WebGLBuffer> WebGLRenderingContext::createBuffer()
</span><span class="cx"> {
</span><span class="cx"> if (isContextLostOrPending())
</span><del>- return 0;
</del><ins>+ return nullptr;
</ins><span class="cx"> RefPtr<WebGLBuffer> o = WebGLBuffer::create(this);
</span><span class="cx"> addSharedObject(o.get());
</span><span class="cx"> return o;
</span><span class="lines">@@ -1517,7 +1527,7 @@
</span><span class="cx"> PassRefPtr<WebGLFramebuffer> WebGLRenderingContext::createFramebuffer()
</span><span class="cx"> {
</span><span class="cx"> if (isContextLostOrPending())
</span><del>- return 0;
</del><ins>+ return nullptr;
</ins><span class="cx"> RefPtr<WebGLFramebuffer> o = WebGLFramebuffer::create(this);
</span><span class="cx"> addContextObject(o.get());
</span><span class="cx"> return o;
</span><span class="lines">@@ -1526,7 +1536,7 @@
</span><span class="cx"> PassRefPtr<WebGLTexture> WebGLRenderingContext::createTexture()
</span><span class="cx"> {
</span><span class="cx"> if (isContextLostOrPending())
</span><del>- return 0;
</del><ins>+ return nullptr;
</ins><span class="cx"> RefPtr<WebGLTexture> o = WebGLTexture::create(this);
</span><span class="cx"> addSharedObject(o.get());
</span><span class="cx"> return o;
</span><span class="lines">@@ -1535,7 +1545,7 @@
</span><span class="cx"> PassRefPtr<WebGLProgram> WebGLRenderingContext::createProgram()
</span><span class="cx"> {
</span><span class="cx"> if (isContextLostOrPending())
</span><del>- return 0;
</del><ins>+ return nullptr;
</ins><span class="cx"> RefPtr<WebGLProgram> o = WebGLProgram::create(this);
</span><span class="cx"> addSharedObject(o.get());
</span><span class="cx"> return o;
</span><span class="lines">@@ -1544,7 +1554,7 @@
</span><span class="cx"> PassRefPtr<WebGLRenderbuffer> WebGLRenderingContext::createRenderbuffer()
</span><span class="cx"> {
</span><span class="cx"> if (isContextLostOrPending())
</span><del>- return 0;
</del><ins>+ return nullptr;
</ins><span class="cx"> RefPtr<WebGLRenderbuffer> o = WebGLRenderbuffer::create(this);
</span><span class="cx"> addSharedObject(o.get());
</span><span class="cx"> return o;
</span><span class="lines">@@ -1554,10 +1564,10 @@
</span><span class="cx"> {
</span><span class="cx"> UNUSED_PARAM(ec);
</span><span class="cx"> if (isContextLostOrPending())
</span><del>- return 0;
</del><ins>+ return nullptr;
</ins><span class="cx"> if (type != GraphicsContext3D::VERTEX_SHADER && type != GraphicsContext3D::FRAGMENT_SHADER) {
</span><span class="cx"> synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "createShader", "invalid shader type");
</span><del>- return 0;
</del><ins>+ return nullptr;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> RefPtr<WebGLShader> o = WebGLShader::create(this, type);
</span><span class="lines">@@ -2266,10 +2276,10 @@
</span><span class="cx"> {
</span><span class="cx"> UNUSED_PARAM(ec);
</span><span class="cx"> if (isContextLostOrPending() || !validateWebGLObject("getActiveAttrib", program))
</span><del>- return 0;
</del><ins>+ return nullptr;
</ins><span class="cx"> ActiveInfo info;
</span><span class="cx"> if (!m_context->getActiveAttrib(objectOrZero(program), index, info))
</span><del>- return 0;
</del><ins>+ return nullptr;
</ins><span class="cx">
</span><span class="cx"> LOG(WebGL, "Returning active attribute %d: %s", index, info.name.utf8().data());
</span><span class="cx">
</span><span class="lines">@@ -2283,7 +2293,7 @@
</span><span class="cx"> return 0;
</span><span class="cx"> ActiveInfo info;
</span><span class="cx"> if (!m_context->getActiveUniform(objectOrZero(program), index, info))
</span><del>- return 0;
</del><ins>+ return nullptr;
</ins><span class="cx"> if (!isGLES2Compliant())
</span><span class="cx"> if (info.size > 1 && !info.name.endsWith("[0]"))
</span><span class="cx"> info.name.append("[0]");
</span><span class="lines">@@ -2354,7 +2364,7 @@
</span><span class="cx"> PassRefPtr<WebGLContextAttributes> WebGLRenderingContext::getContextAttributes()
</span><span class="cx"> {
</span><span class="cx"> if (isContextLostOrPending())
</span><del>- return 0;
</del><ins>+ return nullptr;
</ins><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="cx">
</span><span class="lines">@@ -2376,13 +2386,15 @@
</span><span class="cx">
</span><span class="cx"> GC3Denum WebGLRenderingContext::getError()
</span><span class="cx"> {
</span><ins>+ if (isContextLostOrPending())
+ return GraphicsContext3D::NO_ERROR;
</ins><span class="cx"> return m_context->getError();
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> WebGLExtension* WebGLRenderingContext::getExtension(const String& name)
</span><span class="cx"> {
</span><span class="cx"> if (isContextLostOrPending())
</span><del>- return 0;
</del><ins>+ return nullptr;
</ins><span class="cx">
</span><span class="cx"> if (equalIgnoringCase(name, "WEBKIT_EXT_texture_filter_anisotropic")
</span><span class="cx"> && m_context->getExtensions()->supports("GL_EXT_texture_filter_anisotropic")) {
</span><span class="lines">@@ -2506,7 +2518,7 @@
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><del>- return 0;
</del><ins>+ return nullptr;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> WebGLGetInfo WebGLRenderingContext::getFramebufferAttachmentParameter(GC3Denum target, GC3Denum attachment, GC3Denum pname, ExceptionCode& ec)
</span><span class="lines">@@ -2938,14 +2950,14 @@
</span><span class="cx"> {
</span><span class="cx"> UNUSED_PARAM(ec);
</span><span class="cx"> if (isContextLostOrPending())
</span><del>- return 0;
</del><ins>+ return nullptr;
</ins><span class="cx"> switch (shaderType) {
</span><span class="cx"> case GraphicsContext3D::VERTEX_SHADER:
</span><span class="cx"> case GraphicsContext3D::FRAGMENT_SHADER:
</span><span class="cx"> break;
</span><span class="cx"> default:
</span><span class="cx"> synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getShaderPrecisionFormat", "invalid shader type");
</span><del>- return 0;
</del><ins>+ return nullptr;
</ins><span class="cx"> }
</span><span class="cx"> switch (precisionType) {
</span><span class="cx"> case GraphicsContext3D::LOW_FLOAT:
</span><span class="lines">@@ -2957,7 +2969,7 @@
</span><span class="cx"> break;
</span><span class="cx"> default:
</span><span class="cx"> synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getShaderPrecisionFormat", "invalid precision type");
</span><del>- return 0;
</del><ins>+ return nullptr;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> GC3Dint range[2] = {0, 0};
</span><span class="lines">@@ -3199,7 +3211,7 @@
</span><span class="cx"> for (GC3Dint i = 0; i < activeUniforms; i++) {
</span><span class="cx"> ActiveInfo info;
</span><span class="cx"> if (!m_context->getActiveUniform(objectOrZero(program), i, info))
</span><del>- return 0;
</del><ins>+ return nullptr;
</ins><span class="cx"> // Strip "[0]" from the name if it's an array.
</span><span class="cx"> if (info.name.endsWith("[0]"))
</span><span class="cx"> info.name = info.name.left(info.name.length() - 3);
</span><span class="lines">@@ -3860,7 +3872,7 @@
</span><span class="cx"> ImageBuffer* buf = m_generatedImageCache.imageBuffer(size);
</span><span class="cx"> if (!buf) {
</span><span class="cx"> synthesizeGLError(GraphicsContext3D::OUT_OF_MEMORY, "texImage2D", "out of memory");
</span><del>- return 0;
</del><ins>+ return nullptr;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> IntRect srcRect(IntPoint(), image->size());
</span><span class="lines">@@ -3922,7 +3934,7 @@
</span><span class="cx"> ImageBuffer* buf = m_generatedImageCache.imageBuffer(size);
</span><span class="cx"> if (!buf) {
</span><span class="cx"> synthesizeGLError(GraphicsContext3D::OUT_OF_MEMORY, "texImage2D", "out of memory");
</span><del>- return 0;
</del><ins>+ return nullptr;
</ins><span class="cx"> }
</span><span class="cx"> IntRect destRect(0, 0, size.width(), size.height());
</span><span class="cx"> // FIXME: Turn this into a GPU-GPU texture copy instead of CPU readback.
</span><span class="lines">@@ -5612,11 +5624,11 @@
</span><span class="cx"> break;
</span><span class="cx"> default:
</span><span class="cx"> synthesizeGLError(GraphicsContext3D::INVALID_ENUM, functionName, "invalid target");
</span><del>- return 0;
</del><ins>+ return nullptr;
</ins><span class="cx"> }
</span><span class="cx"> if (!buffer) {
</span><span class="cx"> synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName, "no buffer");
</span><del>- return 0;
</del><ins>+ return nullptr;
</ins><span class="cx"> }
</span><span class="cx"> switch (usage) {
</span><span class="cx"> case GraphicsContext3D::STREAM_DRAW:
</span><span class="lines">@@ -5625,7 +5637,7 @@
</span><span class="cx"> return buffer;
</span><span class="cx"> }
</span><span class="cx"> synthesizeGLError(GraphicsContext3D::INVALID_ENUM, functionName, "invalid usage");
</span><del>- return 0;
</del><ins>+ return nullptr;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> bool WebGLRenderingContext::validateHTMLImageElement(const char* functionName, HTMLImageElement* image, ExceptionCode& ec)
</span><span class="lines">@@ -5953,7 +5965,7 @@
</span><span class="cx">
</span><span class="cx"> std::unique_ptr<ImageBuffer> temp = ImageBuffer::create(size, 1);
</span><span class="cx"> if (!temp)
</span><del>- return 0;
</del><ins>+ return nullptr;
</ins><span class="cx"> i = std::min(m_capacity - 1, i);
</span><span class="cx"> m_buffers[i] = std::move(temp);
</span><span class="cx">
</span></span></pre>
</div>
</div>
</body>
</html>