<!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>[162036] 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/162036">162036</a></dd>
<dt>Author</dt> <dd>roger_fong@apple.com</dd>
<dt>Date</dt> <dd>2014-01-14 18:58:58 -0800 (Tue, 14 Jan 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>Add support for handling WebGL load policies.
https://bugs.webkit.org/show_bug.cgi?id=126935
&lt;rdar://problem/15790448&gt;.

Reviewed by Brent Fulgham.

* WebCore.xcodeproj/project.pbxproj: Copy over HTMLCanvasElement.h to the private headers directory.
* html/HTMLCanvasElement.cpp: Show the policy dialog and retrieve policies as necessary.
(WebCore::HTMLCanvasElement::getContext): Make sure that WebGL is allowed on the site.
                                          If it isn't, be sure to notify the frame loader client that
                                          the site is trying to create a WebGL context.
* loader/FrameLoaderClient.h:
(WebCore::FrameLoaderClient::webGLPolicyForHost): Used to get the WebGL load policy for a site.
* loader/FrameLoaderTypes.h:
* page/ChromeClient.h:
(WebCore::ChromeClient::webGLContextCreated): Called when a site is creating a WebGL context.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreWebCorexcodeprojprojectpbxproj">trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkSourceWebCorehtmlHTMLCanvasElementcpp">trunk/Source/WebCore/html/HTMLCanvasElement.cpp</a></li>
<li><a href="#trunkSourceWebCoreloaderFrameLoaderClienth">trunk/Source/WebCore/loader/FrameLoaderClient.h</a></li>
<li><a href="#trunkSourceWebCoreloaderFrameLoaderTypesh">trunk/Source/WebCore/loader/FrameLoaderTypes.h</a></li>
<li><a href="#trunkSourceWebCorepageChromeClienth">trunk/Source/WebCore/page/ChromeClient.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (162035 => 162036)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2014-01-15 02:57:18 UTC (rev 162035)
+++ trunk/Source/WebCore/ChangeLog        2014-01-15 02:58:58 UTC (rev 162036)
</span><span class="lines">@@ -1,3 +1,22 @@
</span><ins>+2014-01-14  Roger Fong  &lt;roger_fong@apple.com&gt;
+
+        Add support for handling WebGL load policies.
+        https://bugs.webkit.org/show_bug.cgi?id=126935
+        &lt;rdar://problem/15790448&gt;.
+
+        Reviewed by Brent Fulgham.
+
+        * WebCore.xcodeproj/project.pbxproj: Copy over HTMLCanvasElement.h to the private headers directory.
+        * html/HTMLCanvasElement.cpp: Show the policy dialog and retrieve policies as necessary.
+        (WebCore::HTMLCanvasElement::getContext): Make sure that WebGL is allowed on the site.
+                                                  If it isn't, be sure to notify the frame loader client that
+                                                  the site is trying to create a WebGL context.
+        * loader/FrameLoaderClient.h:
+        (WebCore::FrameLoaderClient::webGLPolicyForHost): Used to get the WebGL load policy for a site.
+        * loader/FrameLoaderTypes.h:
+        * page/ChromeClient.h:
+        (WebCore::ChromeClient::webGLContextCreated): Called when a site is creating a WebGL context.
+
</ins><span class="cx"> 2014-01-14  Anders Carlsson  &lt;andersca@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Create separate progress tracker clients
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (162035 => 162036)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2014-01-15 02:57:18 UTC (rev 162035)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2014-01-15 02:58:58 UTC (rev 162036)
</span><span class="lines">@@ -3241,7 +3241,7 @@
</span><span class="cx">                 93F199BB08245E59001E9ABC /* WebCoreKeyboardUIMode.h in Headers */ = {isa = PBXBuildFile; fileRef = BE983D95052A2E0A00892D85 /* WebCoreKeyboardUIMode.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 93F199BE08245E59001E9ABC /* BlockExceptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 65A640F00533BB1F0085E777 /* BlockExceptions.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 93F199DE08245E59001E9ABC /* Position.h in Headers */ = {isa = PBXBuildFile; fileRef = BE91FC8B06133666005E3790 /* Position.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><del>-                93F199E508245E59001E9ABC /* HTMLCanvasElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 51F6A3D60663BF04004D2919 /* HTMLCanvasElement.h */; };
</del><ins>+                93F199E508245E59001E9ABC /* HTMLCanvasElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 51F6A3D60663BF04004D2919 /* HTMLCanvasElement.h */; settings = {ATTRIBUTES = (Private, ); }; };
</ins><span class="cx">                 93F199EC08245E59001E9ABC /* XSLStyleSheet.h in Headers */ = {isa = PBXBuildFile; fileRef = BC06F24A06D18A7E004A6FA3 /* XSLStyleSheet.h */; };
</span><span class="cx">                 93F199ED08245E59001E9ABC /* XSLTProcessor.h in Headers */ = {isa = PBXBuildFile; fileRef = BC06F24C06D18A7E004A6FA3 /* XSLTProcessor.h */; };
</span><span class="cx">                 93F199F008245E59001E9ABC /* WebCoreView.h in Headers */ = {isa = PBXBuildFile; fileRef = BE855F7F0701E83500239769 /* WebCoreView.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="lines">@@ -23190,6 +23190,7 @@
</span><span class="cx">                                 E4B65A58132FA8E70070E7BE /* TileGrid.h in Headers */,
</span><span class="cx">                                 93F1992F08245E59001E9ABC /* Cursor.h in Headers */,
</span><span class="cx">                                 BC2272A20E82E87C00E7F975 /* CursorData.h in Headers */,
</span><ins>+                                93F199E508245E59001E9ABC /* HTMLCanvasElement.h in Headers */,
</ins><span class="cx">                                 868160D618766A130021E79D /* UserActivity.h in Headers */,
</span><span class="cx">                                 BC2272AD0E82E8F300E7F975 /* CursorList.h in Headers */,
</span><span class="cx">                                 62CD325A1157E57C0063B0A7 /* CustomEvent.h in Headers */,
</span><span class="lines">@@ -23953,7 +23954,6 @@
</span><span class="cx">                                 A871DE2C0A152AC800B12A68 /* HTMLBodyElement.h in Headers */,
</span><span class="cx">                                 A8CFF7AA0A156978000A4234 /* HTMLBRElement.h in Headers */,
</span><span class="cx">                                 A81369D2097374F600D74463 /* HTMLButtonElement.h in Headers */,
</span><del>-                                93F199E508245E59001E9ABC /* HTMLCanvasElement.h in Headers */,
</del><span class="cx">                                 07969DC017D14151007FF842 /* JSRTCStatsCallback.h in Headers */,
</span><span class="cx">                                 A8DF3FD0097FA0FC0052981B /* HTMLCollection.h in Headers */,
</span><span class="cx">                                 977B3865122883E900B81FF8 /* HTMLConstructionSite.h in Headers */,
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLCanvasElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLCanvasElement.cpp (162035 => 162036)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLCanvasElement.cpp        2014-01-15 02:57:18 UTC (rev 162035)
+++ trunk/Source/WebCore/html/HTMLCanvasElement.cpp        2014-01-15 02:58:58 UTC (rev 162036)
</span><span class="lines">@@ -33,13 +33,16 @@
</span><span class="cx"> #include &quot;CanvasPattern.h&quot;
</span><span class="cx"> #include &quot;CanvasRenderingContext2D.h&quot;
</span><span class="cx"> #include &quot;Chrome.h&quot;
</span><ins>+#include &quot;ChromeClient.h&quot;
</ins><span class="cx"> #include &quot;Document.h&quot;
</span><span class="cx"> #include &quot;ExceptionCode.h&quot;
</span><span class="cx"> #include &quot;Frame.h&quot;
</span><ins>+#include &quot;FrameLoaderClient.h&quot;
</ins><span class="cx"> #include &quot;GraphicsContext.h&quot;
</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><ins>+#include &quot;MainFrame.h&quot;
</ins><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">@@ -201,7 +204,7 @@
</span><span class="cx">     // once it is created. https://bugs.webkit.org/show_bug.cgi?id=117095
</span><span class="cx">     if (is2dType(type)) {
</span><span class="cx">         if (m_context &amp;&amp; !m_context-&gt;is2d())
</span><del>-            return 0;
</del><ins>+            return nullptr;
</ins><span class="cx">         if (!m_context) {
</span><span class="cx">             bool usesDashbardCompatibilityMode = false;
</span><span class="cx"> #if ENABLE(DASHBOARD_SUPPORT)
</span><span class="lines">@@ -223,6 +226,17 @@
</span><span class="cx">             if (m_context &amp;&amp; !m_context-&gt;is3d())
</span><span class="cx">                 return 0;
</span><span class="cx">             if (!m_context) {
</span><ins>+                Page* page = document().page();
+                if (page &amp;&amp; !document().url().isLocalFile()) {
+                    WebGLLoadPolicy policy = page-&gt;mainFrame().loader().client().webGLPolicyForHost(document().url().host());
+
+                    if (policy == WebGLAsk) {
+                        page-&gt;chrome().client().webGLContextCreated(this);
+                        return nullptr;
+                    }
+                    if (policy == WebGLBlock)
+                        return nullptr;
+                }
</ins><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 class="lines">@@ -235,7 +249,7 @@
</span><span class="cx"> #else
</span><span class="cx">     UNUSED_PARAM(attrs);
</span><span class="cx"> #endif
</span><del>-    return 0;
</del><ins>+    return nullptr;
</ins><span class="cx"> }
</span><span class="cx">     
</span><span class="cx"> bool HTMLCanvasElement::probablySupportsContext(const String&amp; type, CanvasContextAttributes*)
</span></span></pre></div>
<a id="trunkSourceWebCoreloaderFrameLoaderClienth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/FrameLoaderClient.h (162035 => 162036)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/FrameLoaderClient.h        2014-01-15 02:57:18 UTC (rev 162035)
+++ trunk/Source/WebCore/loader/FrameLoaderClient.h        2014-01-15 02:58:58 UTC (rev 162036)
</span><span class="lines">@@ -331,6 +331,7 @@
</span><span class="cx">         // Informs the embedder that a WebGL canvas inside this frame received a lost context
</span><span class="cx">         // notification with the given GL_ARB_robustness guilt/innocence code (see Extensions3D.h).
</span><span class="cx">         virtual void didLoseWebGLContext(int) { }
</span><ins>+        virtual WebGLLoadPolicy webGLPolicyForHost(const String&amp;) const { return WebGLAsk; }
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx">         virtual void forcePageTransitionIfNeeded() { }
</span></span></pre></div>
<a id="trunkSourceWebCoreloaderFrameLoaderTypesh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/FrameLoaderTypes.h (162035 => 162036)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/FrameLoaderTypes.h        2014-01-15 02:57:18 UTC (rev 162035)
+++ trunk/Source/WebCore/loader/FrameLoaderTypes.h        2014-01-15 02:58:58 UTC (rev 162036)
</span><span class="lines">@@ -105,6 +105,12 @@
</span><span class="cx">         AboutToInstantiatePlugin,
</span><span class="cx">         NotAboutToInstantiatePlugin
</span><span class="cx">     };
</span><ins>+    
+    enum WebGLLoadPolicy {
+        WebGLAsk = 0,
+        WebGLAllow,
+        WebGLBlock
+    };
</ins><span class="cx"> 
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorepageChromeClienth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/ChromeClient.h (162035 => 162036)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/ChromeClient.h        2014-01-15 02:57:18 UTC (rev 162035)
+++ trunk/Source/WebCore/page/ChromeClient.h        2014-01-15 02:58:58 UTC (rev 162036)
</span><span class="lines">@@ -428,6 +428,10 @@
</span><span class="cx">     // would likely want the page to remain running uninterrupted.
</span><span class="cx">     virtual void incrementActivePageCount() { }
</span><span class="cx">     virtual void decrementActivePageCount() { }
</span><ins>+    
+#if ENABLE(WEBGL)
+    virtual void webGLContextCreated(Element*) const { }
+#endif
</ins><span class="cx"> 
</span><span class="cx"> protected:
</span><span class="cx">     virtual ~ChromeClient() { }
</span></span></pre>
</div>
</div>

</body>
</html>