<!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>[243116] 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/243116">243116</a></dd>
<dt>Author</dt> <dd>timothy@apple.com</dd>
<dt>Date</dt> <dd>2019-03-18 16:54:38 -0700 (Mon, 18 Mar 2019)</dd>
</dl>

<h3>Log Message</h3>
<pre>WKWebView.GetContentsShouldReturnAttributedString is crashing on iOS Simulator.
https://bugs.webkit.org/show_bug.cgi?id=195916

Reviewed by Tim Horton.

Source/WebCore:

* WebCore.xcodeproj/project.pbxproj: Make ColorIOS.h a private header.
* platform/ios/ColorIOS.h: Export colorFromUIColor.

Source/WebKit:

Add direct support for UIColor so it does not try to use the NSSecureCoding path.
This avoids needs to list the classes when decoding the attributes NSDictionary
and matches the macOS NSColor encoder/decoder.

* Shared/Cocoa/ArgumentCodersCocoa.mm:
(IPC::typeFromObject):
(IPC::encodeColorInternal):
(IPC::decodeColorInternal):
(IPC::encodeObject):
(IPC::decodeObject):

Tools:

* TestWebKitAPI/Tests/WebKitCocoa/WKWebViewGetContents.mm:
(TEST(WKWebView, GetContentsShouldReturnAttributedString): Fix iOS code path to pass.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreWebCorexcodeprojprojectpbxproj">trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkSourceWebCoreplatformiosColorIOSh">trunk/Source/WebCore/platform/ios/ColorIOS.h</a></li>
<li><a href="#trunkSourceWebKitChangeLog">trunk/Source/WebKit/ChangeLog</a></li>
<li><a href="#trunkSourceWebKitSharedCocoaArgumentCodersCocoamm">trunk/Source/WebKit/Shared/Cocoa/ArgumentCodersCocoa.mm</a></li>
<li><a href="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKitCocoaWKWebViewGetContentsmm">trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebViewGetContents.mm</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (243115 => 243116)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog   2019-03-18 23:51:42 UTC (rev 243115)
+++ trunk/Source/WebCore/ChangeLog      2019-03-18 23:54:38 UTC (rev 243116)
</span><span class="lines">@@ -1,3 +1,13 @@
</span><ins>+2019-03-18  Timothy Hatcher  <timothy@apple.com>
+
+        WKWebView.GetContentsShouldReturnAttributedString is crashing on iOS Simulator.
+        https://bugs.webkit.org/show_bug.cgi?id=195916
+
+        Reviewed by Tim Horton.
+
+        * WebCore.xcodeproj/project.pbxproj: Make ColorIOS.h a private header.
+        * platform/ios/ColorIOS.h: Export colorFromUIColor.
+
</ins><span class="cx"> 2019-03-18  Said Abou-Hallawa  <sabouhallawa@apple.com>
</span><span class="cx"> 
</span><span class="cx">         Define the type of SVGPropertyOwnerRegistry for all SVG elements
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (243115 => 243116)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj   2019-03-18 23:51:42 UTC (rev 243115)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj      2019-03-18 23:54:38 UTC (rev 243116)
</span><span class="lines">@@ -4235,7 +4235,7 @@
</span><span class="cx">          CE08C3D2152B599A0021B8C2 /* AlternativeTextController.h in Headers */ = {isa = PBXBuildFile; fileRef = CE08C3D0152B599A0021B8C2 /* AlternativeTextController.h */; settings = {ATTRIBUTES = (); }; };
</span><span class="cx">          CE1866451F72E5B400A0CAB6 /* MarkedText.h in Headers */ = {isa = PBXBuildFile; fileRef = CE1866431F72E5B400A0CAB6 /* MarkedText.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">          CE2849871CA360DF00B4A57F /* ContentSecurityPolicyDirectiveNames.h in Headers */ = {isa = PBXBuildFile; fileRef = CE2849861CA360DF00B4A57F /* ContentSecurityPolicyDirectiveNames.h */; };
</span><del>-               CE5169E721F1B84700EA4F78 /* ColorIOS.h in Headers */ = {isa = PBXBuildFile; fileRef = CE5169E521F1B84700EA4F78 /* ColorIOS.h */; };
</del><ins>+                CE5169E721F1B84700EA4F78 /* ColorIOS.h in Headers */ = {isa = PBXBuildFile; fileRef = CE5169E521F1B84700EA4F78 /* ColorIOS.h */; settings = {ATTRIBUTES = (Private, ); }; };
</ins><span class="cx">           CE5FA255209E48C50051D700 /* ContentSecurityPolicyClient.h in Headers */ = {isa = PBXBuildFile; fileRef = CE5FA253209E48C50051D700 /* ContentSecurityPolicyClient.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">          CE6DADFA1C591E6A003F6A88 /* ContentSecurityPolicyResponseHeaders.h in Headers */ = {isa = PBXBuildFile; fileRef = CE6DADF81C591E6A003F6A88 /* ContentSecurityPolicyResponseHeaders.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">          CE799F981C6A46BC0097B518 /* ContentSecurityPolicySourceList.h in Headers */ = {isa = PBXBuildFile; fileRef = CE799F961C6A46BC0097B518 /* ContentSecurityPolicySourceList.h */; };
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformiosColorIOSh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/ios/ColorIOS.h (243115 => 243116)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/ios/ColorIOS.h     2019-03-18 23:51:42 UTC (rev 243115)
+++ trunk/Source/WebCore/platform/ios/ColorIOS.h        2019-03-18 23:54:38 UTC (rev 243116)
</span><span class="lines">@@ -33,7 +33,7 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><del>-Color colorFromUIColor(UIColor *);
</del><ins>+WEBCORE_EXPORT Color colorFromUIColor(UIColor *);
</ins><span class="cx"> 
</span><span class="cx"> } // namespace WebCore
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKitChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/ChangeLog (243115 => 243116)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/ChangeLog    2019-03-18 23:51:42 UTC (rev 243115)
+++ trunk/Source/WebKit/ChangeLog       2019-03-18 23:54:38 UTC (rev 243116)
</span><span class="lines">@@ -1,5 +1,23 @@
</span><span class="cx"> 2019-03-18  Timothy Hatcher  <timothy@apple.com>
</span><span class="cx"> 
</span><ins>+        WKWebView.GetContentsShouldReturnAttributedString is crashing on iOS Simulator.
+        https://bugs.webkit.org/show_bug.cgi?id=195916
+
+        Reviewed by Tim Horton.
+
+        Add direct support for UIColor so it does not try to use the NSSecureCoding path.
+        This avoids needs to list the classes when decoding the attributes NSDictionary
+        and matches the macOS NSColor encoder/decoder.
+
+        * Shared/Cocoa/ArgumentCodersCocoa.mm:
+        (IPC::typeFromObject):
+        (IPC::encodeColorInternal):
+        (IPC::decodeColorInternal):
+        (IPC::encodeObject):
+        (IPC::decodeObject):
+
+2019-03-18  Timothy Hatcher  <timothy@apple.com>
+
</ins><span class="cx">         Add new NSAttributedString API for converting HTML.
</span><span class="cx">         https://bugs.webkit.org/show_bug.cgi?id=195636
</span><span class="cx">         rdar://problem/45055697
</span></span></pre></div>
<a id="trunkSourceWebKitSharedCocoaArgumentCodersCocoamm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/Shared/Cocoa/ArgumentCodersCocoa.mm (243115 => 243116)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/Shared/Cocoa/ArgumentCodersCocoa.mm  2019-03-18 23:51:42 UTC (rev 243115)
+++ trunk/Source/WebKit/Shared/Cocoa/ArgumentCodersCocoa.mm     2019-03-18 23:54:38 UTC (rev 243116)
</span><span class="lines">@@ -36,17 +36,22 @@
</span><span class="cx"> 
</span><span class="cx"> #if USE(APPKIT)
</span><span class="cx"> #import <WebCore/ColorMac.h>
</span><ins>+#else
+#import <WebCore/ColorIOS.h>
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> #if PLATFORM(IOS_FAMILY)
</span><ins>+#import <UIKit/UIColor.h>
</ins><span class="cx"> #import <UIKit/UIFont.h>
</span><span class="cx"> #import <UIKit/UIFontDescriptor.h>
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> #if USE(APPKIT)
</span><ins>+using PlatformColor = NSColor;
</ins><span class="cx"> using PlatformFont = NSFont;
</span><span class="cx"> using PlatformFontDescriptor = NSFontDescriptor;
</span><span class="cx"> #else
</span><ins>+using PlatformColor = UIColor;
</ins><span class="cx"> using PlatformFont = UIFont;
</span><span class="cx"> using PlatformFontDescriptor = UIFontDescriptor;
</span><span class="cx"> #endif
</span><span class="lines">@@ -58,9 +63,7 @@
</span><span class="cx"> 
</span><span class="cx"> enum class NSType {
</span><span class="cx">     Array,
</span><del>-#if USE(APPKIT)
</del><span class="cx">     Color,
</span><del>-#endif
</del><span class="cx">     Data,
</span><span class="cx">     Date,
</span><span class="cx">     Dictionary,
</span><span class="lines">@@ -81,10 +84,8 @@
</span><span class="cx">     // Specific classes handled.
</span><span class="cx">     if ([object isKindOfClass:[NSArray class]])
</span><span class="cx">         return NSType::Array;
</span><del>-#if USE(APPKIT)
-    if ([object isKindOfClass:[NSColor class]])
</del><ins>+    if ([object isKindOfClass:[PlatformColor class]])
</ins><span class="cx">         return NSType::Color;
</span><del>-#endif
</del><span class="cx">     if ([object isKindOfClass:[NSData class]])
</span><span class="cx">         return NSType::Data;
</span><span class="cx">     if ([object isKindOfClass:[NSDate class]])
</span><span class="lines">@@ -170,7 +171,7 @@
</span><span class="cx">     return { array };
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-#pragma mark - NSColor
</del><ins>+#pragma mark - NSColor / UIColor
</ins><span class="cx"> 
</span><span class="cx"> #if USE(APPKIT)
</span><span class="cx"> static inline void encodeColorInternal(Encoder& encoder, NSColor *color)
</span><span class="lines">@@ -185,6 +186,19 @@
</span><span class="cx">         return WTF::nullopt;
</span><span class="cx">     return { nsColor(color) };
</span><span class="cx"> }
</span><ins>+#else
+static inline void encodeColorInternal(Encoder& encoder, UIColor *color)
+{
+    encoder << colorFromUIColor(color);
+}
+
+static inline Optional<RetainPtr<id>> decodeColorInternal(Decoder& decoder)
+{
+    Color color;
+    if (!decoder.decode(color))
+        return WTF::nullopt;
+    return { adoptNS([[UIColor alloc] initWithCGColor:cachedCGColor(color)]) };
+}
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> #pragma mark - NSData
</span><span class="lines">@@ -384,11 +398,9 @@
</span><span class="cx">     case NSType::Array:
</span><span class="cx">         encodeArrayInternal(encoder, static_cast<NSArray *>(object));
</span><span class="cx">         return;
</span><del>-#if USE(APPKIT)
</del><span class="cx">     case NSType::Color:
</span><del>-        encodeColorInternal(encoder, static_cast<NSColor *>(object));
</del><ins>+        encodeColorInternal(encoder, static_cast<PlatformColor *>(object));
</ins><span class="cx">         return;
</span><del>-#endif
</del><span class="cx">     case NSType::Dictionary:
</span><span class="cx">         encodeDictionaryInternal(encoder, static_cast<NSDictionary *>(object));
</span><span class="cx">         return;
</span><span class="lines">@@ -435,10 +447,8 @@
</span><span class="cx">     switch (type) {
</span><span class="cx">     case NSType::Array:
</span><span class="cx">         return decodeArrayInternal(decoder, allowedClasses);
</span><del>-#if USE(APPKIT)
</del><span class="cx">     case NSType::Color:
</span><span class="cx">         return decodeColorInternal(decoder);
</span><del>-#endif
</del><span class="cx">     case NSType::Dictionary:
</span><span class="cx">         return decodeDictionaryInternal(decoder, allowedClasses);
</span><span class="cx">     case NSType::Font:
</span><span class="lines">@@ -470,9 +480,7 @@
</span><span class="cx">     using values = EnumValues<
</span><span class="cx">         IPC::NSType,
</span><span class="cx">         IPC::NSType::Array,
</span><del>-#if USE(APPKIT)
</del><span class="cx">         IPC::NSType::Color,
</span><del>-#endif
</del><span class="cx">         IPC::NSType::Data,
</span><span class="cx">         IPC::NSType::Date,
</span><span class="cx">         IPC::NSType::Dictionary,
</span></span></pre></div>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (243115 => 243116)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog    2019-03-18 23:51:42 UTC (rev 243115)
+++ trunk/Tools/ChangeLog       2019-03-18 23:54:38 UTC (rev 243116)
</span><span class="lines">@@ -1,3 +1,13 @@
</span><ins>+2019-03-18  Timothy Hatcher  <timothy@apple.com>
+
+        WKWebView.GetContentsShouldReturnAttributedString is crashing on iOS Simulator.
+        https://bugs.webkit.org/show_bug.cgi?id=195916
+
+        Reviewed by Tim Horton.
+
+        * TestWebKitAPI/Tests/WebKitCocoa/WKWebViewGetContents.mm:
+        (TEST(WKWebView, GetContentsShouldReturnAttributedString): Fix iOS code path to pass.
+
</ins><span class="cx"> 2019-03-18  Alexey Proskuryakov  <ap@apple.com>
</span><span class="cx"> 
</span><span class="cx">         Add a secondary e-mail address for Fujii Hironori to make tools happier.
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebKitCocoaWKWebViewGetContentsmm"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebViewGetContents.mm (243115 => 243116)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebViewGetContents.mm      2019-03-18 23:51:42 UTC (rev 243115)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebViewGetContents.mm 2019-03-18 23:54:38 UTC (rev 243116)
</span><span class="lines">@@ -57,14 +57,6 @@
</span><span class="cx"> 
</span><span class="cx">     __block bool finished = false;
</span><span class="cx"> 
</span><del>-#if USE(APPKIT)
-    using PlatformFont = NSFont;
-    using PlatformColor = NSColor;
-#else
-    using PlatformFont = UIFont;
-    using PlatformColor = UIColor;
-#endif
-
</del><span class="cx">     [webView _getContentsAsAttributedStringWithCompletionHandler:^(NSAttributedString *attributedString, NSDictionary<NSAttributedStringDocumentAttributeKey, id> *documentAttributes, NSError *error) {
</span><span class="cx">         EXPECT_NOT_NULL(attributedString);
</span><span class="cx">         EXPECT_NOT_NULL(documentAttributes);
</span><span class="lines">@@ -76,10 +68,18 @@
</span><span class="cx"> 
</span><span class="cx">             if (!i) {
</span><span class="cx">                 EXPECT_WK_STREQ(@"Hello ", substring.string);
</span><del>-                EXPECT_WK_STREQ(@"Times-Roman", dynamic_objc_cast<PlatformFont>(attributes[NSFontAttributeName]).fontName);
</del><ins>+#if USE(APPKIT)
+                EXPECT_WK_STREQ(@"Times-Roman", dynamic_objc_cast<NSFont>(attributes[NSFontAttributeName]).fontName);
+#else
+                EXPECT_WK_STREQ(@"TimesNewRomanPSMT", dynamic_objc_cast<UIFont>(attributes[NSFontAttributeName]).fontName);
+#endif
</ins><span class="cx">             } else if (i == 1) {
</span><span class="cx">                 EXPECT_WK_STREQ(@"World!", substring.string);
</span><del>-                EXPECT_WK_STREQ(@"Times-Bold", dynamic_objc_cast<PlatformFont>(attributes[NSFontAttributeName]).fontName);
</del><ins>+#if USE(APPKIT)
+                EXPECT_WK_STREQ(@"Times-Bold", dynamic_objc_cast<NSFont>(attributes[NSFontAttributeName]).fontName);
+#else
+                EXPECT_WK_STREQ(@"TimesNewRomanPS-BoldMT", dynamic_objc_cast<UIFont>(attributes[NSFontAttributeName]).fontName);
+#endif
</ins><span class="cx">             } else
</span><span class="cx">                 ASSERT_NOT_REACHED();
</span><span class="cx"> 
</span><span class="lines">@@ -86,7 +86,11 @@
</span><span class="cx">             ++i;
</span><span class="cx">         }];
</span><span class="cx"> 
</span><del>-        EXPECT_WK_STREQ(@"sRGB IEC61966-2.1 colorspace 1 0 0 1", dynamic_objc_cast<PlatformColor>(documentAttributes[NSBackgroundColorDocumentAttribute]).description);
</del><ins>+#if USE(APPKIT)
+        EXPECT_WK_STREQ(@"sRGB IEC61966-2.1 colorspace 1 0 0 1", dynamic_objc_cast<NSColor>(documentAttributes[NSBackgroundColorDocumentAttribute]).description);
+#else
+        EXPECT_WK_STREQ(@"kCGColorSpaceModelRGB 1 0 0 1 ", dynamic_objc_cast<UIColor>(documentAttributes[NSBackgroundColorDocumentAttribute]).description);
+#endif
</ins><span class="cx"> 
</span><span class="cx">         finished = true;
</span><span class="cx">     }];
</span></span></pre>
</div>
</div>

</body>
</html>