<!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>[279339] trunk</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/279339">279339</a></dd>
<dt>Author</dt> <dd>weinig@apple.com</dd>
<dt>Date</dt> <dd>2021-06-28 08:34:32 -0700 (Mon, 28 Jun 2021)</dd>
</dl>

<h3>Log Message</h3>
<pre>Add helpers to create Spans from CFDataRef and NSData
https://bugs.webkit.org/show_bug.cgi?id=227217

Reviewed by Chris Dumez.

Source/WTF:

Add overloads of asBytes() for CFDataRef and NSData. This is going to
be a common enough pattern to warrent these helpers.

* WTF.xcodeproj/project.pbxproj:
* wtf/PlatformFTW.cmake:
* wtf/PlatformMac.cmake:
* wtf/PlatformWin.cmake:
* wtf/cf/SpanCF.h: Added.
(WTF::asBytes):
* wtf/cocoa/SpanCocoa.h: Added.
(WTF::asBytes):

Tools:

* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WTF/cf/SpanCF.cpp: Added.
* TestWebKitAPI/Tests/WTF/cocoa/SpanCocoa.mm: Added.
Add tests for new asBytes() overloads.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWTFChangeLog">trunk/Source/WTF/ChangeLog</a></li>
<li><a href="#trunkSourceWTFWTFxcodeprojprojectpbxproj">trunk/Source/WTF/WTF.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkSourceWTFwtfPlatformFTWcmake">trunk/Source/WTF/wtf/PlatformFTW.cmake</a></li>
<li><a href="#trunkSourceWTFwtfPlatformMaccmake">trunk/Source/WTF/wtf/PlatformMac.cmake</a></li>
<li><a href="#trunkSourceWTFwtfPlatformWincmake">trunk/Source/WTF/wtf/PlatformWin.cmake</a></li>
<li><a href="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsTestWebKitAPITestWebKitAPIxcodeprojprojectpbxproj">trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceWTFwtfcfSpanCFh">trunk/Source/WTF/wtf/cf/SpanCF.h</a></li>
<li><a href="#trunkSourceWTFwtfcocoaSpanCocoah">trunk/Source/WTF/wtf/cocoa/SpanCocoa.h</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWTFcfSpanCFcpp">trunk/Tools/TestWebKitAPI/Tests/WTF/cf/SpanCF.cpp</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWTFcocoaSpanCocoamm">trunk/Tools/TestWebKitAPI/Tests/WTF/cocoa/SpanCocoa.mm</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWTFChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/ChangeLog (279338 => 279339)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/ChangeLog       2021-06-28 13:57:15 UTC (rev 279338)
+++ trunk/Source/WTF/ChangeLog  2021-06-28 15:34:32 UTC (rev 279339)
</span><span class="lines">@@ -1,3 +1,22 @@
</span><ins>+2021-06-28  Sam Weinig  <weinig@apple.com>
+
+        Add helpers to create Spans from CFDataRef and NSData
+        https://bugs.webkit.org/show_bug.cgi?id=227217
+
+        Reviewed by Chris Dumez.
+
+        Add overloads of asBytes() for CFDataRef and NSData. This is going to
+        be a common enough pattern to warrent these helpers.
+
+        * WTF.xcodeproj/project.pbxproj:
+        * wtf/PlatformFTW.cmake:
+        * wtf/PlatformMac.cmake:
+        * wtf/PlatformWin.cmake:
+        * wtf/cf/SpanCF.h: Added.
+        (WTF::asBytes):
+        * wtf/cocoa/SpanCocoa.h: Added.
+        (WTF::asBytes):
+
</ins><span class="cx"> 2021-06-27  Antoine Quint  <graouts@webkit.org>
</span><span class="cx"> 
</span><span class="cx">         [Model] [iOS] Add support for rendering model resources
</span></span></pre></div>
<a id="trunkSourceWTFWTFxcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/WTF.xcodeproj/project.pbxproj (279338 => 279339)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/WTF.xcodeproj/project.pbxproj   2021-06-28 13:57:15 UTC (rev 279338)
+++ trunk/Source/WTF/WTF.xcodeproj/project.pbxproj      2021-06-28 15:34:32 UTC (rev 279339)
</span><span class="lines">@@ -692,6 +692,8 @@
</span><span class="cx">          AD89B6B91E64150F0090707F /* MemoryPressureHandlerCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MemoryPressureHandlerCocoa.mm; sourceTree = "<group>"; };
</span><span class="cx">          ADF2CE641E39F106006889DB /* MemoryFootprint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MemoryFootprint.h; sourceTree = "<group>"; };
</span><span class="cx">          ADF2CE651E39F106006889DB /* MemoryFootprintCocoa.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MemoryFootprintCocoa.cpp; sourceTree = "<group>"; };
</span><ins>+               BC3FEB5D267FCD340054006A /* SpanCF.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SpanCF.h; sourceTree = "<group>"; };
+               BC3FEB5E267FCD460054006A /* SpanCocoa.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SpanCocoa.h; sourceTree = "<group>"; };
</ins><span class="cx">           BCA30C7F266D3034000D230C /* Span.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Span.h; sourceTree = "<group>"; };
</span><span class="cx">          C2BCFC3E1F61D13000C9222C /* Language.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Language.cpp; sourceTree = "<group>"; };
</span><span class="cx">          C2BCFC3F1F61D13000C9222C /* Language.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Language.h; sourceTree = "<group>"; };
</span><span class="lines">@@ -840,6 +842,7 @@
</span><span class="cx">                          C2BCFC411F61D61600C9222C /* LanguageCF.cpp */,
</span><span class="cx">                          2CDED0EE18115C38004DBA70 /* RunLoopCF.cpp */,
</span><span class="cx">                          A3EE5C3B21FFAC7C00FABD61 /* SchedulePairCF.cpp */,
</span><ins>+                               BC3FEB5D267FCD340054006A /* SpanCF.h */,
</ins><span class="cx">                           1AFDE647195201C300C48FFA /* TypeCastsCF.h */,
</span><span class="cx">                          5C1F0594216437B30039302C /* URLCF.cpp */,
</span><span class="cx">                  );
</span><span class="lines">@@ -1581,6 +1584,7 @@
</span><span class="cx">                          1CA85CA8241B0B260071C2F5 /* RuntimeApplicationChecksCocoa.cpp */,
</span><span class="cx">                          1CA85CA7241B0B110071C2F5 /* RuntimeApplicationChecksCocoa.h */,
</span><span class="cx">                          A30D412C1F0DE0BA00B71954 /* SoftLinking.h */,
</span><ins>+                               BC3FEB5E267FCD460054006A /* SpanCocoa.h */,
</ins><span class="cx">                           EB61EDC62409CCC0001EFE36 /* SystemTracingCocoa.cpp */,
</span><span class="cx">                          5CC0EE862162BC2200A1A842 /* URLCocoa.mm */,
</span><span class="cx">                          93241657243BC2E50032FAAE /* VectorCocoa.h */,
</span></span></pre></div>
<a id="trunkSourceWTFwtfPlatformFTWcmake"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/wtf/PlatformFTW.cmake (279338 => 279339)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/PlatformFTW.cmake   2021-06-28 13:57:15 UTC (rev 279338)
+++ trunk/Source/WTF/wtf/PlatformFTW.cmake      2021-06-28 15:34:32 UTC (rev 279339)
</span><span class="lines">@@ -37,6 +37,7 @@
</span><span class="cx"> if (USE_CF)
</span><span class="cx">     list(APPEND WTF_PUBLIC_HEADERS
</span><span class="cx">         cf/CFURLExtras.h
</span><ins>+        cf/SpanCF.h
</ins><span class="cx">         cf/TypeCastsCF.h
</span><span class="cx"> 
</span><span class="cx">         text/cf/StringConcatenateCF.h
</span></span></pre></div>
<a id="trunkSourceWTFwtfPlatformMaccmake"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/wtf/PlatformMac.cmake (279338 => 279339)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/PlatformMac.cmake   2021-06-28 13:57:15 UTC (rev 279338)
+++ trunk/Source/WTF/wtf/PlatformMac.cmake      2021-06-28 15:34:32 UTC (rev 279339)
</span><span class="lines">@@ -11,6 +11,7 @@
</span><span class="cx">     WeakObjCPtr.h
</span><span class="cx"> 
</span><span class="cx">     cf/CFURLExtras.h
</span><ins>+    cf/SpanCF.h
</ins><span class="cx">     cf/TypeCastsCF.h
</span><span class="cx"> 
</span><span class="cx">     cocoa/CrashReporter.h
</span><span class="lines">@@ -18,6 +19,7 @@
</span><span class="cx">     cocoa/NSURLExtras.h
</span><span class="cx">     cocoa/RuntimeApplicationChecksCocoa.h
</span><span class="cx">     cocoa/SoftLinking.h
</span><ins>+    cocoa/SpanCocoa.h
</ins><span class="cx">     cocoa/VectorCocoa.h
</span><span class="cx"> 
</span><span class="cx">     darwin/WeakLinking.h
</span></span></pre></div>
<a id="trunkSourceWTFwtfPlatformWincmake"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/wtf/PlatformWin.cmake (279338 => 279339)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/PlatformWin.cmake   2021-06-28 13:57:15 UTC (rev 279338)
+++ trunk/Source/WTF/wtf/PlatformWin.cmake      2021-06-28 15:34:32 UTC (rev 279339)
</span><span class="lines">@@ -35,6 +35,7 @@
</span><span class="cx"> if (USE_CF)
</span><span class="cx">     list(APPEND WTF_PUBLIC_HEADERS
</span><span class="cx">         cf/CFURLExtras.h
</span><ins>+        cf/SpanCF.h
</ins><span class="cx">         cf/TypeCastsCF.h
</span><span class="cx"> 
</span><span class="cx">         text/cf/StringConcatenateCF.h
</span></span></pre></div>
<a id="trunkSourceWTFwtfcfSpanCFh"></a>
<div class="addfile"><h4>Added: trunk/Source/WTF/wtf/cf/SpanCF.h (0 => 279339)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/cf/SpanCF.h                         (rev 0)
+++ trunk/Source/WTF/wtf/cf/SpanCF.h    2021-06-28 15:34:32 UTC (rev 279339)
</span><span class="lines">@@ -0,0 +1,46 @@
</span><ins>+/*
+ * Copyright (C) 2021 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include <CoreFoundation/CoreFoundation.h>
+#include <wtf/RetainPtr.h>
+#include <wtf/Span.h>
+
+namespace WTF {
+
+inline Span<const std::byte> asBytes(CFDataRef data)
+{
+    return { reinterpret_cast<const std::byte*>(CFDataGetBytePtr(data)), static_cast<size_t>(CFDataGetLength(data)) };
+}
+
+inline Span<const std::byte> asBytes(const RetainPtr<CFDataRef>& data)
+{
+    return asBytes(data.get());
+}
+
+}
+
+using WTF::asBytes;
</ins></span></pre></div>
<a id="trunkSourceWTFwtfcocoaSpanCocoah"></a>
<div class="addfile"><h4>Added: trunk/Source/WTF/wtf/cocoa/SpanCocoa.h (0 => 279339)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/cocoa/SpanCocoa.h                           (rev 0)
+++ trunk/Source/WTF/wtf/cocoa/SpanCocoa.h      2021-06-28 15:34:32 UTC (rev 279339)
</span><span class="lines">@@ -0,0 +1,46 @@
</span><ins>+/*
+ * Copyright (C) 2021 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include <Foundation/Foundation.h>
+#include <wtf/RetainPtr.h>
+#include <wtf/Span.h>
+
+namespace WTF {
+
+inline Span<const std::byte> asBytes(NSData *data)
+{
+    return { reinterpret_cast<const std::byte*>(data.bytes), data.length };
+}
+
+inline Span<const std::byte> asBytes(const RetainPtr<NSData>& data)
+{
+    return asBytes(data.get());
+}
+
+}
+
+using WTF::asBytes;
</ins></span></pre></div>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (279338 => 279339)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog    2021-06-28 13:57:15 UTC (rev 279338)
+++ trunk/Tools/ChangeLog       2021-06-28 15:34:32 UTC (rev 279339)
</span><span class="lines">@@ -1,3 +1,15 @@
</span><ins>+2021-06-28  Sam Weinig  <weinig@apple.com>
+
+        Add helpers to create Spans from CFDataRef and NSData
+        https://bugs.webkit.org/show_bug.cgi?id=227217
+
+        Reviewed by Chris Dumez.
+
+        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+        * TestWebKitAPI/Tests/WTF/cf/SpanCF.cpp: Added.
+        * TestWebKitAPI/Tests/WTF/cocoa/SpanCocoa.mm: Added.
+        Add tests for new asBytes() overloads. 
+
</ins><span class="cx"> 2021-06-28  Philippe Normand  <pnormand@igalia.com>
</span><span class="cx"> 
</span><span class="cx">         [webkitpy] Test timeouts not properly detected when running layout tests with Python 3
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestWebKitAPIxcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (279338 => 279339)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj        2021-06-28 13:57:15 UTC (rev 279338)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj   2021-06-28 15:34:32 UTC (rev 279339)
</span><span class="lines">@@ -979,6 +979,8 @@
</span><span class="cx">          BC22D31914DC68B900FFB1DD /* UserMessage_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC22D31714DC68B800FFB1DD /* UserMessage_Bundle.cpp */; };
</span><span class="cx">          BC246D9C132F1FF000B56D7C /* CanHandleRequest_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC246D97132F1FE100B56D7C /* CanHandleRequest_Bundle.cpp */; };
</span><span class="cx">          BC2D006412AA04CE00E732A3 /* file-with-anchor.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = BC2D004A12A9FEB300E732A3 /* file-with-anchor.html */; };
</span><ins>+               BC3FEB61267FCDB00054006A /* SpanCF.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC3FEB60267FCDB00054006A /* SpanCF.cpp */; };
+               BC3FEB64267FCF740054006A /* SpanCocoa.mm in Sources */ = {isa = PBXBuildFile; fileRef = BC3FEB63267FCF740054006A /* SpanCocoa.mm */; };
</ins><span class="cx">           BC575A97126E74F1006F0F12 /* InjectedBundleMain.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC575946126E7351006F0F12 /* InjectedBundleMain.cpp */; };
</span><span class="cx">          BC575AA2126E7660006F0F12 /* InjectedBundleController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC575AA0126E7657006F0F12 /* InjectedBundleController.cpp */; };
</span><span class="cx">          BC575AB0126E83C8006F0F12 /* InjectedBundleBasic_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC575AAF126E83C8006F0F12 /* InjectedBundleBasic_Bundle.cpp */; };
</span><span class="lines">@@ -2735,6 +2737,8 @@
</span><span class="cx">          BC2D004A12A9FEB300E732A3 /* file-with-anchor.html */ = {isa = PBXFileReference; explicitFileType = text.html; fileEncoding = 4; path = "file-with-anchor.html"; sourceTree = "<group>"; };
</span><span class="cx">          BC3C4C7014575B6A0025FB62 /* WKBrowsingContextLoadDelegateTest.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = WKBrowsingContextLoadDelegateTest.mm; path = WebKitObjC/WKBrowsingContextLoadDelegateTest.mm; sourceTree = "<group>"; };
</span><span class="cx">          BC3C4C7D14587AA60025FB62 /* WKBrowsingContextGroupTest.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = WKBrowsingContextGroupTest.mm; path = WebKitObjC/WKBrowsingContextGroupTest.mm; sourceTree = "<group>"; };
</span><ins>+               BC3FEB60267FCDB00054006A /* SpanCF.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = SpanCF.cpp; sourceTree = "<group>"; };
+               BC3FEB63267FCF740054006A /* SpanCocoa.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = SpanCocoa.mm; sourceTree = "<group>"; };
</ins><span class="cx">           BC55F5F814AD78EE00484BE1 /* Vector.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Vector.cpp; sourceTree = "<group>"; };
</span><span class="cx">          BC575946126E7351006F0F12 /* InjectedBundleMain.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InjectedBundleMain.cpp; sourceTree = "<group>"; };
</span><span class="cx">          BC575980126E74AF006F0F12 /* InjectedBundleTestWebKitAPI.bundle */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = InjectedBundleTestWebKitAPI.bundle; sourceTree = BUILT_PRODUCTS_DIR; };
</span><span class="lines">@@ -4850,6 +4854,7 @@
</span><span class="cx">                  children = (
</span><span class="cx">                          BC029B161486AD6400817DA9 /* RetainPtr.cpp */,
</span><span class="cx">                          C0991C50143C7D68007998F2 /* RetainPtrHashing.cpp */,
</span><ins>+                               BC3FEB60267FCDB00054006A /* SpanCF.cpp */,
</ins><span class="cx">                   );
</span><span class="cx">                  path = cf;
</span><span class="cx">                  sourceTree = "<group>";
</span><span class="lines">@@ -4944,6 +4949,7 @@
</span><span class="cx">          E3C21A7821B25C82003B31A3 /* cocoa */ = {
</span><span class="cx">                  isa = PBXGroup;
</span><span class="cx">                  children = (
</span><ins>+                               BC3FEB63267FCF740054006A /* SpanCocoa.mm */,
</ins><span class="cx">                           E3C21A7B21B25CA2003B31A3 /* URLExtras.mm */,
</span><span class="cx">                  );
</span><span class="cx">                  path = cocoa;
</span><span class="lines">@@ -5757,6 +5763,8 @@
</span><span class="cx">                          510A91F824D3622100BFD89C /* SonyDualShock3.mm in Sources */,
</span><span class="cx">                          51EB126424CA6B66000CB030 /* SonyDualShock4.mm in Sources */,
</span><span class="cx">                          7CCE7F151A411AE600447C4C /* SpacebarScrolling.cpp in Sources */,
</span><ins>+                               BC3FEB61267FCDB00054006A /* SpanCF.cpp in Sources */,
+                               BC3FEB64267FCF740054006A /* SpanCocoa.mm in Sources */,
</ins><span class="cx">                           9342589C255B609B0059EEDD /* SpeechRecognition.mm in Sources */,
</span><span class="cx">                          57F4AAA0208FAEF000A68E9E /* SSLKeyGenerator.mm in Sources */,
</span><span class="cx">                          83BC5AC020E6C0DF00F5879F /* StartLoadInDidFailProvisionalLoad.mm in Sources */,
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWTFcfSpanCFcpp"></a>
<div class="addfile"><h4>Added: trunk/Tools/TestWebKitAPI/Tests/WTF/cf/SpanCF.cpp (0 => 279339)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WTF/cf/SpanCF.cpp                                (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WTF/cf/SpanCF.cpp   2021-06-28 15:34:32 UTC (rev 279339)
</span><span class="lines">@@ -0,0 +1,66 @@
</span><ins>+/*
+ * Copyright (C) 2021 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include <wtf/cf/SpanCF.h>
+
+namespace TestWebKitAPI {
+
+TEST(WTFSpanCF, Empty)
+{
+    auto data = adoptCF(CFDataCreate(nullptr, nullptr, 0));
+
+    {
+        auto span = asBytes(data.get());
+        EXPECT_EQ(span.size(), 0u);
+        EXPECT_EQ(span.data(), nullptr);
+    }
+
+    {
+        auto span = asBytes(data);
+        EXPECT_EQ(span.size(), 0u);
+        EXPECT_EQ(span.data(), nullptr);
+    }
+}
+
+TEST(WTFSpanCF, Bytes)
+{
+    const uint8_t input[4] = { 1, 2, 3, 4 };
+    auto data = adoptCF(CFDataCreateWithBytesNoCopy(nullptr, input, 4, kCFAllocatorNull));
+
+    {
+        auto span = asBytes(data.get());
+        EXPECT_EQ(span.size(), 4u);
+        EXPECT_EQ(reinterpret_cast<const uint8_t*>(span.data()), input);
+    }
+
+    {
+        auto span = asBytes(data);
+        EXPECT_EQ(span.size(), 4u);
+        EXPECT_EQ(reinterpret_cast<const uint8_t*>(span.data()), input);
+    }
+}
+
+}
</ins></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWTFcocoaSpanCocoamm"></a>
<div class="addfile"><h4>Added: trunk/Tools/TestWebKitAPI/Tests/WTF/cocoa/SpanCocoa.mm (0 => 279339)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WTF/cocoa/SpanCocoa.mm                           (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WTF/cocoa/SpanCocoa.mm      2021-06-28 15:34:32 UTC (rev 279339)
</span><span class="lines">@@ -0,0 +1,66 @@
</span><ins>+/*
+ * Copyright (C) 2021 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include <wtf/cocoa/SpanCocoa.h>
+
+namespace TestWebKitAPI {
+
+TEST(WTFSpanCocoa, Empty)
+{
+    auto data = adoptNS([[NSData alloc] init]);
+
+    {
+        auto span = asBytes(data.get());
+        EXPECT_EQ(span.size(), 0u);
+        EXPECT_EQ(span.data(), nullptr);
+    }
+
+    {
+        auto span = asBytes(data);
+        EXPECT_EQ(span.size(), 0u);
+        EXPECT_EQ(span.data(), nullptr);
+    }
+}
+
+TEST(WTFSpanCocoa, Bytes)
+{
+    uint8_t input[4] = { 1, 2, 3, 4 };
+    auto data = adoptNS([[NSData alloc] initWithBytesNoCopy:input length:4 deallocator:^(void*, NSUInteger) { }]);
+
+    {
+        auto span = asBytes(data.get());
+        EXPECT_EQ(span.size(), 4u);
+        EXPECT_EQ(reinterpret_cast<const uint8_t*>(span.data()), input);
+    }
+
+    {
+        auto span = asBytes(data);
+        EXPECT_EQ(span.size(), 4u);
+        EXPECT_EQ(reinterpret_cast<const uint8_t*>(span.data()), input);
+    }
+}
+
+}
</ins></span></pre>
</div>
</div>

</body>
</html>