<!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>[150206] trunk/Source</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/150206">150206</a></dd>
<dt>Author</dt> <dd>beidson@apple.com</dd>
<dt>Date</dt> <dd>2013-05-16 14:02:11 -0700 (Thu, 16 May 2013)</dd>
</dl>

<h3>Log Message</h3>
<pre>svg/as-image/img-zoom-svg-stylesheet.html crashes with NetworkProcess enabled.
&lt;rdar://problem/13837408&gt; and https://bugs.webkit.org/show_bug.cgi?id=115917

Reviewed by Sam Weinig.

Source/WebCore:

Give WebKit2 the ability to not mis-cast.

* loader/FrameLoaderClient.h:
(WebCore::FrameLoaderClient::isEmptyFrameLoaderClient): Defaults to false, and include a FIXME
  to remove it once https://bugs.webkit.org/show_bug.cgi?id=116233 is resolved.

* loader/EmptyClients.h: Make isEmptyFrameLoaderClient() return true, and add a FIXME to remove it.

Source/WebKit2:

* NetworkProcess/SchedulableLoader.cpp:
(WebKit::SchedulableLoader::SchedulableLoader): ASSERT that either there’s a frame and page ID, or
  that the client cannot be asked for credentials.

* WebProcess/Network/WebResourceLoadScheduler.cpp:
(WebKit::WebResourceLoadScheduler::scheduleLoad): Only cast the FrameLoaderClient and get WebFrame/WebPage
  if that is actually possible. Set the clientCredentialPolicy based on whether or not WebFrame/WebPage are
  available since they are needed to ask the UIProcess for credentials. ASSERT that either there’s both
  a frame and page ID or that the client won’t be asked for credentials.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreloaderEmptyClientsh">trunk/Source/WebCore/loader/EmptyClients.h</a></li>
