<!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>[218464] 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/218464">218464</a></dd>
<dt>Author</dt> <dd>cdumez@apple.com</dd>
<dt>Date</dt> <dd>2017-06-18 12:49:12 -0700 (Sun, 18 Jun 2017)</dd>
</dl>

<h3>Log Message</h3>
<pre>Use WTF::Function instead of std::function in WTF/
https://bugs.webkit.org/show_bug.cgi?id=173519

Reviewed by Sam Weinig.

Source/WebCore:

Replace a few uses of std::function with WTF::Function in WebCore/
as well. It was either this or including <functional> and I decided
it made more sense to port the code.

* platform/graphics/FontSelectionAlgorithm.h:
(WebCore::FontSelectionAlgorithm::iterateActiveCapabilitiesWithReturn):
* platform/mediastream/MediaConstraints.cpp:
(WebCore::StringConstraint::find):
(WebCore::MediaTrackConstraintSetMap::forEach):
(WebCore::MediaTrackConstraintSetMap::filter):
(WebCore::MediaConstraints::isConstraintSet):
* platform/mediastream/MediaConstraints.h:
(WebCore::NumericConstraint::find):
* platform/mediastream/RealtimeMediaSource.cpp:
(WebCore::RealtimeMediaSource::applyConstraint):

Source/WTF:

Use WTF::Function instead of std::function in WTF/ to avoid
copying.

