<!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>[50394] trunk/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/50394">50394</a></dd>
<dt>Author</dt> <dd>oliver@apple.com</dd>
<dt>Date</dt> <dd>2009-11-01 13:30:16 -0800 (Sun, 01 Nov 2009)</dd>
</dl>

<h3>Log Message</h3>
<pre>Fix layering violations in GraphicsContext3D
https://bugs.webkit.org/show_bug.cgi?id=30986

Reviewed by Darin Adler.

Remove uses of HTMLImageElement and HTMLCanvasElement</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkWebCoreChangeLog">trunk/WebCore/ChangeLog</a></li>
<li><a href="#trunkWebCorehtmlcanvasCanvasRenderingContext3Dcpp">trunk/WebCore/html/canvas/CanvasRenderingContext3D.cpp</a></li>
<li><a href="#trunkWebCoreplatformgraphicsGraphicsContext3Dh">trunk/WebCore/platform/graphics/GraphicsContext3D.h</a></li>
<li><a href="#trunkWebCoreplatformgraphicsmacGraphicsContext3DMaccpp">trunk/WebCore/platform/graphics/mac/GraphicsContext3DMac.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/ChangeLog (50393 => 50394)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/ChangeLog        2009-11-01 21:22:30 UTC (rev 50393)
+++ trunk/WebCore/ChangeLog        2009-11-01 21:30:16 UTC (rev 50394)
</span><span class="lines">@@ -1,3 +1,20 @@
</span><ins>+2009-10-31  Oliver Hunt  &lt;oliver@apple.com&gt;
+
+        Reviewed by Darin Adler.
+
+        Fix layering violations in GraphicsContext3D
+        https://bugs.webkit.org/show_bug.cgi?id=30986
+
+        Remove uses of HTMLImageElement and HTMLCanvasElement
+
+        * html/canvas/CanvasRenderingContext3D.cpp:
+        (WebCore::CanvasRenderingContext3D::texImage2D):
+        (WebCore::CanvasRenderingContext3D::texSubImage2D):
+        * platform/graphics/GraphicsContext3D.h:
+        * platform/graphics/mac/GraphicsContext3DMac.cpp:
+        (WebCore::GraphicsContext3D::texImage2D):
+        (WebCore::GraphicsContext3D::texSubImage2D):
+
</ins><span class="cx"> 2009-11-01  Joanmarie Diggs  &lt;joanmarie.diggs@gmail.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Reviewed by Jan Alonzo.
</span></span></pre></div>
<a id="trunkWebCorehtmlcanvasCanvasRenderingContext3Dcpp"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/html/canvas/CanvasRenderingContext3D.cpp (50393 => 50394)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/html/canvas/CanvasRenderingContext3D.cpp        2009-11-01 21:22:30 UTC (rev 50393)
+++ trunk/WebCore/html/canvas/CanvasRenderingContext3D.cpp        2009-11-01 21:30:16 UTC (rev 50394)
</span><span class="lines">@@ -37,6 +37,8 @@
</span><span class="cx"> #include &quot;CanvasTexture.h&quot;
</span><span class="cx"> #include &quot;CanvasShader.h&quot;
</span><span class="cx"> #include &quot;HTMLCanvasElement.h&quot;
</span><ins>+#include &quot;HTMLImageElement.h&quot;
+#include &quot;ImageBuffer.h&quot;
</ins><span class="cx"> #include &quot;RenderBox.h&quot;
</span><span class="cx"> #include &quot;RenderLayer.h&quot;
</span><span class="cx"> 
</span><span class="lines">@@ -1005,18 +1007,36 @@
</span><span class="cx"> void CanvasRenderingContext3D::texImage2D(unsigned target, unsigned level, HTMLImageElement* image,
</span><span class="cx">                                           bool flipY, bool premultiplyAlpha, ExceptionCode&amp; ec)
</span><span class="cx"> {
</span><ins>+    ec = 0;
+    if (!image) {
+        ec = TYPE_MISMATCH_ERR;
+        return;
+    }
+
+    CachedImage* cachedImage = image-&gt;cachedImage();
+    if (!cachedImage)
+        return;
+
</ins><span class="cx">     // FIXME: For now we ignore any errors returned
</span><del>-    ec = 0;
-    m_context-&gt;texImage2D(target, level, image, flipY, premultiplyAlpha);
</del><ins>+    m_context-&gt;texImage2D(target, level, cachedImage-&gt;image(), flipY, premultiplyAlpha);
</ins><span class="cx">     cleanupAfterGraphicsCall(false);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void CanvasRenderingContext3D::texImage2D(unsigned target, unsigned level, HTMLCanvasElement* canvas,
</span><span class="cx">                                           bool flipY, bool premultiplyAlpha, ExceptionCode&amp; ec)
</span><span class="cx"> {
</span><ins>+    ec = 0;
+    if (!canvas) {
+        ec = TYPE_MISMATCH_ERR;
+        return;
+    }
+
+    ImageBuffer* buffer = canvas-&gt;buffer();
+    if (!buffer)
+        return;
+
</ins><span class="cx">     // FIXME: For now we ignore any errors returned
</span><del>-    ec = 0;
-    m_context-&gt;texImage2D(target, level, canvas, flipY, premultiplyAlpha);
</del><ins>+    m_context-&gt;texImage2D(target, level, buffer-&gt;image(), flipY, premultiplyAlpha);
</ins><span class="cx">     cleanupAfterGraphicsCall(false);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -1067,7 +1087,16 @@
</span><span class="cx"> {
</span><span class="cx">     // FIXME: For now we ignore any errors returned
</span><span class="cx">     ec = 0;
</span><del>-    m_context-&gt;texSubImage2D(target, level, xoffset, yoffset, width, height, image, flipY, premultiplyAlpha);
</del><ins>+    if (!image) {
+        ec = TYPE_MISMATCH_ERR;
+        return;
+    }
+    
+    CachedImage* cachedImage = image-&gt;cachedImage();
+    if (!cachedImage)
+        return;
+
+    m_context-&gt;texSubImage2D(target, level, xoffset, yoffset, width, height, cachedImage-&gt;image(), flipY, premultiplyAlpha);
</ins><span class="cx">     cleanupAfterGraphicsCall(false);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -1075,9 +1104,18 @@
</span><span class="cx">                                              unsigned width, unsigned height, HTMLCanvasElement* canvas,
</span><span class="cx">                                              bool flipY, bool premultiplyAlpha, ExceptionCode&amp; ec)
</span><span class="cx"> {
</span><ins>+    ec = 0;
+    if (!canvas) {
+        ec = TYPE_MISMATCH_ERR;
+        return;
+    }
+    
+    ImageBuffer* buffer = canvas-&gt;buffer();
+    if (!buffer)
+        return;
+    
</ins><span class="cx">     // FIXME: For now we ignore any errors returned
</span><del>-    ec = 0;
-    m_context-&gt;texSubImage2D(target, level, xoffset, yoffset, width, height, canvas, flipY, premultiplyAlpha);
</del><ins>+    m_context-&gt;texSubImage2D(target, level, xoffset, yoffset, width, height, buffer-&gt;image(), flipY, premultiplyAlpha);
</ins><span class="cx">     cleanupAfterGraphicsCall(false);
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkWebCoreplatformgraphicsGraphicsContext3Dh"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/platform/graphics/GraphicsContext3D.h (50393 => 50394)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/platform/graphics/GraphicsContext3D.h        2009-11-01 21:22:30 UTC (rev 50393)
+++ trunk/WebCore/platform/graphics/GraphicsContext3D.h        2009-11-01 21:30:16 UTC (rev 50394)
</span><span class="lines">@@ -58,8 +58,7 @@
</span><span class="cx">     class CanvasRenderingContext3D;
</span><span class="cx">     class CanvasShader;
</span><span class="cx">     class CanvasTexture;
</span><del>-    class HTMLCanvasElement;
-    class HTMLImageElement;
</del><ins>+    class Image;
</ins><span class="cx">     class HTMLVideoElement;
</span><span class="cx">     class ImageData;
</span><span class="cx">     class WebKitCSSMatrix;
</span><span class="lines">@@ -236,10 +235,8 @@
</span><span class="cx">         int texImage2D(unsigned target, unsigned level, unsigned internalformat,
</span><span class="cx">                        unsigned width, unsigned height, unsigned border,
</span><span class="cx">                        unsigned format, unsigned type, ImageData* pixels);
</span><del>-        int texImage2D(unsigned target, unsigned level, HTMLImageElement* image,
</del><ins>+        int texImage2D(unsigned target, unsigned level, Image* image,
</ins><span class="cx">                        bool flipY, bool premultiplyAlpha);
</span><del>-        int texImage2D(unsigned target, unsigned level, HTMLCanvasElement* canvas,
-                       bool flipY, bool premultiplyAlpha);
</del><span class="cx">         int texImage2D(unsigned target, unsigned level, HTMLVideoElement* video,
</span><span class="cx">                        bool flipY, bool premultiplyAlpha);
</span><span class="cx"> 
</span><span class="lines">@@ -253,12 +250,9 @@
</span><span class="cx">                           unsigned width, unsigned height,
</span><span class="cx">                           unsigned format, unsigned type, ImageData* pixels);
</span><span class="cx">         int texSubImage2D(unsigned target, unsigned level, unsigned xoffset, unsigned yoffset,
</span><del>-                          unsigned width, unsigned height, HTMLImageElement* image,
</del><ins>+                          unsigned width, unsigned height, Image* image,
</ins><span class="cx">                           bool flipY, bool premultiplyAlpha);
</span><span class="cx">         int texSubImage2D(unsigned target, unsigned level, unsigned xoffset, unsigned yoffset,
</span><del>-                          unsigned width, unsigned height, HTMLCanvasElement* canvas,
-                          bool flipY, bool premultiplyAlpha);
-        int texSubImage2D(unsigned target, unsigned level, unsigned xoffset, unsigned yoffset,
</del><span class="cx">                           unsigned width, unsigned height, HTMLVideoElement* video,
</span><span class="cx">                           bool flipY, bool premultiplyAlpha);
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkWebCoreplatformgraphicsmacGraphicsContext3DMaccpp"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/platform/graphics/mac/GraphicsContext3DMac.cpp (50393 => 50394)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/platform/graphics/mac/GraphicsContext3DMac.cpp        2009-11-01 21:22:30 UTC (rev 50393)
+++ trunk/WebCore/platform/graphics/mac/GraphicsContext3DMac.cpp        2009-11-01 21:30:16 UTC (rev 50394)
</span><span class="lines">@@ -1568,42 +1568,18 @@
</span><span class="cx">     return -1;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-int GraphicsContext3D::texImage2D(unsigned target, unsigned level, HTMLImageElement* image, bool flipY, bool premultiplyAlpha)
</del><ins>+int GraphicsContext3D::texImage2D(unsigned target, unsigned level, Image* image, bool flipY, bool premultiplyAlpha)
</ins><span class="cx"> {
</span><span class="cx">     // FIXME: need to support flipY and premultiplyAlpha
</span><span class="cx">     UNUSED_PARAM(flipY);
</span><span class="cx">     UNUSED_PARAM(premultiplyAlpha);
</span><ins>+    ASSERT(image);
</ins><span class="cx">     
</span><del>-    if (!image)
-        return -1;
-    
</del><span class="cx">     ensureContext(m_contextObj);
</span><del>-    CachedImage* cachedImage = image-&gt;cachedImage();
-    if (!cachedImage)
-        return -1;
-    
-    imageToTexture(cachedImage-&gt;image(), target, level);
</del><ins>+    imageToTexture(image, target, level);
</ins><span class="cx">     return 0;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-int GraphicsContext3D::texImage2D(unsigned target, unsigned level, HTMLCanvasElement* canvas, bool flipY, bool premultiplyAlpha)
-{
-    // FIXME: need to support flipY and premultiplyAlpha
-    UNUSED_PARAM(flipY);
-    UNUSED_PARAM(premultiplyAlpha);
-    
-    if (!canvas)
-        return -1;
-    
-    ensureContext(m_contextObj);
-    ImageBuffer* buffer = canvas-&gt;buffer();
-    if (!buffer)
-        return -1;
-    
-    imageToTexture(buffer-&gt;image(), target, level);
-    return 0;
-}
-
</del><span class="cx"> int GraphicsContext3D::texImage2D(unsigned target, unsigned level, HTMLVideoElement* video, bool flipY, bool premultiplyAlpha)
</span><span class="cx"> {
</span><span class="cx">     // FIXME: need to implement this form
</span><span class="lines">@@ -1647,7 +1623,7 @@
</span><span class="cx">     return -1;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-int GraphicsContext3D::texSubImage2D(unsigned target, unsigned level, unsigned xoff, unsigned yoff, unsigned width, unsigned height, HTMLImageElement* image, bool flipY, bool premultiplyAlpha)
</del><ins>+int GraphicsContext3D::texSubImage2D(unsigned target, unsigned level, unsigned xoff, unsigned yoff, unsigned width, unsigned height, Image* image, bool flipY, bool premultiplyAlpha)
</ins><span class="cx"> {
</span><span class="cx">     // FIXME: we will need to deal with PixelStore params when dealing with image buffers that differ from the subimage size
</span><span class="cx">     UNUSED_PARAM(target);
</span><span class="lines">@@ -1664,23 +1640,6 @@
</span><span class="cx">     return -1;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-int GraphicsContext3D::texSubImage2D(unsigned target, unsigned level, unsigned xoff, unsigned yoff, unsigned width, unsigned height, HTMLCanvasElement* canvas, bool flipY, bool premultiplyAlpha)
-{
-    // FIXME: we will need to deal with PixelStore params when dealing with image buffers that differ from the subimage size
-    UNUSED_PARAM(target);
-    UNUSED_PARAM(level);
-    UNUSED_PARAM(xoff);
-    UNUSED_PARAM(yoff);
-    UNUSED_PARAM(width);
-    UNUSED_PARAM(height);
-    UNUSED_PARAM(canvas);
-
-    // FIXME: need to support flipY and premultiplyAlpha    
-    UNUSED_PARAM(flipY);
-    UNUSED_PARAM(premultiplyAlpha);
-    return -1;
-}
-
</del><span class="cx"> int GraphicsContext3D::texSubImage2D(unsigned target, unsigned level, unsigned xoff, unsigned yoff, unsigned width, unsigned height, HTMLVideoElement* video, bool flipY, bool premultiplyAlpha)
</span><span class="cx"> {
</span><span class="cx">     // FIXME: we will need to deal with PixelStore params when dealing with image buffers that differ from the subimage size
</span></span></pre>
</div>
</div>

</body>
</html>