<li><a href="#trunkSourceWebCoreloaderFrameLoaderClienth">trunk/Source/WebCore/loader/FrameLoaderClient.h</a></li>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2NetworkProcessSchedulableLoadercpp">trunk/Source/WebKit2/NetworkProcess/SchedulableLoader.cpp</a></li>
<li><a href="#trunkSourceWebKit2WebProcessNetworkWebResourceLoadSchedulercpp">trunk/Source/WebKit2/WebProcess/Network/WebResourceLoadScheduler.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (150205 => 150206)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2013-05-16 20:50:06 UTC (rev 150205)
+++ trunk/Source/WebCore/ChangeLog        2013-05-16 21:02:11 UTC (rev 150206)
</span><span class="lines">@@ -1,3 +1,18 @@
</span><ins>+2013-05-16  Brady Eidson  &lt;beidson@apple.com&gt;
+
+        svg/as-image/img-zoom-svg-stylesheet.html crashes with NetworkProcess enabled.
+        &lt;rdar://problem/13837408&gt; and https://bugs.webkit.org/show_bug.cgi?id=115917
+
+        Reviewed by Sam Weinig.
+
+        Give WebKit2 the ability to not mis-cast.
+
+        * loader/FrameLoaderClient.h:
+        (WebCore::FrameLoaderClient::isEmptyFrameLoaderClient): Defaults to false, and include a FIXME
+          to remove it once https://bugs.webkit.org/show_bug.cgi?id=116233 is resolved.
+
+        * loader/EmptyClients.h: Make isEmptyFrameLoaderClient() return true, and add a FIXME to remove it.
+
</ins><span class="cx"> 2013-05-14  Martin Robinson  &lt;mrobinson@igalia.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [GTK] Add support for building WebCore to the cmake build
</span></span></pre></div>
<a id="trunkSourceWebCoreloaderEmptyClientsh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/EmptyClients.h (150205 => 150206)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/EmptyClients.h        2013-05-16 20:50:06 UTC (rev 150205)
+++ trunk/Source/WebCore/loader/EmptyClients.h        2013-05-16 21:02:11 UTC (rev 150206)
</span><span class="lines">@@ -209,6 +209,8 @@
</span><span class="cx">     virtual bool shouldNotifyOnFormChanges() { return false; }
</span><span class="cx"> };
</span><span class="cx"> 
</span><ins>+// FIXME (bug 116233): Get rid of EmptyFrameLoaderClient. It is a travesty.
+
</ins><span class="cx"> class EmptyFrameLoaderClient : public FrameLoaderClient {
</span><span class="cx">     WTF_MAKE_NONCOPYABLE(EmptyFrameLoaderClient); WTF_MAKE_FAST_ALLOCATED;
</span><span class="cx"> public:
</span><span class="lines">@@ -373,6 +375,8 @@
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx">     virtual PassRefPtr&lt;FrameNetworkingContext&gt; createNetworkingContext() OVERRIDE;
</span><ins>+
+    virtual bool isEmptyFrameLoaderClient() OVERRIDE { return true; }
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> class EmptyTextCheckerClient : public TextCheckerClient {
</span></span></pre></div>
<a id="trunkSourceWebCoreloaderFrameLoaderClienth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/FrameLoaderClient.h (150205 => 150206)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/FrameLoaderClient.h        2013-05-16 20:50:06 UTC (rev 150205)
+++ trunk/Source/WebCore/loader/FrameLoaderClient.h        2013-05-16 21:02:11 UTC (rev 150206)
</span><span class="lines">@@ -348,6 +348,9 @@
</span><span class="cx">         virtual void dispatchWillInsertBody() { }
</span><span class="cx"> 
</span><span class="cx">         virtual void dispatchDidChangeResourcePriority(unsigned long /*identifier*/, ResourceLoadPriority) { }
</span><ins>+
+        // FIXME (bug 116233): We need to get rid of EmptyFrameLoaderClient completely, then this will no longer be needed.
+        virtual bool isEmptyFrameLoaderClient() { return false; }
</ins><span class="cx">     };
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (150205 => 150206)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2013-05-16 20:50:06 UTC (rev 150205)
+++ trunk/Source/WebKit2/ChangeLog        2013-05-16 21:02:11 UTC (rev 150206)
</span><span class="lines">@@ -1,3 +1,20 @@
</span><ins>+2013-05-16  Brady Eidson  &lt;beidson@apple.com&gt;
+
+        svg/as-image/img-zoom-svg-stylesheet.html crashes with NetworkProcess enabled.
+        &lt;rdar://problem/13837408&gt; and https://bugs.webkit.org/show_bug.cgi?id=115917
+
+        Reviewed by Sam Weinig.
+
+        * NetworkProcess/SchedulableLoader.cpp:
+        (WebKit::SchedulableLoader::SchedulableLoader): ASSERT that either there’s a frame and page ID, or
+          that the client cannot be asked for credentials.
+
+        * WebProcess/Network/WebResourceLoadScheduler.cpp:
+        (WebKit::WebResourceLoadScheduler::scheduleLoad): Only cast the FrameLoaderClient and get WebFrame/WebPage
+          if that is actually possible. Set the clientCredentialPolicy based on whether or not WebFrame/WebPage are
+          available since they are needed to ask the UIProcess for credentials. ASSERT that either there’s both
+          a frame and page ID or that the client won’t be asked for credentials.
+
</ins><span class="cx"> 2013-05-16  Timothy Hatcher  &lt;timothy@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Make the Find Banner in Safari work again with the docked Web Inspector.
</span></span></pre></div>
<a id="trunkSourceWebKit2NetworkProcessSchedulableLoadercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/NetworkProcess/SchedulableLoader.cpp (150205 => 150206)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/NetworkProcess/SchedulableLoader.cpp        2013-05-16 20:50:06 UTC (rev 150205)
+++ trunk/Source/WebKit2/NetworkProcess/SchedulableLoader.cpp        2013-05-16 21:02:11 UTC (rev 150206)
</span><span class="lines">@@ -51,6 +51,11 @@
</span><span class="cx">     , m_isLoadingMainResource(parameters.isMainResource)
</span><span class="cx">     , m_connection(connection)
</span><span class="cx"> {
</span><ins>+    // Either this loader has both a webPageID and webFrameID, or it is not allowed to ask the client for authentication credentials.
+    // FIXME: This is necessary because of the existence of EmptyFrameLoaderClient in WebCore.
+    //        Once bug 116233 is resolved, this ASSERT can just be &quot;m_webPageID &amp;&amp; m_webFrameID&quot;
+    ASSERT((m_webPageID &amp;&amp; m_webFrameID) || m_clientCredentialPolicy == DoNotAskClientForAnyCredentials);
+
</ins><span class="cx">     for (size_t i = 0, count = parameters.requestBodySandboxExtensions.size(); i &lt; count; ++i) {
</span><span class="cx">         if (RefPtr&lt;SandboxExtension&gt; extension = SandboxExtension::create(parameters.requestBodySandboxExtensions[i]))
</span><span class="cx">             m_requestBodySandboxExtensions.append(extension);
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessNetworkWebResourceLoadSchedulercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/Network/WebResourceLoadScheduler.cpp (150205 => 150206)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/Network/WebResourceLoadScheduler.cpp        2013-05-16 20:50:06 UTC (rev 150205)
+++ trunk/Source/WebKit2/WebProcess/Network/WebResourceLoadScheduler.cpp        2013-05-16 21:02:11 UTC (rev 150206)
</span><span class="lines">@@ -105,22 +105,32 @@
</span><span class="cx">     StoredCredentials allowStoredCredentials = resourceLoader-&gt;shouldUseCredentialStorage() ? AllowStoredCredentials : DoNotAllowStoredCredentials;
</span><span class="cx">     bool privateBrowsingEnabled = resourceLoader-&gt;frameLoader()-&gt;frame()-&gt;settings()-&gt;privateBrowsingEnabled();
</span><span class="cx"> 
</span><del>-    WebFrame* webFrame = static_cast&lt;WebFrameLoaderClient*&gt;(resourceLoader-&gt;frameLoader()-&gt;client())-&gt;webFrame();
-    WebPage* webPage = webFrame-&gt;page();
</del><ins>+    // FIXME: Some entities in WebCore use WebCore's &quot;EmptyFrameLoaderClient&quot; instead of having a proper WebFrameLoaderClient.
+    // EmptyFrameLoaderClient shouldn't exist and everything should be using a WebFrameLoaderClient,
+    // but in the meantime we have to make sure not to mis-cast.
+    WebFrame* webFrame = 0;
+    WebPage* webPage = 0;
+    if (!resourceLoader-&gt;frameLoader()-&gt;client()-&gt;isEmptyFrameLoaderClient()) {
+        webFrame = static_cast&lt;WebFrameLoaderClient*&gt;(resourceLoader-&gt;frameLoader()-&gt;client())-&gt;webFrame();
+        webPage = webFrame-&gt;page();
+    }
</ins><span class="cx"> 
</span><span class="cx">     NetworkResourceLoadParameters loadParameters;
</span><span class="cx">     loadParameters.identifier = identifier;
</span><del>-    loadParameters.webPageID = webPage-&gt;pageID();
-    loadParameters.webFrameID = webFrame-&gt;frameID();
</del><ins>+    loadParameters.webPageID = webPage ? webPage-&gt;pageID() : 0;
+    loadParameters.webFrameID = webFrame ? webFrame-&gt;frameID() : 0;
</ins><span class="cx">     loadParameters.request = resourceLoader-&gt;request();
</span><span class="cx">     loadParameters.priority = priority;
</span><span class="cx">     loadParameters.contentSniffingPolicy = contentSniffingPolicy;
</span><span class="cx">     loadParameters.allowStoredCredentials = allowStoredCredentials;
</span><del>-    loadParameters.clientCredentialPolicy = resourceLoader-&gt;clientCredentialPolicy();
</del><ins>+    // If there is no WebFrame then this resource cannot be authenticated with the client.
+    loadParameters.clientCredentialPolicy = (webFrame &amp;&amp; webPage) ? resourceLoader-&gt;clientCredentialPolicy() : DoNotAskClientForAnyCredentials;
</ins><span class="cx">     loadParameters.inPrivateBrowsingMode = privateBrowsingEnabled;
</span><span class="cx">     loadParameters.shouldClearReferrerOnHTTPSToHTTPRedirect = shouldClearReferrerOnHTTPSToHTTPRedirect;
</span><span class="cx">     loadParameters.isMainResource = resource &amp;&amp; resource-&gt;type() == CachedResource::MainResource;
</span><span class="cx"> 
</span><ins>+    ASSERT((loadParameters.webPageID &amp;&amp; loadParameters.webFrameID) || loadParameters.clientCredentialPolicy == DoNotAskClientForAnyCredentials);
+
</ins><span class="cx">     if (!WebProcess::shared().networkConnection()-&gt;connection()-&gt;send(Messages::NetworkConnectionToWebProcess::ScheduleResourceLoad(loadParameters), 0)) {
</span><span class="cx">         // We probably failed to schedule this load with the NetworkProcess because it had crashed.
</span><span class="cx">         // This load will never succeed so we will schedule it to fail asynchronously.
</span></span></pre>
</div>
</div>

</body>
</html>