<!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>[212000] 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/212000">212000</a></dd>
<dt>Author</dt> <dd>beidson@apple.com</dd>
<dt>Date</dt> <dd>2017-02-09 16:21:11 -0800 (Thu, 09 Feb 2017)</dd>
</dl>

<h3>Log Message</h3>
<pre>Transition &quot;WebKit Library Version&quot; checks to SDK version checks.
&lt;rdar://problem/30313696&gt; and https://bugs.webkit.org/show_bug.cgi?id=168056

Reviewed by Geoffrey Garen.

Source/WebKit2:

When doing linkedOnOrAfter checks, relying solely on the WebKit library version number is error prone,
since apps may not link against WebKit directly and therefore the linked WebKit is unknown.

We should first prefer a version check on the SDK that the app was built with.

If that check fails, we can fallback to the linked WebKit library version number if it exists.

* Shared/Cocoa/CompletionHandlerCallChecker.mm:
(WebKit::shouldThrowExceptionForDuplicateCompletionHandlerCall):

* UIProcess/API/Cocoa/WKWebViewConfiguration.mm:
(-[WKWebViewConfiguration init]):

For each &quot;linked-on-or-after&quot; feature, include both the WebKit library version and SDK version:
* UIProcess/Cocoa/VersionChecks.h:
(WebKit::linkedOnOrAfter):
* UIProcess/Cocoa/VersionChecks.mm:
(WebKit::linkedOnOrAfter):
(WebKit::linkTimeVersion): Deleted.

* UIProcess/Cocoa/WebProcessPoolCocoa.mm:
(WebKit::WebProcessPool::isNetworkCacheEnabled):

Source/WTF:

