<!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>[183132] branches/safari-600.7-branch</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/183132">183132</a></dd>
<dt>Author</dt> <dd>matthew_hanson@apple.com</dd>
<dt>Date</dt> <dd>2015-04-22 13:55:46 -0700 (Wed, 22 Apr 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>Merged <a href="http://trac.webkit.org/projects/webkit/changeset/181656">r181656</a>. &lt;rdar://problem/20545362&gt;</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#branchessafari6007branchLayoutTestsChangeLog">branches/safari-600.7-branch/LayoutTests/ChangeLog</a></li>
<li><a href="#branchessafari6007branchSourceWebCoreChangeLog">branches/safari-600.7-branch/Source/WebCore/ChangeLog</a></li>
<li><a href="#branchessafari6007branchSourceWebCoredomScriptedAnimationControllercpp">branches/safari-600.7-branch/Source/WebCore/dom/ScriptedAnimationController.cpp</a></li>
<li><a href="#branchessafari6007branchSourceWebCoredomScriptedAnimationControllerh">branches/safari-600.7-branch/Source/WebCore/dom/ScriptedAnimationController.h</a></li>
<li><a href="#branchessafari6007branchSourceWebCorepageChromeClienth">branches/safari-600.7-branch/Source/WebCore/page/ChromeClient.h</a></li>
<li><a href="#branchessafari6007branchSourceWebCoreplatformgraphicsDisplayRefreshMonitorcpp">branches/safari-600.7-branch/Source/WebCore/platform/graphics/DisplayRefreshMonitor.cpp</a></li>
<li><a href="#branchessafari6007branchSourceWebCoreplatformgraphicsDisplayRefreshMonitorh">branches/safari-600.7-branch/Source/WebCore/platform/graphics/DisplayRefreshMonitor.h</a></li>
<li><a href="#branchessafari6007branchSourceWebCoreplatformgraphicsDisplayRefreshMonitorClienth">branches/safari-600.7-branch/Source/WebCore/platform/graphics/DisplayRefreshMonitorClient.h</a></li>
<li><a href="#branchessafari6007branchSourceWebCoreplatformgraphicsDisplayRefreshMonitorManagercpp">branches/safari-600.7-branch/Source/WebCore/platform/graphics/DisplayRefreshMonitorManager.cpp</a></li>
<li><a href="#branchessafari6007branchSourceWebCoreplatformgraphicsDisplayRefreshMonitorManagerh">branches/safari-600.7-branch/Source/WebCore/platform/graphics/DisplayRefreshMonitorManager.h</a></li>
<li><a href="#branchessafari6007branchSourceWebCoreplatformgraphicsGraphicsLayerUpdatercpp">branches/safari-600.7-branch/Source/WebCore/platform/graphics/GraphicsLayerUpdater.cpp</a></li>
<li><a href="#branchessafari6007branchSourceWebCoreplatformgraphicsGraphicsLayerUpdaterh">branches/safari-600.7-branch/Source/WebCore/platform/graphics/GraphicsLayerUpdater.h</a></li>
<li><a href="#branchessafari6007branchSourceWebCorerenderingRenderLayerCompositorcpp">branches/safari-600.7-branch/Source/WebCore/rendering/RenderLayerCompositor.cpp</a></li>
<li><a href="#branchessafari6007branchSourceWebCorerenderingRenderLayerCompositorh">branches/safari-600.7-branch/Source/WebCore/rendering/RenderLayerCompositor.h</a></li>
<li><a href="#branchessafari6007branchSourceWebKit2ChangeLog">branches/safari-600.7-branch/Source/WebKit2/ChangeLog</a></li>
<li><a href="#branchessafari6007branchSourceWebKit2WebProcessWebCoreSupportWebChromeClientcpp">branches/safari-600.7-branch/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp</a></li>
<li><a href="#branchessafari6007branchSourceWebKit2WebProcessWebCoreSupportWebChromeClienth">branches/safari-600.7-branch/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="branchessafari6007branchLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-600.7-branch/LayoutTests/ChangeLog (183131 => 183132)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.7-branch/LayoutTests/ChangeLog        2015-04-22 20:55:36 UTC (rev 183131)
+++ branches/safari-600.7-branch/LayoutTests/ChangeLog        2015-04-22 20:55:46 UTC (rev 183132)
</span><span class="lines">@@ -1,3 +1,20 @@
</span><ins>+2015-04-22  Matthew Hanson  &lt;matthew_hanson@apple.com&gt;
+
+        Merge r181656. rdar://problem/20545362
+
+    2015-03-17  Timothy Horton  &lt;timothy_horton@apple.com&gt;
+
+            Reproducible null deref under ScriptedAnimationController::createDisplayRefreshMonitor
+            https://bugs.webkit.org/show_bug.cgi?id=142776
+            &lt;rdar://problem/18921338&gt;
+
+            Reviewed by Alexey Proskuryakov.
+
+            * fast/animation/request-animation-frame-unparented-iframe-crash-expected.txt: Added.
+            * fast/animation/request-animation-frame-unparented-iframe-crash.html: Added.
+            Add a test that ensures that calling requestAnimationFrame on a recently-unparented
+            frame doesn't crash.
+
</ins><span class="cx"> 2015-04-17  Lucas Forschler  &lt;lforschler@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">     Rollout r182965
</span></span></pre></div>
<a id="branchessafari6007branchSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-600.7-branch/Source/WebCore/ChangeLog (183131 => 183132)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.7-branch/Source/WebCore/ChangeLog        2015-04-22 20:55:36 UTC (rev 183131)
+++ branches/safari-600.7-branch/Source/WebCore/ChangeLog        2015-04-22 20:55:46 UTC (rev 183132)
</span><span class="lines">@@ -1,5 +1,68 @@
</span><span class="cx"> 2015-04-22  Matthew Hanson  &lt;matthew_hanson@apple.com&gt;
</span><span class="cx"> 
</span><ins>+        Merge r181656. rdar://problem/20545362
+
+    2015-03-17  Timothy Horton  &lt;timothy_horton@apple.com&gt;
+
+            Reproducible null deref under ScriptedAnimationController::createDisplayRefreshMonitor
+            https://bugs.webkit.org/show_bug.cgi?id=142776
+            &lt;rdar://problem/18921338&gt;
+
+            Reviewed by Alexey Proskuryakov.
+
+            Test: fast/animation/request-animation-frame-unparented-iframe-crash.html
+
+            In some cases (like the new test), we can end up trying to start
+            requestAnimationFrame on a Document that has no Page. Most paths null-checked
+            the Page and did the right thing, but one failed to do so. In addition,
+            the current fallback (when Page is null) can result in us constructing
+            the wrong kind of DisplayRefreshMonitor, which could lead to trouble
+            down the road when it's reused. Instead, just completely avoid making a
+            DisplayRefreshMonitor in the null-page case.
+
+            * dom/ScriptedAnimationController.cpp:
+            (WebCore::ScriptedAnimationController::createDisplayRefreshMonitor):
+            If the page is null, bail.
+
+            * dom/ScriptedAnimationController.h:
+            * platform/graphics/DisplayRefreshMonitor.cpp:
+            (WebCore::DisplayRefreshMonitor::create):
+            Use Optional&lt;&gt; to make it easy to distinguish between ChromeClient
+            being unreachable (because we don't have a Page for some reason) and
+            ChromeClient declaring that it doesn't want to override the type of
+            DisplayRefreshMonitor that is created.
+
+            If ChromeClient was unreachable for some reason, we'll get back an engaged
+            nullptr and return it (instead of creating a DisplayRefreshMonitor based
+            on the platform). This avoids creating the wrong type of DisplayRefreshMonitor
+            in the rare case where we can't reach the ChromeClient (e.g. a freshly unparented
+            IFrame).
+
+            If instead the client returns a disengaged Nullopt, we'll interpret that as
+            &quot;construct the default type&quot;, which falls back on the platform #ifdefs to
+            decide what to make.
+
+            * platform/graphics/DisplayRefreshMonitorManager.cpp:
+            (WebCore::DisplayRefreshMonitorManager::ensureMonitorForClient):
+            (WebCore::DisplayRefreshMonitorManager::scheduleAnimation):
+            Silently handle the case where we failed to make a DisplayRefreshMonitor.
+
+            * platform/graphics/DisplayRefreshMonitor.h:
+            * platform/graphics/DisplayRefreshMonitorClient.h:
+            * platform/graphics/GraphicsLayerUpdater.cpp:
+            (WebCore::GraphicsLayerUpdater::createDisplayRefreshMonitor):
+            * platform/graphics/GraphicsLayerUpdater.h:
+            * rendering/RenderLayerCompositor.cpp:
+            (WebCore::RenderLayerCompositor::createDisplayRefreshMonitor):
+            * rendering/RenderLayerCompositor.h:
+            Adjust to the new signature of createDisplayRefreshMonitor, and return
+            an engaged (nullptr) Optional if we can't get to ChromeClient for any reason.
+
+            * page/ChromeClient.h:
+            Return Nullopt (indicating a lack of override) by default.
+
+2015-04-22  Matthew Hanson  &lt;matthew_hanson@apple.com&gt;
+
</ins><span class="cx">         Merge r180520. rdar://problem/20545427
</span><span class="cx"> 
</span><span class="cx">     2015-02-22  Dean Jackson  &lt;dino@apple.com&gt;
</span></span></pre></div>
<a id="branchessafari6007branchSourceWebCoredomScriptedAnimationControllercpp"></a>
<div class="modfile"><h4>Modified: branches/safari-600.7-branch/Source/WebCore/dom/ScriptedAnimationController.cpp (183131 => 183132)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.7-branch/Source/WebCore/dom/ScriptedAnimationController.cpp        2015-04-22 20:55:36 UTC (rev 183131)
+++ branches/safari-600.7-branch/Source/WebCore/dom/ScriptedAnimationController.cpp        2015-04-22 20:55:46 UTC (rev 183132)
</span><span class="lines">@@ -226,9 +226,11 @@
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx"> #if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)
</span><del>-PassRefPtr&lt;DisplayRefreshMonitor&gt; ScriptedAnimationController::createDisplayRefreshMonitor(PlatformDisplayID displayID) const
</del><ins>+Optional&lt;RefPtr&lt;DisplayRefreshMonitor&gt;&gt; ScriptedAnimationController::createDisplayRefreshMonitor(PlatformDisplayID displayID) const
</ins><span class="cx"> {
</span><del>-    return m_document-&gt;page()-&gt;chrome().client().createDisplayRefreshMonitor(displayID);
</del><ins>+    if (!m_document-&gt;page())
+        return Optional&lt;RefPtr&lt;DisplayRefreshMonitor&gt;&gt;(nullptr);
+    return Optional&lt;RefPtr&lt;DisplayRefreshMonitor&gt;&gt;(m_document-&gt;page()-&gt;chrome().client().createDisplayRefreshMonitor(displayID));
</ins><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx"> 
</span></span></pre></div>
<a id="branchessafari6007branchSourceWebCoredomScriptedAnimationControllerh"></a>
<div class="modfile"><h4>Modified: branches/safari-600.7-branch/Source/WebCore/dom/ScriptedAnimationController.h (183131 => 183132)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.7-branch/Source/WebCore/dom/ScriptedAnimationController.h        2015-04-22 20:55:36 UTC (rev 183131)
+++ branches/safari-600.7-branch/Source/WebCore/dom/ScriptedAnimationController.h        2015-04-22 20:55:46 UTC (rev 183132)
</span><span class="lines">@@ -91,7 +91,7 @@
</span><span class="cx"> #if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)
</span><span class="cx">     // Override for DisplayRefreshMonitorClient
</span><span class="cx">     virtual void displayRefreshFired(double timestamp) override;
</span><del>-    virtual PassRefPtr&lt;DisplayRefreshMonitor&gt; createDisplayRefreshMonitor(PlatformDisplayID) const override;
</del><ins>+    virtual Optional&lt;RefPtr&lt;DisplayRefreshMonitor&gt;&gt; createDisplayRefreshMonitor(PlatformDisplayID) const override;
</ins><span class="cx"> 
</span><span class="cx">     bool m_isUsingTimer;
</span><span class="cx">     bool m_isThrottled;
</span></span></pre></div>
<a id="branchessafari6007branchSourceWebCorepageChromeClienth"></a>
<div class="modfile"><h4>Modified: branches/safari-600.7-branch/Source/WebCore/page/ChromeClient.h (183131 => 183132)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.7-branch/Source/WebCore/page/ChromeClient.h        2015-04-22 20:55:36 UTC (rev 183131)
+++ branches/safari-600.7-branch/Source/WebCore/page/ChromeClient.h        2015-04-22 20:55:46 UTC (rev 183132)
</span><span class="lines">@@ -39,6 +39,7 @@
</span><span class="cx"> #include &quot;WebCoreKeyboardUIMode.h&quot;
</span><span class="cx"> #include &lt;runtime/ConsoleTypes.h&gt;
</span><span class="cx"> #include &lt;wtf/Forward.h&gt;
</span><ins>+#include &lt;wtf/Optional.h&gt;
</ins><span class="cx"> #include &lt;wtf/PassOwnPtr.h&gt;
</span><span class="cx"> #include &lt;wtf/Vector.h&gt;
</span><span class="cx"> 
</span><span class="lines">@@ -295,7 +296,7 @@
</span><span class="cx">     virtual GraphicsLayerFactory* graphicsLayerFactory() const { return nullptr; }
</span><span class="cx"> 
</span><span class="cx"> #if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)
</span><del>-    virtual PassRefPtr&lt;DisplayRefreshMonitor&gt; createDisplayRefreshMonitor(PlatformDisplayID) const { return nullptr; }
</del><ins>+    virtual Optional&lt;RefPtr&lt;DisplayRefreshMonitor&gt;&gt; createDisplayRefreshMonitor(PlatformDisplayID) const { return Nullopt; }
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx">     // Pass 0 as the GraphicsLayer to detatch the root layer.
</span></span></pre></div>
<a id="branchessafari6007branchSourceWebCoreplatformgraphicsDisplayRefreshMonitorcpp"></a>
<div class="modfile"><h4>Modified: branches/safari-600.7-branch/Source/WebCore/platform/graphics/DisplayRefreshMonitor.cpp (183131 => 183132)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.7-branch/Source/WebCore/platform/graphics/DisplayRefreshMonitor.cpp        2015-04-22 20:55:36 UTC (rev 183131)
+++ branches/safari-600.7-branch/Source/WebCore/platform/graphics/DisplayRefreshMonitor.cpp        2015-04-22 20:55:46 UTC (rev 183132)
</span><span class="lines">@@ -35,13 +35,15 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><del>-PassRefPtr&lt;DisplayRefreshMonitor&gt; DisplayRefreshMonitor::create(DisplayRefreshMonitorClient* client)
</del><ins>+RefPtr&lt;DisplayRefreshMonitor&gt; DisplayRefreshMonitor::create(DisplayRefreshMonitorClient* client)
</ins><span class="cx"> {
</span><span class="cx">     PlatformDisplayID displayID = client-&gt;displayID();
</span><span class="cx"> 
</span><del>-    if (RefPtr&lt;DisplayRefreshMonitor&gt; monitor = client-&gt;createDisplayRefreshMonitor(displayID))
-        return monitor.release();
</del><ins>+    if (Optional&lt;RefPtr&lt;DisplayRefreshMonitor&gt;&gt; monitor = client-&gt;createDisplayRefreshMonitor(displayID))
+        return monitor.value();
</ins><span class="cx"> 
</span><ins>+    // If ChromeClient returned Nullopt, we'll go ahead and make one of the default type.
+
</ins><span class="cx"> #if PLATFORM(MAC)
</span><span class="cx">     return DisplayRefreshMonitorMac::create(displayID);
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="branchessafari6007branchSourceWebCoreplatformgraphicsDisplayRefreshMonitorh"></a>
<div class="modfile"><h4>Modified: branches/safari-600.7-branch/Source/WebCore/platform/graphics/DisplayRefreshMonitor.h (183131 => 183132)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.7-branch/Source/WebCore/platform/graphics/DisplayRefreshMonitor.h        2015-04-22 20:55:36 UTC (rev 183131)
+++ branches/safari-600.7-branch/Source/WebCore/platform/graphics/DisplayRefreshMonitor.h        2015-04-22 20:55:46 UTC (rev 183132)
</span><span class="lines">@@ -41,7 +41,7 @@
</span><span class="cx"> 
</span><span class="cx"> class DisplayRefreshMonitor : public RefCounted&lt;DisplayRefreshMonitor&gt; {
</span><span class="cx"> public:
</span><del>-    static PassRefPtr&lt;DisplayRefreshMonitor&gt; create(DisplayRefreshMonitorClient*);
</del><ins>+    static RefPtr&lt;DisplayRefreshMonitor&gt; create(DisplayRefreshMonitorClient*);
</ins><span class="cx">     virtual ~DisplayRefreshMonitor();
</span><span class="cx">     
</span><span class="cx">     // Return true if callback request was scheduled, false if it couldn't be
</span></span></pre></div>
<a id="branchessafari6007branchSourceWebCoreplatformgraphicsDisplayRefreshMonitorClienth"></a>
<div class="modfile"><h4>Modified: branches/safari-600.7-branch/Source/WebCore/platform/graphics/DisplayRefreshMonitorClient.h (183131 => 183132)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.7-branch/Source/WebCore/platform/graphics/DisplayRefreshMonitorClient.h        2015-04-22 20:55:36 UTC (rev 183131)
+++ branches/safari-600.7-branch/Source/WebCore/platform/graphics/DisplayRefreshMonitorClient.h        2015-04-22 20:55:46 UTC (rev 183132)
</span><span class="lines">@@ -29,6 +29,7 @@
</span><span class="cx"> #if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)
</span><span class="cx"> 
</span><span class="cx"> #include &quot;PlatformScreen.h&quot;
</span><ins>+#include &lt;wtf/Optional.h&gt;
</ins><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><span class="lines">@@ -43,7 +44,10 @@
</span><span class="cx">     // Always called on the main thread.
</span><span class="cx">     virtual void displayRefreshFired(double timestamp) = 0;
</span><span class="cx"> 
</span><del>-    virtual PassRefPtr&lt;DisplayRefreshMonitor&gt; createDisplayRefreshMonitor(PlatformDisplayID) const = 0;
</del><ins>+    // Returning nullopt indicates that WebCore should create whatever DisplayRefreshMonitor it deems
+    // most appropriate for the current platform. Returning nullptr indicates that we should not try to
+    // create a DisplayRefreshMonitor at all (and should instead fall back to using a timer).
+    virtual Optional&lt;RefPtr&lt;DisplayRefreshMonitor&gt;&gt; createDisplayRefreshMonitor(PlatformDisplayID) const = 0;
</ins><span class="cx"> 
</span><span class="cx">     PlatformDisplayID displayID() const { return m_displayID; }
</span><span class="cx">     bool hasDisplayID() const { return m_displayIDIsSet; }
</span></span></pre></div>
<a id="branchessafari6007branchSourceWebCoreplatformgraphicsDisplayRefreshMonitorManagercpp"></a>
<div class="modfile"><h4>Modified: branches/safari-600.7-branch/Source/WebCore/platform/graphics/DisplayRefreshMonitorManager.cpp (183131 => 183132)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.7-branch/Source/WebCore/platform/graphics/DisplayRefreshMonitorManager.cpp        2015-04-22 20:55:36 UTC (rev 183131)
+++ branches/safari-600.7-branch/Source/WebCore/platform/graphics/DisplayRefreshMonitorManager.cpp        2015-04-22 20:55:46 UTC (rev 183132)
</span><span class="lines">@@ -44,7 +44,7 @@
</span><span class="cx">     return manager.get();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-DisplayRefreshMonitor* DisplayRefreshMonitorManager::ensureMonitorForClient(DisplayRefreshMonitorClient* client)
</del><ins>+DisplayRefreshMonitor* DisplayRefreshMonitorManager::createMonitorForClient(DisplayRefreshMonitorClient* client)
</ins><span class="cx"> {
</span><span class="cx">     PlatformDisplayID clientDisplayID = client-&gt;displayID();
</span><span class="cx">     for (const RefPtr&lt;DisplayRefreshMonitor&gt;&amp; monitor : m_monitors) {
</span><span class="lines">@@ -55,6 +55,8 @@
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     RefPtr&lt;DisplayRefreshMonitor&gt; monitor = DisplayRefreshMonitor::create(client);
</span><ins>+    if (!monitor)
+        return nullptr;
</ins><span class="cx">     monitor-&gt;addClient(client);
</span><span class="cx">     DisplayRefreshMonitor* result = monitor.get();
</span><span class="cx">     m_monitors.append(monitor.release());
</span><span class="lines">@@ -66,7 +68,7 @@
</span><span class="cx">     if (!client-&gt;hasDisplayID())
</span><span class="cx">         return;
</span><span class="cx"> 
</span><del>-    ensureMonitorForClient(client);
</del><ins>+    createMonitorForClient(client);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void DisplayRefreshMonitorManager::unregisterClient(DisplayRefreshMonitorClient* client)
</span><span class="lines">@@ -92,7 +94,9 @@
</span><span class="cx">     if (!client-&gt;hasDisplayID())
</span><span class="cx">         return false;
</span><span class="cx"> 
</span><del>-    DisplayRefreshMonitor* monitor = ensureMonitorForClient(client);
</del><ins>+    DisplayRefreshMonitor* monitor = createMonitorForClient(client);
+    if (!monitor)
+        return false;
</ins><span class="cx"> 
</span><span class="cx">     client-&gt;setIsScheduled(true);
</span><span class="cx">     return monitor-&gt;requestRefreshCallback();
</span></span></pre></div>
<a id="branchessafari6007branchSourceWebCoreplatformgraphicsDisplayRefreshMonitorManagerh"></a>
<div class="modfile"><h4>Modified: branches/safari-600.7-branch/Source/WebCore/platform/graphics/DisplayRefreshMonitorManager.h (183131 => 183132)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.7-branch/Source/WebCore/platform/graphics/DisplayRefreshMonitorManager.h        2015-04-22 20:55:36 UTC (rev 183131)
+++ branches/safari-600.7-branch/Source/WebCore/platform/graphics/DisplayRefreshMonitorManager.h        2015-04-22 20:55:46 UTC (rev 183132)
</span><span class="lines">@@ -54,7 +54,7 @@
</span><span class="cx">     DisplayRefreshMonitorManager() { }
</span><span class="cx">     virtual ~DisplayRefreshMonitorManager();
</span><span class="cx"> 
</span><del>-    DisplayRefreshMonitor* ensureMonitorForClient(DisplayRefreshMonitorClient*);
</del><ins>+    DisplayRefreshMonitor* createMonitorForClient(DisplayRefreshMonitorClient*);
</ins><span class="cx"> 
</span><span class="cx">     Vector&lt;RefPtr&lt;DisplayRefreshMonitor&gt;&gt; m_monitors;
</span><span class="cx"> };
</span></span></pre></div>
<a id="branchessafari6007branchSourceWebCoreplatformgraphicsGraphicsLayerUpdatercpp"></a>
<div class="modfile"><h4>Modified: branches/safari-600.7-branch/Source/WebCore/platform/graphics/GraphicsLayerUpdater.cpp (183131 => 183132)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.7-branch/Source/WebCore/platform/graphics/GraphicsLayerUpdater.cpp        2015-04-22 20:55:36 UTC (rev 183131)
+++ branches/safari-600.7-branch/Source/WebCore/platform/graphics/GraphicsLayerUpdater.cpp        2015-04-22 20:55:46 UTC (rev 183132)
</span><span class="lines">@@ -79,9 +79,11 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> #if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)
</span><del>-PassRefPtr&lt;DisplayRefreshMonitor&gt; GraphicsLayerUpdater::createDisplayRefreshMonitor(PlatformDisplayID displayID) const
</del><ins>+Optional&lt;RefPtr&lt;DisplayRefreshMonitor&gt;&gt; GraphicsLayerUpdater::createDisplayRefreshMonitor(PlatformDisplayID displayID) const
</ins><span class="cx"> {
</span><del>-    return m_client ? m_client-&gt;createDisplayRefreshMonitor(displayID) : nullptr;
</del><ins>+    if (!m_client)
+        return Optional&lt;RefPtr&lt;DisplayRefreshMonitor&gt;&gt;(nullptr);
+    return m_client-&gt;createDisplayRefreshMonitor(displayID);
</ins><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx"> 
</span></span></pre></div>
<a id="branchessafari6007branchSourceWebCoreplatformgraphicsGraphicsLayerUpdaterh"></a>
<div class="modfile"><h4>Modified: branches/safari-600.7-branch/Source/WebCore/platform/graphics/GraphicsLayerUpdater.h (183131 => 183132)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.7-branch/Source/WebCore/platform/graphics/GraphicsLayerUpdater.h        2015-04-22 20:55:36 UTC (rev 183131)
+++ branches/safari-600.7-branch/Source/WebCore/platform/graphics/GraphicsLayerUpdater.h        2015-04-22 20:55:46 UTC (rev 183132)
</span><span class="lines">@@ -38,7 +38,7 @@
</span><span class="cx">     virtual ~GraphicsLayerUpdaterClient() { }
</span><span class="cx">     virtual void flushLayersSoon(GraphicsLayerUpdater*) = 0;
</span><span class="cx"> #if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)
</span><del>-    virtual PassRefPtr&lt;DisplayRefreshMonitor&gt; createDisplayRefreshMonitor(PlatformDisplayID) const = 0;
</del><ins>+    virtual Optional&lt;RefPtr&lt;DisplayRefreshMonitor&gt;&gt; createDisplayRefreshMonitor(PlatformDisplayID) const = 0;
</ins><span class="cx"> #endif
</span><span class="cx"> };
</span><span class="cx"> 
</span><span class="lines">@@ -55,7 +55,7 @@
</span><span class="cx">     void screenDidChange(PlatformDisplayID);
</span><span class="cx"> 
</span><span class="cx"> #if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)
</span><del>-    virtual PassRefPtr&lt;DisplayRefreshMonitor&gt; createDisplayRefreshMonitor(PlatformDisplayID) const override;
</del><ins>+    virtual Optional&lt;RefPtr&lt;DisplayRefreshMonitor&gt;&gt; createDisplayRefreshMonitor(PlatformDisplayID) const override;
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> private:
</span></span></pre></div>
<a id="branchessafari6007branchSourceWebCorerenderingRenderLayerCompositorcpp"></a>
<div class="modfile"><h4>Modified: branches/safari-600.7-branch/Source/WebCore/rendering/RenderLayerCompositor.cpp (183131 => 183132)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.7-branch/Source/WebCore/rendering/RenderLayerCompositor.cpp        2015-04-22 20:55:36 UTC (rev 183131)
+++ branches/safari-600.7-branch/Source/WebCore/rendering/RenderLayerCompositor.cpp        2015-04-22 20:55:46 UTC (rev 183132)
</span><span class="lines">@@ -4034,14 +4034,14 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> #if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)
</span><del>-PassRefPtr&lt;DisplayRefreshMonitor&gt; RenderLayerCompositor::createDisplayRefreshMonitor(PlatformDisplayID displayID) const
</del><ins>+Optional&lt;RefPtr&lt;DisplayRefreshMonitor&gt;&gt; RenderLayerCompositor::createDisplayRefreshMonitor(PlatformDisplayID displayID) const
</ins><span class="cx"> {
</span><span class="cx">     Frame&amp; frame = m_renderView.frameView().frame();
</span><span class="cx">     Page* page = frame.page();
</span><span class="cx">     if (!page)
</span><del>-        return nullptr;
</del><ins>+        return Optional&lt;RefPtr&lt;DisplayRefreshMonitor&gt;&gt;(nullptr);
</ins><span class="cx"> 
</span><del>-    return page-&gt;chrome().client().createDisplayRefreshMonitor(displayID);
</del><ins>+    return Optional&lt;RefPtr&lt;DisplayRefreshMonitor&gt;&gt;(page-&gt;chrome().client().createDisplayRefreshMonitor(displayID));
</ins><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx"> 
</span></span></pre></div>
<a id="branchessafari6007branchSourceWebCorerenderingRenderLayerCompositorh"></a>
<div class="modfile"><h4>Modified: branches/safari-600.7-branch/Source/WebCore/rendering/RenderLayerCompositor.h (183131 => 183132)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.7-branch/Source/WebCore/rendering/RenderLayerCompositor.h        2015-04-22 20:55:36 UTC (rev 183131)
+++ branches/safari-600.7-branch/Source/WebCore/rendering/RenderLayerCompositor.h        2015-04-22 20:55:46 UTC (rev 183132)
</span><span class="lines">@@ -390,7 +390,7 @@
</span><span class="cx">     ScrollingCoordinator* scrollingCoordinator() const;
</span><span class="cx"> 
</span><span class="cx"> #if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)
</span><del>-    PassRefPtr&lt;DisplayRefreshMonitor&gt; createDisplayRefreshMonitor(PlatformDisplayID) const;
</del><ins>+    Optional&lt;RefPtr&lt;DisplayRefreshMonitor&gt;&gt; createDisplayRefreshMonitor(PlatformDisplayID) const;
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx">     bool requiresCompositingForAnimation(RenderLayerModelObject&amp;) const;
</span></span></pre></div>
<a id="branchessafari6007branchSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-600.7-branch/Source/WebKit2/ChangeLog (183131 => 183132)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.7-branch/Source/WebKit2/ChangeLog        2015-04-22 20:55:36 UTC (rev 183131)
+++ branches/safari-600.7-branch/Source/WebKit2/ChangeLog        2015-04-22 20:55:46 UTC (rev 183132)
</span><span class="lines">@@ -1,5 +1,22 @@
</span><span class="cx"> 2015-04-22  Matthew Hanson  &lt;matthew_hanson@apple.com&gt;
</span><span class="cx"> 
</span><ins>+        Merge r181656. rdar://problem/20545362
+
+    2015-03-17  Timothy Horton  &lt;timothy_horton@apple.com&gt;
+
+            Reproducible null deref under ScriptedAnimationController::createDisplayRefreshMonitor
+            https://bugs.webkit.org/show_bug.cgi?id=142776
+            &lt;rdar://problem/18921338&gt;
+
+            Reviewed by Alexey Proskuryakov.
+
+            * WebProcess/WebCoreSupport/WebChromeClient.cpp:
+            (WebKit::WebChromeClient::createDisplayRefreshMonitor):
+            * WebProcess/WebCoreSupport/WebChromeClient.h:
+            Adjust to the new signature.
+
+2015-04-22  Matthew Hanson  &lt;matthew_hanson@apple.com&gt;
+
</ins><span class="cx">         Merge r174288. rdar://problem/20368461
</span><span class="cx"> 
</span><span class="cx">     2014-10-03  Jer Noble  &lt;jer.noble@apple.com&gt;
</span></span></pre></div>
<a id="branchessafari6007branchSourceWebKit2WebProcessWebCoreSupportWebChromeClientcpp"></a>
<div class="modfile"><h4>Modified: branches/safari-600.7-branch/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp (183131 => 183132)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.7-branch/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp        2015-04-22 20:55:36 UTC (rev 183131)
+++ branches/safari-600.7-branch/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp        2015-04-22 20:55:46 UTC (rev 183132)
</span><span class="lines">@@ -812,9 +812,9 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> #if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)
</span><del>-PassRefPtr&lt;WebCore::DisplayRefreshMonitor&gt; WebChromeClient::createDisplayRefreshMonitor(PlatformDisplayID displayID) const
</del><ins>+Optional&lt;RefPtr&lt;WebCore::DisplayRefreshMonitor&gt;&gt; WebChromeClient::createDisplayRefreshMonitor(PlatformDisplayID displayID) const
</ins><span class="cx"> {
</span><del>-    return m_page-&gt;drawingArea()-&gt;createDisplayRefreshMonitor(displayID);
</del><ins>+    return Optional&lt;RefPtr&lt;WebCore::DisplayRefreshMonitor&gt;&gt;(m_page-&gt;drawingArea()-&gt;createDisplayRefreshMonitor(displayID));
</ins><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx"> 
</span></span></pre></div>
<a id="branchessafari6007branchSourceWebKit2WebProcessWebCoreSupportWebChromeClienth"></a>
<div class="modfile"><h4>Modified: branches/safari-600.7-branch/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.h (183131 => 183132)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.7-branch/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.h        2015-04-22 20:55:36 UTC (rev 183131)
+++ branches/safari-600.7-branch/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.h        2015-04-22 20:55:46 UTC (rev 183132)
</span><span class="lines">@@ -217,7 +217,7 @@
</span><span class="cx">     virtual bool adjustLayerFlushThrottling(WebCore::LayerFlushThrottleState::Flags) override;
</span><span class="cx"> 
</span><span class="cx"> #if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)
</span><del>-    virtual PassRefPtr&lt;WebCore::DisplayRefreshMonitor&gt; createDisplayRefreshMonitor(PlatformDisplayID) const override;
</del><ins>+    virtual Optional&lt;RefPtr&lt;WebCore::DisplayRefreshMonitor&gt;&gt; createDisplayRefreshMonitor(PlatformDisplayID) const override;
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx">     virtual CompositingTriggerFlags allowedCompositingTriggers() const
</span></span></pre>
</div>
</div>

</body>
</html>