* wtf/Brigand.h:
* wtf/Condition.h:
* wtf/Expected.h:
* wtf/FunctionDispatcher.h:
* wtf/MainThread.h:
* wtf/MemoryPressureHandler.h:
(WTF::MemoryPressureHandler::setMemoryKillCallback):
(WTF::MemoryPressureHandler::setMemoryPressureStatusChangedCallback):
(WTF::MemoryPressureHandler::setDidExceedInactiveLimitWhileActiveCallback):
* wtf/Optional.h:
* wtf/ParkingLot.h:
* wtf/RefCounter.h:
(WTF::RefCounter<T>::RefCounter):
* wtf/WorkQueue.h:
* wtf/linux/MemoryPressureHandlerLinux.cpp:
(WTF::MemoryPressureHandler::EventFDPoller::EventFDPoller):
* wtf/text/WTFString.cpp:
(WTF::String::split):
* wtf/text/WTFString.h:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWTFChangeLog">trunk/Source/WTF/ChangeLog</a></li>
<li><a href="#trunkSourceWTFwtfBrigandh">trunk/Source/WTF/wtf/Brigand.h</a></li>
<li><a href="#trunkSourceWTFwtfConditionh">trunk/Source/WTF/wtf/Condition.h</a></li>
<li><a href="#trunkSourceWTFwtfExpectedh">trunk/Source/WTF/wtf/Expected.h</a></li>
<li><a href="#trunkSourceWTFwtfFunctionDispatcherh">trunk/Source/WTF/wtf/FunctionDispatcher.h</a></li>
<li><a href="#trunkSourceWTFwtfMainThreadh">trunk/Source/WTF/wtf/MainThread.h</a></li>
<li><a href="#trunkSourceWTFwtfMemoryPressureHandlerh">trunk/Source/WTF/wtf/MemoryPressureHandler.h</a></li>
<li><a href="#trunkSourceWTFwtfOptionalh">trunk/Source/WTF/wtf/Optional.h</a></li>
<li><a href="#trunkSourceWTFwtfParkingLoth">trunk/Source/WTF/wtf/ParkingLot.h</a></li>
<li><a href="#trunkSourceWTFwtfRefCounterh">trunk/Source/WTF/wtf/RefCounter.h</a></li>
<li><a href="#trunkSourceWTFwtfWorkQueueh">trunk/Source/WTF/wtf/WorkQueue.h</a></li>
<li><a href="#trunkSourceWTFwtflinuxMemoryPressureHandlerLinuxcpp">trunk/Source/WTF/wtf/linux/MemoryPressureHandlerLinux.cpp</a></li>
<li><a href="#trunkSourceWTFwtftextWTFStringcpp">trunk/Source/WTF/wtf/text/WTFString.cpp</a></li>
<li><a href="#trunkSourceWTFwtftextWTFStringh">trunk/Source/WTF/wtf/text/WTFString.h</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsFontSelectionAlgorithmh">trunk/Source/WebCore/platform/graphics/FontSelectionAlgorithm.h</a></li>
<li><a href="#trunkSourceWebCoreplatformmediastreamMediaConstraintscpp">trunk/Source/WebCore/platform/mediastream/MediaConstraints.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformmediastreamMediaConstraintsh">trunk/Source/WebCore/platform/mediastream/MediaConstraints.h</a></li>
<li><a href="#trunkSourceWebCoreplatformmediastreamRealtimeMediaSourcecpp">trunk/Source/WebCore/platform/mediastream/RealtimeMediaSource.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWTFChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/ChangeLog (218463 => 218464)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/ChangeLog       2017-06-18 15:55:55 UTC (rev 218463)
+++ trunk/Source/WTF/ChangeLog  2017-06-18 19:49:12 UTC (rev 218464)
</span><span class="lines">@@ -1,3 +1,33 @@
</span><ins>+2017-06-18  Chris Dumez  <cdumez@apple.com>
+
+        Use WTF::Function instead of std::function in WTF/
+        https://bugs.webkit.org/show_bug.cgi?id=173519
+
+        Reviewed by Sam Weinig.
+
+        Use WTF::Function instead of std::function in WTF/ to avoid
+        copying.
+
+        * wtf/Brigand.h:
+        * wtf/Condition.h:
+        * wtf/Expected.h:
+        * wtf/FunctionDispatcher.h:
+        * wtf/MainThread.h:
+        * wtf/MemoryPressureHandler.h:
+        (WTF::MemoryPressureHandler::setMemoryKillCallback):
+        (WTF::MemoryPressureHandler::setMemoryPressureStatusChangedCallback):
+        (WTF::MemoryPressureHandler::setDidExceedInactiveLimitWhileActiveCallback):
+        * wtf/Optional.h:
+        * wtf/ParkingLot.h:
+        * wtf/RefCounter.h:
+        (WTF::RefCounter<T>::RefCounter):
+        * wtf/WorkQueue.h:
+        * wtf/linux/MemoryPressureHandlerLinux.cpp:
+        (WTF::MemoryPressureHandler::EventFDPoller::EventFDPoller):
+        * wtf/text/WTFString.cpp:
+        (WTF::String::split):
+        * wtf/text/WTFString.h:
+
</ins><span class="cx"> 2017-06-16  Alex Christensen  <achristensen@webkit.org>
</span><span class="cx"> 
</span><span class="cx">         Fix Mac CMake build.
</span></span></pre></div>
<a id="trunkSourceWTFwtfBrigandh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/wtf/Brigand.h (218463 => 218464)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/Brigand.h   2017-06-18 15:55:55 UTC (rev 218463)
+++ trunk/Source/WTF/wtf/Brigand.h      2017-06-18 19:49:12 UTC (rev 218464)
</span><span class="lines">@@ -51,7 +51,6 @@
</span><span class="cx"> #include <cstddef>
</span><span class="cx"> #include <cstdint>
</span><span class="cx"> #include <cstring>
</span><del>-#include <functional>
</del><span class="cx"> #include <initializer_list>
</span><span class="cx"> #include <tuple>
</span><span class="cx"> #include <type_traits>
</span></span></pre></div>
<a id="trunkSourceWTFwtfConditionh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/wtf/Condition.h (218463 => 218464)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/Condition.h 2017-06-18 15:55:55 UTC (rev 218463)
+++ trunk/Source/WTF/wtf/Condition.h    2017-06-18 19:49:12 UTC (rev 218464)
</span><span class="lines">@@ -26,7 +26,6 @@
</span><span class="cx"> #ifndef WTF_Condition_h
</span><span class="cx"> #define WTF_Condition_h
</span><span class="cx"> 
</span><del>-#include <functional>
</del><span class="cx"> #include <wtf/CurrentTime.h>
</span><span class="cx"> #include <wtf/Noncopyable.h>
</span><span class="cx"> #include <wtf/ParkingLot.h>
</span></span></pre></div>
<a id="trunkSourceWTFwtfExpectedh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/wtf/Expected.h (218463 => 218464)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/Expected.h  2017-06-18 15:55:55 UTC (rev 218463)
+++ trunk/Source/WTF/wtf/Expected.h     2017-06-18 19:49:12 UTC (rev 218464)
</span><span class="lines">@@ -29,7 +29,6 @@
</span><span class="cx"> #pragma once
</span><span class="cx"> 
</span><span class="cx"> #include <cstdlib>
</span><del>-#include <functional>
</del><span class="cx"> #include <initializer_list>
</span><span class="cx"> #include <type_traits>
</span><span class="cx"> #include <utility>
</span></span></pre></div>
<a id="trunkSourceWTFwtfFunctionDispatcherh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/wtf/FunctionDispatcher.h (218463 => 218464)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/FunctionDispatcher.h        2017-06-18 15:55:55 UTC (rev 218463)
+++ trunk/Source/WTF/wtf/FunctionDispatcher.h   2017-06-18 19:49:12 UTC (rev 218464)
</span><span class="lines">@@ -26,7 +26,6 @@
</span><span class="cx"> #ifndef FunctionDispatcher_h
</span><span class="cx"> #define FunctionDispatcher_h
</span><span class="cx"> 
</span><del>-#include <functional>
</del><span class="cx"> #include <wtf/Function.h>
</span><span class="cx"> #include <wtf/ThreadSafeRefCounted.h>
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWTFwtfMainThreadh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/wtf/MainThread.h (218463 => 218464)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/MainThread.h        2017-06-18 15:55:55 UTC (rev 218463)
+++ trunk/Source/WTF/wtf/MainThread.h   2017-06-18 19:49:12 UTC (rev 218464)
</span><span class="lines">@@ -30,7 +30,6 @@
</span><span class="cx"> #ifndef MainThread_h
</span><span class="cx"> #define MainThread_h
</span><span class="cx"> 
</span><del>-#include <functional>
</del><span class="cx"> #include <stdint.h>
</span><span class="cx"> #include <wtf/Function.h>
</span><span class="cx"> #include <wtf/Optional.h>
</span></span></pre></div>
<a id="trunkSourceWTFwtfMemoryPressureHandlerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/wtf/MemoryPressureHandler.h (218463 => 218464)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/MemoryPressureHandler.h     2017-06-18 15:55:55 UTC (rev 218463)
+++ trunk/Source/WTF/wtf/MemoryPressureHandler.h        2017-06-18 19:49:12 UTC (rev 218464)
</span><span class="lines">@@ -28,9 +28,9 @@
</span><span class="cx"> 
</span><span class="cx"> #include <atomic>
</span><span class="cx"> #include <ctime>
</span><del>-#include <functional>
</del><span class="cx"> #include <wtf/FastMalloc.h>
</span><span class="cx"> #include <wtf/Forward.h>
</span><ins>+#include <wtf/Function.h>
</ins><span class="cx"> #include <wtf/NeverDestroyed.h>
</span><span class="cx"> #include <wtf/Optional.h>
</span><span class="cx"> #include <wtf/RunLoop.h>
</span><span class="lines">@@ -59,7 +59,7 @@
</span><span class="cx"> enum class Critical { No, Yes };
</span><span class="cx"> enum class Synchronous { No, Yes };
</span><span class="cx"> 
</span><del>-typedef std::function<void(Critical, Synchronous)> LowMemoryHandler;
</del><ins>+typedef WTF::Function<void(Critical, Synchronous)> LowMemoryHandler;
</ins><span class="cx"> 
</span><span class="cx"> class MemoryPressureHandler {
</span><span class="cx">     friend class WTF::NeverDestroyed<MemoryPressureHandler>;
</span><span class="lines">@@ -70,9 +70,9 @@
</span><span class="cx"> 
</span><span class="cx">     WTF_EXPORT_PRIVATE void setShouldUsePeriodicMemoryMonitor(bool);
</span><span class="cx"> 
</span><del>-    void setMemoryKillCallback(WTF::Function<void()> function) { m_memoryKillCallback = WTFMove(function); }
-    void setMemoryPressureStatusChangedCallback(WTF::Function<void(bool)> function) { m_memoryPressureStatusChangedCallback = WTFMove(function); }
-    void setDidExceedInactiveLimitWhileActiveCallback(WTF::Function<void()> function) { m_didExceedInactiveLimitWhileActiveCallback = WTFMove(function); }
</del><ins>+    void setMemoryKillCallback(WTF::Function<void()>&& function) { m_memoryKillCallback = WTFMove(function); }
+    void setMemoryPressureStatusChangedCallback(WTF::Function<void(bool)>&& function) { m_memoryPressureStatusChangedCallback = WTFMove(function); }
+    void setDidExceedInactiveLimitWhileActiveCallback(WTF::Function<void()>&& function) { m_didExceedInactiveLimitWhileActiveCallback = WTFMove(function); }
</ins><span class="cx"> 
</span><span class="cx">     void setLowMemoryHandler(LowMemoryHandler&& handler)
</span><span class="cx">     {
</span><span class="lines">@@ -172,7 +172,7 @@
</span><span class="cx">     class EventFDPoller {
</span><span class="cx">         WTF_MAKE_NONCOPYABLE(EventFDPoller); WTF_MAKE_FAST_ALLOCATED;
</span><span class="cx">     public:
</span><del>-        EventFDPoller(int fd, std::function<void ()>&& notifyHandler);
</del><ins>+        EventFDPoller(int fd, WTF::Function<void ()>&& notifyHandler);
</ins><span class="cx">         ~EventFDPoller();
</span><span class="cx"> 
</span><span class="cx">     private:
</span><span class="lines">@@ -179,7 +179,7 @@
</span><span class="cx">         void readAndNotify() const;
</span><span class="cx"> 
</span><span class="cx">         std::optional<int> m_fd;
</span><del>-        std::function<void ()> m_notifyHandler;
</del><ins>+        WTF::Function<void ()> m_notifyHandler;
</ins><span class="cx"> #if USE(GLIB)
</span><span class="cx">         GRefPtr<GSource> m_source;
</span><span class="cx"> #else
</span></span></pre></div>
<a id="trunkSourceWTFwtfOptionalh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/wtf/Optional.h (218463 => 218464)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/Optional.h  2017-06-18 15:55:55 UTC (rev 218463)
+++ trunk/Source/WTF/wtf/Optional.h     2017-06-18 19:49:12 UTC (rev 218464)
</span><span class="lines">@@ -41,7 +41,6 @@
</span><span class="cx"> # include <type_traits>
</span><span class="cx"> # include <initializer_list>
</span><span class="cx"> # include <cassert>
</span><del>-# include <functional>
</del><span class="cx"> # include <string>
</span><span class="cx"> # include <stdexcept>
</span><span class="cx"> # include <wtf/Assertions.h>
</span></span></pre></div>
<a id="trunkSourceWTFwtfParkingLoth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/wtf/ParkingLot.h (218463 => 218464)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/ParkingLot.h        2017-06-18 15:55:55 UTC (rev 218463)
+++ trunk/Source/WTF/wtf/ParkingLot.h   2017-06-18 19:49:12 UTC (rev 218464)
</span><span class="lines">@@ -26,7 +26,6 @@
</span><span class="cx"> #ifndef WTF_ParkingLot_h
</span><span class="cx"> #define WTF_ParkingLot_h
</span><span class="cx"> 
</span><del>-#include <functional>
</del><span class="cx"> #include <wtf/Atomics.h>
</span><span class="cx"> #include <wtf/ScopedLambda.h>
</span><span class="cx"> #include <wtf/Threading.h>
</span></span></pre></div>
<a id="trunkSourceWTFwtfRefCounterh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/wtf/RefCounter.h (218463 => 218464)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/RefCounter.h        2017-06-18 15:55:55 UTC (rev 218463)
+++ trunk/Source/WTF/wtf/RefCounter.h   2017-06-18 19:49:12 UTC (rev 218464)
</span><span class="lines">@@ -26,7 +26,7 @@
</span><span class="cx"> #ifndef RefCounter_h
</span><span class="cx"> #define RefCounter_h
</span><span class="cx"> 
</span><del>-#include <functional>
</del><ins>+#include <wtf/Function.h>
</ins><span class="cx"> #include <wtf/Noncopyable.h>
</span><span class="cx"> #include <wtf/RefPtr.h>
</span><span class="cx"> 
</span><span class="lines">@@ -59,9 +59,9 @@
</span><span class="cx"> 
</span><span class="cx"> public:
</span><span class="cx">     using Token = RefPtr<Count>;
</span><del>-    using ValueChangeFunction = std::function<void (RefCounterEvent)>;
</del><ins>+    using ValueChangeFunction = WTF::Function<void (RefCounterEvent)>;
</ins><span class="cx"> 
</span><del>-    RefCounter(ValueChangeFunction = nullptr);
</del><ins>+    RefCounter(ValueChangeFunction&& = nullptr);
</ins><span class="cx">     ~RefCounter();
</span><span class="cx"> 
</span><span class="cx">     Token count() const
</span><span class="lines">@@ -105,8 +105,8 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> template<typename T>
</span><del>-inline RefCounter<T>::RefCounter(ValueChangeFunction valueDidChange)
-    : m_valueDidChange(valueDidChange)
</del><ins>+inline RefCounter<T>::RefCounter(ValueChangeFunction&& valueDidChange)
+    : m_valueDidChange(WTFMove(valueDidChange))
</ins><span class="cx">     , m_count(new Count(*this))
</span><span class="cx"> {
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWTFwtfWorkQueueh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/wtf/WorkQueue.h (218463 => 218464)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/WorkQueue.h 2017-06-18 15:55:55 UTC (rev 218463)
+++ trunk/Source/WTF/wtf/WorkQueue.h    2017-06-18 19:49:12 UTC (rev 218464)
</span><span class="lines">@@ -27,7 +27,6 @@
</span><span class="cx"> #ifndef WorkQueue_h
</span><span class="cx"> #define WorkQueue_h
</span><span class="cx"> 
</span><del>-#include <functional>
</del><span class="cx"> #include <wtf/Forward.h>
</span><span class="cx"> #include <wtf/FunctionDispatcher.h>
</span><span class="cx"> #include <wtf/RefCounted.h>
</span></span></pre></div>
<a id="trunkSourceWTFwtflinuxMemoryPressureHandlerLinuxcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/wtf/linux/MemoryPressureHandlerLinux.cpp (218463 => 218464)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/linux/MemoryPressureHandlerLinux.cpp        2017-06-18 15:55:55 UTC (rev 218463)
+++ trunk/Source/WTF/wtf/linux/MemoryPressureHandlerLinux.cpp   2017-06-18 19:49:12 UTC (rev 218464)
</span><span class="lines">@@ -99,7 +99,7 @@
</span><span class="cx"> };
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-MemoryPressureHandler::EventFDPoller::EventFDPoller(int fd, std::function<void ()>&& notifyHandler)
</del><ins>+MemoryPressureHandler::EventFDPoller::EventFDPoller(int fd, WTF::Function<void ()>&& notifyHandler)
</ins><span class="cx">     : m_fd(fd)
</span><span class="cx">     , m_notifyHandler(WTFMove(notifyHandler))
</span><span class="cx"> {
</span></span></pre></div>
<a id="trunkSourceWTFwtftextWTFStringcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/wtf/text/WTFString.cpp (218463 => 218464)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/text/WTFString.cpp  2017-06-18 15:55:55 UTC (rev 218463)
+++ trunk/Source/WTF/wtf/text/WTFString.cpp     2017-06-18 19:49:12 UTC (rev 218464)
</span><span class="lines">@@ -743,7 +743,7 @@
</span><span class="cx">         result.append(substring(startPos));
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void String::split(UChar separator, bool allowEmptyEntries, SplitFunctor&& functor) const
</del><ins>+void String::split(UChar separator, bool allowEmptyEntries, const SplitFunctor& functor) const
</ins><span class="cx"> {
</span><span class="cx">     StringView view(*this);
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWTFwtftextWTFStringh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/wtf/text/WTFString.h (218463 => 218464)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/text/WTFString.h    2017-06-18 15:55:55 UTC (rev 218463)
+++ trunk/Source/WTF/wtf/text/WTFString.h       2017-06-18 19:49:12 UTC (rev 218464)
</span><span class="lines">@@ -25,8 +25,7 @@
</span><span class="cx"> // This file would be called String.h, but that conflicts with <string.h>
</span><span class="cx"> // on systems without case-sensitive file systems.
</span><span class="cx"> 
</span><del>-#include <functional>
-
</del><ins>+#include <wtf/Function.h>
</ins><span class="cx"> #include <wtf/text/ASCIIFastPath.h>
</span><span class="cx"> #include <wtf/text/IntegerToStringConversion.h>
</span><span class="cx"> #include <wtf/text/StringImpl.h>
</span><span class="lines">@@ -367,8 +366,8 @@
</span><span class="cx">         split(separator, false, result);
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    using SplitFunctor = std::function<void(const StringView&)>;
-    WTF_EXPORT_STRING_API void split(UChar separator, bool allowEmptyEntries, SplitFunctor&&) const;
</del><ins>+    using SplitFunctor = WTF::Function<void(const StringView&)>;
+    WTF_EXPORT_STRING_API void split(UChar separator, bool allowEmptyEntries, const SplitFunctor&) const;
</ins><span class="cx">     WTF_EXPORT_STRING_API void split(UChar separator, bool allowEmptyEntries, Vector<String>& result) const;
</span><span class="cx">     void split(UChar separator, Vector<String>& result) const
</span><span class="cx">     {
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (218463 => 218464)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog   2017-06-18 15:55:55 UTC (rev 218463)
+++ trunk/Source/WebCore/ChangeLog      2017-06-18 19:49:12 UTC (rev 218464)
</span><span class="lines">@@ -1,3 +1,26 @@
</span><ins>+2017-06-18  Chris Dumez  <cdumez@apple.com>
+
+        Use WTF::Function instead of std::function in WTF/
+        https://bugs.webkit.org/show_bug.cgi?id=173519
+
+        Reviewed by Sam Weinig.
+
+        Replace a few uses of std::function with WTF::Function in WebCore/
+        as well. It was either this or including <functional> and I decided
+        it made more sense to port the code.
+
+        * platform/graphics/FontSelectionAlgorithm.h:
+        (WebCore::FontSelectionAlgorithm::iterateActiveCapabilitiesWithReturn):
+        * platform/mediastream/MediaConstraints.cpp:
+        (WebCore::StringConstraint::find):
+        (WebCore::MediaTrackConstraintSetMap::forEach):
+        (WebCore::MediaTrackConstraintSetMap::filter):
+        (WebCore::MediaConstraints::isConstraintSet):
+        * platform/mediastream/MediaConstraints.h:
+        (WebCore::NumericConstraint::find):
+        * platform/mediastream/RealtimeMediaSource.cpp:
+        (WebCore::RealtimeMediaSource::applyConstraint):
+
</ins><span class="cx"> 2017-06-18  Jer Noble  <jer.noble@apple.com>
</span><span class="cx"> 
</span><span class="cx">         [MSE] Seeking or entering fullscreen can cause extreme CPU usage
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsFontSelectionAlgorithmh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/FontSelectionAlgorithm.h (218463 => 218464)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/FontSelectionAlgorithm.h  2017-06-18 15:55:55 UTC (rev 218463)
+++ trunk/Source/WebCore/platform/graphics/FontSelectionAlgorithm.h     2017-06-18 19:49:12 UTC (rev 218464)
</span><span class="lines">@@ -26,6 +26,7 @@
</span><span class="cx"> #pragma once
</span><span class="cx"> 
</span><span class="cx"> #include "TextFlags.h"
</span><ins>+#include <wtf/Function.h>
</ins><span class="cx"> #include <wtf/GetPtr.h>
</span><span class="cx"> #include <wtf/Hasher.h>
</span><span class="cx"> #include <wtf/NeverDestroyed.h>
</span><span class="lines">@@ -513,10 +514,10 @@
</span><span class="cx"> 
</span><span class="cx"> private:
</span><span class="cx">     template <typename T>
</span><del>-    using IterateActiveCapabilitiesWithReturnCallback = std::function<std::optional<T>(FontSelectionCapabilities, size_t)>;
</del><ins>+    using IterateActiveCapabilitiesWithReturnCallback = WTF::Function<std::optional<T>(FontSelectionCapabilities, size_t)>;
</ins><span class="cx"> 
</span><span class="cx">     template <typename T>
</span><del>-    inline std::optional<T> iterateActiveCapabilitiesWithReturn(IterateActiveCapabilitiesWithReturnCallback<T> callback)
</del><ins>+    inline std::optional<T> iterateActiveCapabilitiesWithReturn(const IterateActiveCapabilitiesWithReturnCallback<T>& callback)
</ins><span class="cx">     {
</span><span class="cx">         for (size_t i = 0; i < m_capabilities.size(); ++i) {
</span><span class="cx">             if (!m_filter[i])
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformmediastreamMediaConstraintscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/mediastream/MediaConstraints.cpp (218463 => 218464)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mediastream/MediaConstraints.cpp   2017-06-18 15:55:55 UTC (rev 218463)
+++ trunk/Source/WebCore/platform/mediastream/MediaConstraints.cpp      2017-06-18 19:49:12 UTC (rev 218464)
</span><span class="lines">@@ -38,7 +38,7 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><del>-const String& StringConstraint::find(std::function<bool(const String&)> filter) const
</del><ins>+const String& StringConstraint::find(const WTF::Function<bool(const String&)>& filter) const
</ins><span class="cx"> {
</span><span class="cx">     for (auto& constraint : m_exact) {
</span><span class="cx">         if (filter(constraint))
</span><span class="lines">@@ -182,15 +182,15 @@
</span><span class="cx">     return nullptr;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void MediaTrackConstraintSetMap::forEach(std::function<void(const MediaConstraint&)> callback) const
</del><ins>+void MediaTrackConstraintSetMap::forEach(WTF::Function<void(const MediaConstraint&)>&& callback) const
</ins><span class="cx"> {
</span><del>-    filter([callback] (const MediaConstraint& constraint) mutable {
</del><ins>+    filter([callback = WTFMove(callback)] (const MediaConstraint& constraint) mutable {
</ins><span class="cx">         callback(constraint);
</span><span class="cx">         return false;
</span><span class="cx">     });
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void MediaTrackConstraintSetMap::filter(std::function<bool(const MediaConstraint&)> callback) const
</del><ins>+void MediaTrackConstraintSetMap::filter(const WTF::Function<bool(const MediaConstraint&)>& callback) const
</ins><span class="cx"> {
</span><span class="cx">     if (m_width && !m_width->isEmpty() && callback(*m_width))
</span><span class="cx">         return;
</span><span class="lines">@@ -363,7 +363,7 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool MediaConstraints::isConstraintSet(std::function<bool(const MediaTrackConstraintSetMap&)>&& callback)
</del><ins>+bool MediaConstraints::isConstraintSet(const WTF::Function<bool(const MediaTrackConstraintSetMap&)>& callback)
</ins><span class="cx"> {
</span><span class="cx">     if (callback(mandatoryConstraints))
</span><span class="cx">         return true;
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformmediastreamMediaConstraintsh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/mediastream/MediaConstraints.h (218463 => 218464)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mediastream/MediaConstraints.h     2017-06-18 15:55:55 UTC (rev 218463)
+++ trunk/Source/WebCore/platform/mediastream/MediaConstraints.h        2017-06-18 19:49:12 UTC (rev 218464)
</span><span class="lines">@@ -35,6 +35,7 @@
</span><span class="cx"> 
</span><span class="cx"> #include "RealtimeMediaSourceSupportedConstraints.h"
</span><span class="cx"> #include <cstdlib>
</span><ins>+#include <wtf/Function.h>
</ins><span class="cx"> #include <wtf/Vector.h>
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="lines">@@ -220,7 +221,7 @@
</span><span class="cx">         return true;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    ValueType find(std::function<bool(ValueType)> function) const
</del><ins>+    ValueType find(const WTF::Function<bool(ValueType)>& function) const
</ins><span class="cx">     {
</span><span class="cx">         if (m_min && function(m_min.value()))
</span><span class="cx">             return m_min.value();
</span><span class="lines">@@ -525,7 +526,7 @@
</span><span class="cx">     double fitnessDistance(const String&) const;
</span><span class="cx">     double fitnessDistance(const Vector<String>&) const;
</span><span class="cx"> 
</span><del>-    const String& find(std::function<bool(const String&)>) const;
</del><ins>+    const String& find(const WTF::Function<bool(const String&)>&) const;
</ins><span class="cx"> 
</span><span class="cx">     bool isEmpty() const { return m_exact.isEmpty() && m_ideal.isEmpty(); }
</span><span class="cx">     bool isMandatory() const { return !m_exact.isEmpty(); }
</span><span class="lines">@@ -572,8 +573,8 @@
</span><span class="cx"> 
</span><span class="cx"> class MediaTrackConstraintSetMap {
</span><span class="cx"> public:
</span><del>-    WEBCORE_EXPORT void forEach(std::function<void(const MediaConstraint&)>) const;
-    void filter(std::function<bool(const MediaConstraint&)>) const;
</del><ins>+    WEBCORE_EXPORT void forEach(WTF::Function<void(const MediaConstraint&)>&&) const;
+    void filter(const WTF::Function<bool(const MediaConstraint&)>&) const;
</ins><span class="cx">     bool isEmpty() const;
</span><span class="cx">     WEBCORE_EXPORT size_t size() const;
</span><span class="cx"> 
</span><span class="lines">@@ -806,7 +807,7 @@
</span><span class="cx"> 
</span><span class="cx"> struct MediaConstraints {
</span><span class="cx">     void setDefaultVideoConstraints();
</span><del>-    bool isConstraintSet(std::function<bool(const MediaTrackConstraintSetMap&)>&&);
</del><ins>+    bool isConstraintSet(const WTF::Function<bool(const MediaTrackConstraintSetMap&)>&);
</ins><span class="cx"> 
</span><span class="cx">     MediaTrackConstraintSetMap mandatoryConstraints;
</span><span class="cx">     Vector<MediaTrackConstraintSetMap> advancedConstraints;
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformmediastreamRealtimeMediaSourcecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/mediastream/RealtimeMediaSource.cpp (218463 => 218464)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mediastream/RealtimeMediaSource.cpp        2017-06-18 15:55:55 UTC (rev 218463)
+++ trunk/Source/WebCore/platform/mediastream/RealtimeMediaSource.cpp   2017-06-18 19:49:12 UTC (rev 218464)
</span><span class="lines">@@ -502,7 +502,7 @@
</span><span class="cx">             return false;
</span><span class="cx">         };
</span><span class="cx"> 
</span><del>-        auto modeString = downcast<StringConstraint>(constraint).find(filter);
</del><ins>+        auto modeString = downcast<StringConstraint>(constraint).find(WTFMove(filter));
</ins><span class="cx">         if (!modeString.isEmpty())
</span><span class="cx">             setFacingMode(RealtimeMediaSourceSettings::videoFacingModeEnum(modeString));
</span><span class="cx">         break;
</span></span></pre>
</div>
</div>

</body>
</html>