* wtf/spi/darwin/dyldSPI.h: Add entries for the iOS 10.3, macOS 10.11, and macOS 10.12.4 SDKs.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWTFChangeLog">trunk/Source/WTF/ChangeLog</a></li>
<li><a href="#trunkSourceWTFwtfspidarwindyldSPIh">trunk/Source/WTF/wtf/spi/darwin/dyldSPI.h</a></li>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2SharedCocoaCompletionHandlerCallCheckermm">trunk/Source/WebKit2/Shared/Cocoa/CompletionHandlerCallChecker.mm</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPICocoaWKWebViewConfigurationmm">trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewConfiguration.mm</a></li>
<li><a href="#trunkSourceWebKit2UIProcessCocoaVersionChecksh">trunk/Source/WebKit2/UIProcess/Cocoa/VersionChecks.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessCocoaVersionChecksmm">trunk/Source/WebKit2/UIProcess/Cocoa/VersionChecks.mm</a></li>
<li><a href="#trunkSourceWebKit2UIProcessCocoaWebProcessPoolCocoamm">trunk/Source/WebKit2/UIProcess/Cocoa/WebProcessPoolCocoa.mm</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWTFChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/ChangeLog (211999 => 212000)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/ChangeLog        2017-02-10 00:10:14 UTC (rev 211999)
+++ trunk/Source/WTF/ChangeLog        2017-02-10 00:21:11 UTC (rev 212000)
</span><span class="lines">@@ -1,3 +1,12 @@
</span><ins>+2017-02-09  Brady Eidson  &lt;beidson@apple.com&gt;
+
+        Transition &quot;WebKit Library Version&quot; checks to SDK version checks.
+        &lt;rdar://problem/30313696&gt; and https://bugs.webkit.org/show_bug.cgi?id=168056
+
+        Reviewed by Geoffrey Garen.
+
+        * wtf/spi/darwin/dyldSPI.h: Add entries for the iOS 10.3, macOS 10.11, and macOS 10.12.4 SDKs.
+
</ins><span class="cx"> 2017-02-09  Commit Queue  &lt;commit-queue@webkit.org&gt;
</span><span class="cx"> 
</span><span class="cx">         Unreviewed, rolling out r211980 and r211987.
</span></span></pre></div>
<a id="trunkSourceWTFwtfspidarwindyldSPIh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/wtf/spi/darwin/dyldSPI.h (211999 => 212000)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/spi/darwin/dyldSPI.h        2017-02-10 00:10:14 UTC (rev 211999)
+++ trunk/Source/WTF/wtf/spi/darwin/dyldSPI.h        2017-02-10 00:21:11 UTC (rev 212000)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2016 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2016-2017 Apple Inc. All rights reserved.
</ins><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="cx">  * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -37,6 +37,14 @@
</span><span class="cx"> #define DYLD_MACOSX_VERSION_10_12 0x000A0C00
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+#ifndef DYLD_IOS_VERSION_10_3
+#define DYLD_IOS_VERSION_10_3 0x000A0300
+#endif
+
+#ifndef DYLD_MACOSX_VERSION_10_12_4
+#define DYLD_MACOSX_VERSION_10_12_4 0x000A0C04
+#endif
+
</ins><span class="cx"> #else
</span><span class="cx"> 
</span><span class="cx"> #define DYLD_IOS_VERSION_3_0 0x00030000
</span><span class="lines">@@ -46,8 +54,11 @@
</span><span class="cx"> #define DYLD_IOS_VERSION_7_0 0x00070000
</span><span class="cx"> #define DYLD_IOS_VERSION_9_0 0x00090000
</span><span class="cx"> #define DYLD_IOS_VERSION_10_0 0x000A0000
</span><ins>+#define DYLD_IOS_VERSION_10_3 0x000A0300
</ins><span class="cx"> 
</span><ins>+#define DYLD_MACOSX_VERSION_10_11 0x000A0B00
</ins><span class="cx"> #define DYLD_MACOSX_VERSION_10_12 0x000A0C00
</span><ins>+#define DYLD_MACOSX_VERSION_10_12_4 0x000A0C04
</ins><span class="cx"> 
</span><span class="cx"> #endif
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (211999 => 212000)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2017-02-10 00:10:14 UTC (rev 211999)
+++ trunk/Source/WebKit2/ChangeLog        2017-02-10 00:21:11 UTC (rev 212000)
</span><span class="lines">@@ -1,3 +1,33 @@
</span><ins>+2017-02-09  Brady Eidson  &lt;beidson@apple.com&gt;
+
+        Transition &quot;WebKit Library Version&quot; checks to SDK version checks.
+        &lt;rdar://problem/30313696&gt; and https://bugs.webkit.org/show_bug.cgi?id=168056
+
+        Reviewed by Geoffrey Garen.
+
+        When doing linkedOnOrAfter checks, relying solely on the WebKit library version number is error prone,
+        since apps may not link against WebKit directly and therefore the linked WebKit is unknown.
+        
+        We should first prefer a version check on the SDK that the app was built with.
+        
+        If that check fails, we can fallback to the linked WebKit library version number if it exists.
+
+        * Shared/Cocoa/CompletionHandlerCallChecker.mm:
+        (WebKit::shouldThrowExceptionForDuplicateCompletionHandlerCall):
+
+        * UIProcess/API/Cocoa/WKWebViewConfiguration.mm:
+        (-[WKWebViewConfiguration init]):
+
+        For each &quot;linked-on-or-after&quot; feature, include both the WebKit library version and SDK version:
+        * UIProcess/Cocoa/VersionChecks.h:
+        (WebKit::linkedOnOrAfter):
+        * UIProcess/Cocoa/VersionChecks.mm:
+        (WebKit::linkedOnOrAfter):
+        (WebKit::linkTimeVersion): Deleted.
+
+        * UIProcess/Cocoa/WebProcessPoolCocoa.mm:
+        (WebKit::WebProcessPool::isNetworkCacheEnabled):
+
</ins><span class="cx"> 2017-02-09  Commit Queue  &lt;commit-queue@webkit.org&gt;
</span><span class="cx"> 
</span><span class="cx">         Unreviewed, rolling out r211980 and r211987.
</span></span></pre></div>
<a id="trunkSourceWebKit2SharedCocoaCompletionHandlerCallCheckermm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Shared/Cocoa/CompletionHandlerCallChecker.mm (211999 => 212000)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/Cocoa/CompletionHandlerCallChecker.mm        2017-02-10 00:10:14 UTC (rev 211999)
+++ trunk/Source/WebKit2/Shared/Cocoa/CompletionHandlerCallChecker.mm        2017-02-10 00:21:11 UTC (rev 212000)
</span><span class="lines">@@ -67,7 +67,7 @@
</span><span class="cx">     static bool shouldThrowException;
</span><span class="cx">     static std::once_flag once;
</span><span class="cx">     std::call_once(once, [] {
</span><del>-        shouldThrowException = linkedOnOrAfter(LibraryVersion::FirstWithExceptionsForDuplicateCompletionHandlerCalls);
</del><ins>+        shouldThrowException = linkedOnOrAfter&lt;FirstWebKitWithExceptionsForDuplicateCompletionHandlerCalls&gt;();
</ins><span class="cx">     });
</span><span class="cx">     return shouldThrowException;
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPICocoaWKWebViewConfigurationmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewConfiguration.mm (211999 => 212000)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewConfiguration.mm        2017-02-10 00:10:14 UTC (rev 211999)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewConfiguration.mm        2017-02-10 00:21:11 UTC (rev 212000)
</span><span class="lines">@@ -145,7 +145,7 @@
</span><span class="cx">     _inlineMediaPlaybackRequiresPlaysInlineAttribute = !_allowsInlineMediaPlayback;
</span><span class="cx">     _allowsInlineMediaPlaybackAfterFullscreen = !_allowsInlineMediaPlayback;
</span><span class="cx">     _mediaDataLoadsAutomatically = NO;
</span><del>-    if (linkedOnOrAfter(WebKit::LibraryVersion::FirstWithMediaTypesRequiringUserActionForPlayback))
</del><ins>+    if (WebKit::linkedOnOrAfter&lt;WebKit::FirstWebKitWithMediaTypesRequiringUserActionForPlayback&gt;())
</ins><span class="cx">         _mediaTypesRequiringUserActionForPlayback = WKAudiovisualMediaTypeAudio;
</span><span class="cx">     else
</span><span class="cx">         _mediaTypesRequiringUserActionForPlayback = WKAudiovisualMediaTypeAll;
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessCocoaVersionChecksh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/Cocoa/VersionChecks.h (211999 => 212000)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/Cocoa/VersionChecks.h        2017-02-10 00:10:14 UTC (rev 211999)
+++ trunk/Source/WebKit2/UIProcess/Cocoa/VersionChecks.h        2017-02-10 00:21:11 UTC (rev 212000)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2015 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2015-2017 Apple Inc. All rights reserved.
</ins><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="cx">  * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -25,6 +25,8 @@
</span><span class="cx"> 
</span><span class="cx"> #pragma once
</span><span class="cx"> 
</span><ins>+#import &lt;wtf/spi/darwin/dyldSPI.h&gt;
+
</ins><span class="cx"> namespace WebKit {
</span><span class="cx"> 
</span><span class="cx"> /*
</span><span class="lines">@@ -33,15 +35,41 @@
</span><span class="cx">     For example the version 1.2.3 is returned as 0x00010203 and version 200.3.5 is returned as 0x00C80305
</span><span class="cx">     A version of -1 is returned if the main executable did not link against WebKit.
</span><span class="cx"> 
</span><del>-    Please use the current WebKit version number, available in WebKit2/Configurations/Version.xcconfig,
</del><ins>+    Use the current WebKit version number, available in WebKit2/Configurations/Version.xcconfig,
</ins><span class="cx">     when adding a new version constant.
</span><span class="cx"> */
</span><del>-enum class LibraryVersion {
-    FirstWithNetworkCache = 0x02590116, // 601.1.22
-    FirstWithMediaTypesRequiringUserActionForPlayback = 0x025A0121, // 602.1.33
-    FirstWithExceptionsForDuplicateCompletionHandlerCalls = 0x025B0111, // 603.1.17
</del><ins>+
+struct FirstWebKitWithNetworkCache {
+    static const int LibraryVersion { 0x02590116 }; // 601.1.22
+#if PLATFORM(IOS)
+    static const uint32_t SDKVersion { DYLD_IOS_VERSION_9_0 };
+#elif PLATFORM(MAC)
+    static const uint32_t SDKVersion { DYLD_MACOSX_VERSION_10_11 };
+#endif
</ins><span class="cx"> };
</span><span class="cx"> 
</span><del>-bool linkedOnOrAfter(LibraryVersion);
</del><ins>+struct FirstWebKitWithMediaTypesRequiringUserActionForPlayback {
+    static const int LibraryVersion { 0x025A0121 }; // 602.1.33
+#if PLATFORM(IOS)
+    static const uint32_t SDKVersion { DYLD_IOS_VERSION_10_0 };
+#elif PLATFORM(MAC)
+    static const uint32_t SDKVersion { DYLD_MACOSX_VERSION_10_12 };
+#endif
+};
</ins><span class="cx"> 
</span><ins>+struct FirstWebKitWithExceptionsForDuplicateCompletionHandlerCalls {
+    static const int LibraryVersion { 0x025B0111 }; // 603.1.17
+#if PLATFORM(IOS)
+    static const uint32_t SDKVersion { DYLD_IOS_VERSION_10_3 };
+#elif PLATFORM(MAC)
+    static const uint32_t SDKVersion { DYLD_MACOSX_VERSION_10_12_4 };
+#endif
+};
+
+bool linkedOnOrAfter(int libraryVersion, uint32_t sdkVersion);
+template &lt;typename VersionInfo&gt; bool linkedOnOrAfter()
+{
+    return linkedOnOrAfter(VersionInfo::LibraryVersion, VersionInfo::SDKVersion);
</ins><span class="cx"> }
</span><ins>+
+}
</ins></span></pre></div>
<a id="trunkSourceWebKit2UIProcessCocoaVersionChecksmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/Cocoa/VersionChecks.mm (211999 => 212000)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/Cocoa/VersionChecks.mm        2017-02-10 00:10:14 UTC (rev 211999)
+++ trunk/Source/WebKit2/UIProcess/Cocoa/VersionChecks.mm        2017-02-10 00:21:11 UTC (rev 212000)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2015 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2015-2017 Apple Inc. All rights reserved.
</ins><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="cx">  * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -34,13 +34,8 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WebKit {
</span><span class="cx"> 
</span><del>-static int linkTimeVersion()
</del><ins>+bool linkedOnOrAfter(int libraryVersion, uint32_t sdkVersion)
</ins><span class="cx"> {
</span><del>-    return NSVersionOfLinkTimeLibrary(&quot;WebKit&quot;);
-}
-
-bool linkedOnOrAfter(LibraryVersion version)
-{
</del><span class="cx"> #if PLATFORM(IOS)
</span><span class="cx">     // Always make new features available for Safari.
</span><span class="cx">     if (WebCore::IOSApplication::isMobileSafari())
</span><span class="lines">@@ -47,12 +42,15 @@
</span><span class="cx">         return true;
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-    int linkedVersion = linkTimeVersion();
-    if (linkedVersion == -1) {
-        // Not linked against WebKit.
</del><ins>+    // If the app was build against a new enough SDK, it definitely passes the linked-on-or-after check.
+    if (dyld_get_program_sdk_version() &gt;= sdkVersion)
</ins><span class="cx">         return true;
</span><del>-    }
-    return linkedVersion &gt;= static_cast&lt;int&gt;(version);
</del><ins>+
+    // If the app was built against an older SDK, we might still consider it linked-on-or-after
+    // by checking the linked WebKit library version number, if one exists.
+
+    int linkedVersion = NSVersionOfLinkTimeLibrary(&quot;WebKit&quot;);
+    return linkedVersion == -1 ? false : linkedVersion &gt;= libraryVersion;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessCocoaWebProcessPoolCocoamm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/Cocoa/WebProcessPoolCocoa.mm (211999 => 212000)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/Cocoa/WebProcessPoolCocoa.mm        2017-02-10 00:10:14 UTC (rev 211999)
+++ trunk/Source/WebKit2/UIProcess/Cocoa/WebProcessPoolCocoa.mm        2017-02-10 00:21:11 UTC (rev 212000)
</span><span class="lines">@@ -462,7 +462,7 @@
</span><span class="cx"> 
</span><span class="cx">     bool networkCacheEnabledByDefaults = [defaults boolForKey:WebKitNetworkCacheEnabledDefaultsKey];
</span><span class="cx"> 
</span><del>-    return networkCacheEnabledByDefaults &amp;&amp; linkedOnOrAfter(LibraryVersion::FirstWithNetworkCache);
</del><ins>+    return networkCacheEnabledByDefaults &amp;&amp; linkedOnOrAfter&lt;FirstWebKitWithNetworkCache&gt;();
</ins><span class="cx"> #else
</span><span class="cx">     return false;
</span><span class="cx"> #endif
</span></span></pre>
</div>
</div>

</body>
</html>