<!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>[210779] 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/210779">210779</a></dd>
<dt>Author</dt> <dd>timothy_horton@apple.com</dd>
<dt>Date</dt> <dd>2017-01-15 11:39:39 -0800 (Sun, 15 Jan 2017)</dd>
</dl>

<h3>Log Message</h3>
<pre>De-duplicate more (nearly) identical code in Editor(Mac|IOS).mm
https://bugs.webkit.org/show_bug.cgi?id=167063

Reviewed by Dan Bernstein.

Source/WebCore:

No new tests, just refactoring.

* editing/Editor.h:
Adjust to fontAttributesForSelectionStart returning a RetainPtr.

* editing/cocoa/EditorCocoa.mm:
(WebCore::Editor::getTextDecorationAttributesRespectingTypingStyle):
Make use of more Obj-C literals (for NSNumber).

(WebCore::Editor::fontAttributesForSelectionStart):
Merge this from EditorMac and EditorIOS. There are a number of attributes
that are currently only extracted on Mac, and it's not clear why (and
probably should be shared).

(WebCore::Editor::stringSelectionForPasteboard):
(WebCore::Editor::stringSelectionForPasteboardWithImageAltText):
Merge these functions from EditorMac and EditorIOS. The iOS implementation
was missing a reasonable bug fix from <a href="http://trac.webkit.org/projects/webkit/changeset/161925">r161925</a>.

(WebCore::Editor::createFragmentAndAddResources):
Merge this from EditorMac and EditorIOS. The Mac implementation was missing
a reasonable bug fix from <a href="http://trac.webkit.org/projects/webkit/changeset/203482">r203482</a>.

* editing/ios/EditorIOS.mm:
(WebCore::Editor::fontAttributesForSelectionStart): Deleted.
(WebCore::Editor::stringSelectionForPasteboardWithImageAltText): Deleted.
(WebCore::Editor::createFragmentAndAddResources): Deleted.
* editing/mac/EditorMac.mm:
(WebCore::Editor::fontAttributesForSelectionStart): Deleted.
(WebCore::Editor::stringSelectionForPasteboard): Deleted.
(WebCore::Editor::stringSelectionForPasteboardWithImageAltText): Deleted.
(WebCore::Editor::createFragmentAndAddResources): Deleted.

Source/WebKit/mac:

* WebView/WebHTMLView.mm:
(-[WebHTMLView _selectionStartFontAttributesAsRTF]):
(-[WebHTMLView _updateFontPanel]):
* WebView/WebView.mm:
(-[WebView typingAttributes]):
Adjust to fontAttributesForSelectionStart returning a RetainPtr.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreeditingEditorh">trunk/Source/WebCore/editing/Editor.h</a></li>
<li><a href="#trunkSourceWebCoreeditingcocoaEditorCocoamm">trunk/Source/WebCore/editing/cocoa/EditorCocoa.mm</a></li>
<li><a href="#trunkSourceWebCoreeditingiosEditorIOSmm">trunk/Source/WebCore/editing/ios/EditorIOS.mm</a></li>
<li><a href="#trunkSourceWebCoreeditingmacEditorMacmm">trunk/Source/WebCore/editing/mac/EditorMac.mm</a></li>
<li><a href="#trunkSourceWebKitmacChangeLog">trunk/Source/WebKit/mac/ChangeLog</a></li>
<li><a href="#trunkSourceWebKitmacWebViewWebHTMLViewmm">trunk/Source/WebKit/mac/WebView/WebHTMLView.mm</a></li>
<li><a href="#trunkSourceWebKitmacWebViewWebViewmm">trunk/Source/WebKit/mac/WebView/WebView.mm</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (210778 => 210779)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2017-01-15 17:47:00 UTC (rev 210778)
+++ trunk/Source/WebCore/ChangeLog        2017-01-15 19:39:39 UTC (rev 210779)
</span><span class="lines">@@ -1,3 +1,43 @@
</span><ins>+2017-01-15  Tim Horton  &lt;timothy_horton@apple.com&gt;
+
+        De-duplicate more (nearly) identical code in Editor(Mac|IOS).mm
+        https://bugs.webkit.org/show_bug.cgi?id=167063
+
+        Reviewed by Dan Bernstein.
+
+        No new tests, just refactoring.
+
+        * editing/Editor.h:
+        Adjust to fontAttributesForSelectionStart returning a RetainPtr.
+
+        * editing/cocoa/EditorCocoa.mm:
+        (WebCore::Editor::getTextDecorationAttributesRespectingTypingStyle):
+        Make use of more Obj-C literals (for NSNumber).
+
+        (WebCore::Editor::fontAttributesForSelectionStart):
+        Merge this from EditorMac and EditorIOS. There are a number of attributes
+        that are currently only extracted on Mac, and it's not clear why (and
+        probably should be shared).
+
+        (WebCore::Editor::stringSelectionForPasteboard):
+        (WebCore::Editor::stringSelectionForPasteboardWithImageAltText):
+        Merge these functions from EditorMac and EditorIOS. The iOS implementation
+        was missing a reasonable bug fix from r161925.
+
+        (WebCore::Editor::createFragmentAndAddResources):
+        Merge this from EditorMac and EditorIOS. The Mac implementation was missing
+        a reasonable bug fix from r203482.
+
+        * editing/ios/EditorIOS.mm:
+        (WebCore::Editor::fontAttributesForSelectionStart): Deleted.
+        (WebCore::Editor::stringSelectionForPasteboardWithImageAltText): Deleted.
+        (WebCore::Editor::createFragmentAndAddResources): Deleted.
+        * editing/mac/EditorMac.mm:
+        (WebCore::Editor::fontAttributesForSelectionStart): Deleted.
+        (WebCore::Editor::stringSelectionForPasteboard): Deleted.
+        (WebCore::Editor::stringSelectionForPasteboardWithImageAltText): Deleted.
+        (WebCore::Editor::createFragmentAndAddResources): Deleted.
+
</ins><span class="cx"> 2017-01-15  Myles C. Maxfield  &lt;mmaxfield@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [Cocoa] Unify FontPlatformData's hashing and equality operators
</span></span></pre></div>
<a id="trunkSourceWebCoreeditingEditorh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/editing/Editor.h (210778 => 210779)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/editing/Editor.h        2017-01-15 17:47:00 UTC (rev 210778)
+++ trunk/Source/WebCore/editing/Editor.h        2017-01-15 19:39:39 UTC (rev 210779)
</span><span class="lines">@@ -448,7 +448,7 @@
</span><span class="cx"> 
</span><span class="cx"> #if PLATFORM(COCOA)
</span><span class="cx">     void getTextDecorationAttributesRespectingTypingStyle(const RenderStyle&amp;, NSMutableDictionary*) const;
</span><del>-    WEBCORE_EXPORT NSDictionary *fontAttributesForSelectionStart() const;
</del><ins>+    WEBCORE_EXPORT RetainPtr&lt;NSDictionary&gt; fontAttributesForSelectionStart() const;
</ins><span class="cx">     WEBCORE_EXPORT String stringSelectionForPasteboard();
</span><span class="cx">     String stringSelectionForPasteboardWithImageAltText();
</span><span class="cx"> #if !PLATFORM(IOS)
</span></span></pre></div>
<a id="trunkSourceWebCoreeditingcocoaEditorCocoamm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/editing/cocoa/EditorCocoa.mm (210778 => 210779)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/editing/cocoa/EditorCocoa.mm        2017-01-15 17:47:00 UTC (rev 210778)
+++ trunk/Source/WebCore/editing/cocoa/EditorCocoa.mm        2017-01-15 19:39:39 UTC (rev 210779)
</span><span class="lines">@@ -29,6 +29,8 @@
</span><span class="cx"> #import &quot;ArchiveResource.h&quot;
</span><span class="cx"> #import &quot;CSSValueList.h&quot;
</span><span class="cx"> #import &quot;CSSValuePool.h&quot;
</span><ins>+#import &quot;CachedResourceLoader.h&quot;
+#import &quot;ColorMac.h&quot;
</ins><span class="cx"> #import &quot;DocumentFragment.h&quot;
</span><span class="cx"> #import &quot;DocumentLoader.h&quot;
</span><span class="cx"> #import &quot;EditingStyle.h&quot;
</span><span class="lines">@@ -68,19 +70,78 @@
</span><span class="cx">         if (value &amp;&amp; value-&gt;isValueList()) {
</span><span class="cx">             CSSValueList&amp; valueList = downcast&lt;CSSValueList&gt;(*value);
</span><span class="cx">             if (valueList.hasValue(CSSValuePool::singleton().createIdentifierValue(CSSValueLineThrough).ptr()))
</span><del>-                [result setObject:[NSNumber numberWithInt:NSUnderlineStyleSingle] forKey:NSStrikethroughStyleAttributeName];
</del><ins>+                [result setObject:@(NSUnderlineStyleSingle) forKey:NSStrikethroughStyleAttributeName];
</ins><span class="cx">             if (valueList.hasValue(CSSValuePool::singleton().createIdentifierValue(CSSValueUnderline).ptr()))
</span><del>-                [result setObject:[NSNumber numberWithInt:NSUnderlineStyleSingle] forKey:NSUnderlineStyleAttributeName];
</del><ins>+                [result setObject:@(NSUnderlineStyleSingle) forKey:NSUnderlineStyleAttributeName];
</ins><span class="cx">         }
</span><span class="cx">     } else {
</span><span class="cx">         int decoration = style.textDecorationsInEffect();
</span><span class="cx">         if (decoration &amp; TextDecorationLineThrough)
</span><del>-            [result setObject:[NSNumber numberWithInt:NSUnderlineStyleSingle] forKey:NSStrikethroughStyleAttributeName];
</del><ins>+            [result setObject:@(NSUnderlineStyleSingle) forKey:NSStrikethroughStyleAttributeName];
</ins><span class="cx">         if (decoration &amp; TextDecorationUnderline)
</span><del>-            [result setObject:[NSNumber numberWithInt:NSUnderlineStyleSingle] forKey:NSUnderlineStyleAttributeName];
</del><ins>+            [result setObject:@(NSUnderlineStyleSingle) forKey:NSUnderlineStyleAttributeName];
</ins><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+RetainPtr&lt;NSDictionary&gt; Editor::fontAttributesForSelectionStart() const
+{
+    Node* nodeToRemove;
+    auto* style = styleForSelectionStart(&amp;m_frame, nodeToRemove);
+    if (!style)
+        return nil;
+
+    RetainPtr&lt;NSMutableDictionary&gt; attributes = adoptNS([[NSMutableDictionary alloc] init]);
+
+    if (auto ctFont = style-&gt;fontCascade().primaryFont().getCTFont())
+        [attributes setObject:(id)ctFont forKey:NSFontAttributeName];
+
+    // FIXME: Why would we not want to retrieve these attributes on iOS?
+#if PLATFORM(MAC)
+    if (style-&gt;visitedDependentColor(CSSPropertyBackgroundColor).isVisible())
+        [attributes setObject:nsColor(style-&gt;visitedDependentColor(CSSPropertyBackgroundColor)) forKey:NSBackgroundColorAttributeName];
+
+    if (style-&gt;visitedDependentColor(CSSPropertyColor).isValid() &amp;&amp; !Color::isBlackColor(style-&gt;visitedDependentColor(CSSPropertyColor)))
+        [attributes setObject:nsColor(style-&gt;visitedDependentColor(CSSPropertyColor)) forKey:NSForegroundColorAttributeName];
+
+    const ShadowData* shadowData = style-&gt;textShadow();
+    if (shadowData) {
+        RetainPtr&lt;NSShadow&gt; platformShadow = adoptNS([[NSShadow alloc] init]);
+        [platformShadow setShadowOffset:NSMakeSize(shadowData-&gt;x(), shadowData-&gt;y())];
+        [platformShadow setShadowBlurRadius:shadowData-&gt;radius()];
+        [platformShadow setShadowColor:nsColor(shadowData-&gt;color())];
+        [attributes setObject:platformShadow.get() forKey:NSShadowAttributeName];
+    }
+
+    int superscriptInt = 0;
+    switch (style-&gt;verticalAlign()) {
+    case BASELINE:
+    case BOTTOM:
+    case BASELINE_MIDDLE:
+    case LENGTH:
+    case MIDDLE:
+    case TEXT_BOTTOM:
+    case TEXT_TOP:
+    case TOP:
+        break;
+    case SUB:
+        superscriptInt = -1;
+        break;
+    case SUPER:
+        superscriptInt = 1;
+        break;
+    }
+    if (superscriptInt)
+        [attributes setObject:@(superscriptInt) forKey:NSSuperscriptAttributeName];
+#endif
+
+    getTextDecorationAttributesRespectingTypingStyle(*style, attributes.get());
+
+    if (nodeToRemove)
+        nodeToRemove-&gt;remove();
+
+    return attributes;
+}
+
</ins><span class="cx"> FragmentAndResources Editor::createFragment(NSAttributedString *string)
</span><span class="cx"> {
</span><span class="cx">     // FIXME: The algorithm to convert an attributed string into HTML should be implemented here in WebCore.
</span><span class="lines">@@ -117,6 +178,26 @@
</span><span class="cx">     return SharedBuffer::wrapCFData(archive-&gt;rawDataRepresentation().get());
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+// FIXME: Makes no sense that selectedTextForDataTransfer always includes alt text, but stringSelectionForPasteboard does not.
+// This was left in a bad state when selectedTextForDataTransfer was added. Need to look over clients and fix this.
+String Editor::stringSelectionForPasteboard()
+{
+    if (!canCopy())
+        return emptyString();
+    String text = selectedText();
+    text.replace(noBreakSpace, ' ');
+    return text;
+}
+
+String Editor::stringSelectionForPasteboardWithImageAltText()
+{
+    if (!canCopy())
+        return emptyString();
+    String text = selectedTextForDataTransfer();
+    text.replace(noBreakSpace, ' ');
+    return text;
+}
+
</ins><span class="cx"> void Editor::replaceSelectionWithAttributedString(NSAttributedString *attributedString, MailBlockquoteHandling mailBlockquoteHandling)
</span><span class="cx"> {
</span><span class="cx">     if (m_frame.selection().isNone())
</span><span class="lines">@@ -184,5 +265,39 @@
</span><span class="cx">     return nullptr;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+RefPtr&lt;DocumentFragment&gt; Editor::createFragmentAndAddResources(NSAttributedString *string)
+{
+    if (!m_frame.page() || !m_frame.document())
+        return nullptr;
</ins><span class="cx"> 
</span><ins>+    auto&amp; document = *m_frame.document();
+    if (!document.isHTMLDocument() || !string)
+        return nullptr;
+
+    bool wasDeferringCallbacks = m_frame.page()-&gt;defersLoading();
+    if (!wasDeferringCallbacks)
+        m_frame.page()-&gt;setDefersLoading(true);
+
+    auto&amp; cachedResourceLoader = document.cachedResourceLoader();
+    bool wasImagesEnabled = cachedResourceLoader.imagesEnabled();
+    if (wasImagesEnabled)
+        cachedResourceLoader.setImagesEnabled(false);
+
+    auto fragmentAndResources = createFragment(string);
+
+    if (DocumentLoader* loader = m_frame.loader().documentLoader()) {
+        for (auto&amp; resource : fragmentAndResources.resources) {
+            if (resource)
+                loader-&gt;addArchiveResource(resource.releaseNonNull());
+        }
+    }
+
+    if (wasImagesEnabled)
+        cachedResourceLoader.setImagesEnabled(true);
+    if (!wasDeferringCallbacks)
+        m_frame.page()-&gt;setDefersLoading(false);
+    
+    return WTFMove(fragmentAndResources.fragment);
</ins><span class="cx"> }
</span><ins>+
+}
</ins></span></pre></div>
<a id="trunkSourceWebCoreeditingiosEditorIOSmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/editing/ios/EditorIOS.mm (210778 => 210779)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/editing/ios/EditorIOS.mm        2017-01-15 17:47:00 UTC (rev 210778)
+++ trunk/Source/WebCore/editing/ios/EditorIOS.mm        2017-01-15 19:39:39 UTC (rev 210779)
</span><span class="lines">@@ -156,27 +156,6 @@
</span><span class="cx">     applyParagraphStyle(style.get());
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-NSDictionary* Editor::fontAttributesForSelectionStart() const
-{
-    Node* nodeToRemove;
-    auto* style = styleForSelectionStart(&amp;m_frame, nodeToRemove);
-    if (!style)
-        return nil;
-
-    NSMutableDictionary* result = [NSMutableDictionary dictionary];
-    
-    CTFontRef font = style-&gt;fontCascade().primaryFont().getCTFont();
-    if (font)
-        [result setObject:(id)font forKey:NSFontAttributeName];
-
-    getTextDecorationAttributesRespectingTypingStyle(*style, result);
-
-    if (nodeToRemove)
-        nodeToRemove-&gt;remove();
-    
-    return result;
-}
-
</del><span class="cx"> void Editor::removeUnchangeableStyles()
</span><span class="cx"> {
</span><span class="cx">     // This function removes styles that the user cannot modify by applying their default values.
</span><span class="lines">@@ -201,13 +180,6 @@
</span><span class="cx">     applyStyleToSelection(defaultStyle.get(), EditActionChangeAttributes);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-String Editor::stringSelectionForPasteboardWithImageAltText()
-{
-    String text = selectedTextForDataTransfer();
-    text.replace(noBreakSpace, ' ');
-    return text;
-}
-
</del><span class="cx"> static void getImage(Element&amp; imageElement, RefPtr&lt;Image&gt;&amp; image, CachedImage*&amp; cachedImage)
</span><span class="cx"> {
</span><span class="cx">     auto* renderer = imageElement.renderer();
</span><span class="lines">@@ -434,41 +406,6 @@
</span><span class="cx">         pasteAsFragment(fragment.releaseNonNull(), canSmartReplaceWithPasteboard(*pasteboard), false, mailBlockquoteHandling);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-RefPtr&lt;DocumentFragment&gt; Editor::createFragmentAndAddResources(NSAttributedString *string)
-{
-    if (!m_frame.page() || !m_frame.document())
-        return nullptr;
-
-    auto&amp; document = *m_frame.document();
-    if (!document.isHTMLDocument() || !string)
-        return nullptr;
-
-    bool wasDeferringCallbacks = m_frame.page()-&gt;defersLoading();
-    if (!wasDeferringCallbacks)
-        m_frame.page()-&gt;setDefersLoading(true);
-
-    auto&amp; cachedResourceLoader = document.cachedResourceLoader();
-    bool wasImagesEnabled = cachedResourceLoader.imagesEnabled();
-    if (wasImagesEnabled)
-        cachedResourceLoader.setImagesEnabled(false);
-
-    auto fragmentAndResources = createFragment(string);
-
-    if (DocumentLoader* loader = m_frame.loader().documentLoader()) {
-        for (auto&amp; resource : fragmentAndResources.resources) {
-            if (resource)
-                loader-&gt;addArchiveResource(resource.releaseNonNull());
-        }
-    }
-
-    if (wasImagesEnabled)
-        cachedResourceLoader.setImagesEnabled(true);
-    if (!wasDeferringCallbacks)
-        m_frame.page()-&gt;setDefersLoading(false);
-    
-    return WTFMove(fragmentAndResources.fragment);
-}
-
</del><span class="cx"> void Editor::insertDictationPhrases(Vector&lt;Vector&lt;String&gt;&gt;&amp;&amp; dictationPhrases, RetainPtr&lt;id&gt; metadata)
</span><span class="cx"> {
</span><span class="cx">     if (m_frame.selection().isNone())
</span></span></pre></div>
<a id="trunkSourceWebCoreeditingmacEditorMacmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/editing/mac/EditorMac.mm (210778 => 210779)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/editing/mac/EditorMac.mm        2017-01-15 17:47:00 UTC (rev 210778)
+++ trunk/Source/WebCore/editing/mac/EditorMac.mm        2017-01-15 19:39:39 UTC (rev 210779)
</span><span class="lines">@@ -29,8 +29,6 @@
</span><span class="cx"> #import &quot;Blob.h&quot;
</span><span class="cx"> #import &quot;CSSPrimitiveValueMappings.h&quot;
</span><span class="cx"> #import &quot;CSSValuePool.h&quot;
</span><del>-#import &quot;CachedResourceLoader.h&quot;
-#import &quot;ColorMac.h&quot;
</del><span class="cx"> #import &quot;DOMURL.h&quot;
</span><span class="cx"> #import &quot;DataTransfer.h&quot;
</span><span class="cx"> #import &quot;DocumentFragment.h&quot;
</span><span class="lines">@@ -104,62 +102,6 @@
</span><span class="cx">     client()-&gt;setInsertionPasteboard(String());
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-NSDictionary* Editor::fontAttributesForSelectionStart() const
-{
-    Node* nodeToRemove;
-    auto* style = styleForSelectionStart(&amp;m_frame, nodeToRemove);
-    if (!style)
-        return nil;
-
-    NSMutableDictionary* result = [NSMutableDictionary dictionary];
-
-    if (style-&gt;visitedDependentColor(CSSPropertyBackgroundColor).isVisible())
-        [result setObject:nsColor(style-&gt;visitedDependentColor(CSSPropertyBackgroundColor)) forKey:NSBackgroundColorAttributeName];
-
-    if (auto ctFont = style-&gt;fontCascade().primaryFont().getCTFont())
-        [result setObject:toNSFont(ctFont) forKey:NSFontAttributeName];
-
-    if (style-&gt;visitedDependentColor(CSSPropertyColor).isValid() &amp;&amp; !Color::isBlackColor(style-&gt;visitedDependentColor(CSSPropertyColor)))
-        [result setObject:nsColor(style-&gt;visitedDependentColor(CSSPropertyColor)) forKey:NSForegroundColorAttributeName];
-
-    const ShadowData* shadow = style-&gt;textShadow();
-    if (shadow) {
-        RetainPtr&lt;NSShadow&gt; s = adoptNS([[NSShadow alloc] init]);
-        [s.get() setShadowOffset:NSMakeSize(shadow-&gt;x(), shadow-&gt;y())];
-        [s.get() setShadowBlurRadius:shadow-&gt;radius()];
-        [s.get() setShadowColor:nsColor(shadow-&gt;color())];
-        [result setObject:s.get() forKey:NSShadowAttributeName];
-    }
-
-    int superscriptInt = 0;
-    switch (style-&gt;verticalAlign()) {
-        case BASELINE:
-        case BOTTOM:
-        case BASELINE_MIDDLE:
-        case LENGTH:
-        case MIDDLE:
-        case TEXT_BOTTOM:
-        case TEXT_TOP:
-        case TOP:
-            break;
-        case SUB:
-            superscriptInt = -1;
-            break;
-        case SUPER:
-            superscriptInt = 1;
-            break;
-    }
-    if (superscriptInt)
-        [result setObject:[NSNumber numberWithInt:superscriptInt] forKey:NSSuperscriptAttributeName];
-
-    getTextDecorationAttributesRespectingTypingStyle(*style, result);
-
-    if (nodeToRemove)
-        nodeToRemove-&gt;remove();
-
-    return result;
-}
-
</del><span class="cx"> bool Editor::canCopyExcludingStandaloneImages()
</span><span class="cx"> {
</span><span class="cx">     const VisibleSelection&amp; selection = m_frame.selection().selection();
</span><span class="lines">@@ -243,26 +185,6 @@
</span><span class="cx">     client()-&gt;setInsertionPasteboard(String());
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-// FIXME: Makes no sense that selectedTextForDataTransfer always includes alt text, but stringSelectionForPasteboard does not.
-// This was left in a bad state when selectedTextForDataTransfer was added. Need to look over clients and fix this.
-String Editor::stringSelectionForPasteboard()
-{
-    if (!canCopy())
-        return emptyString();
-    String text = selectedText();
-    text.replace(noBreakSpace, ' ');
-    return text;
-}
-
-String Editor::stringSelectionForPasteboardWithImageAltText()
-{
-    if (!canCopy())
-        return emptyString();
-    String text = selectedTextForDataTransfer();
-    text.replace(noBreakSpace, ' ');
-    return text;
-}
-
</del><span class="cx"> String Editor::selectionInHTMLFormat()
</span><span class="cx"> {
</span><span class="cx">     return createMarkup(*selectedRange(), nullptr, AnnotateForInterchange, false, ResolveNonLocalURLs);
</span><span class="lines">@@ -566,33 +488,6 @@
</span><span class="cx">     return fragment;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-RefPtr&lt;DocumentFragment&gt; Editor::createFragmentAndAddResources(NSAttributedString *string)
-{
-    if (!m_frame.page() || !document().isHTMLDocument())
-        return nullptr;
-
-    if (!string)
-        return nullptr;
-
-    bool wasDeferringCallbacks = m_frame.page()-&gt;defersLoading();
-    if (!wasDeferringCallbacks)
-        m_frame.page()-&gt;setDefersLoading(true);
-
-    auto fragmentAndResources = createFragment(string);
-
-    if (DocumentLoader* loader = m_frame.loader().documentLoader()) {
-        for (auto&amp; resource : fragmentAndResources.resources) {
-            if (resource)
-                loader-&gt;addArchiveResource(resource.releaseNonNull());
-        }
-    }
-
-    if (!wasDeferringCallbacks)
-        m_frame.page()-&gt;setDefersLoading(false);
-
-    return WTFMove(fragmentAndResources.fragment);
-}
-
</del><span class="cx"> void Editor::applyFontStyles(const String&amp; fontFamily, double fontSize, unsigned fontTraits)
</span><span class="cx"> {
</span><span class="cx">     auto&amp; cssValuePool = CSSValuePool::singleton();
</span></span></pre></div>
<a id="trunkSourceWebKitmacChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/mac/ChangeLog (210778 => 210779)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/mac/ChangeLog        2017-01-15 17:47:00 UTC (rev 210778)
+++ trunk/Source/WebKit/mac/ChangeLog        2017-01-15 19:39:39 UTC (rev 210779)
</span><span class="lines">@@ -1,3 +1,17 @@
</span><ins>+2017-01-15  Tim Horton  &lt;timothy_horton@apple.com&gt;
+
+        De-duplicate more (nearly) identical code in Editor(Mac|IOS).mm
+        https://bugs.webkit.org/show_bug.cgi?id=167063
+
+        Reviewed by Dan Bernstein.
+
+        * WebView/WebHTMLView.mm:
+        (-[WebHTMLView _selectionStartFontAttributesAsRTF]):
+        (-[WebHTMLView _updateFontPanel]):
+        * WebView/WebView.mm:
+        (-[WebView typingAttributes]):
+        Adjust to fontAttributesForSelectionStart returning a RetainPtr.
+
</ins><span class="cx"> 2017-01-13  Joseph Pecoraro  &lt;pecoraro@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Remove ENABLE(DETAILS_ELEMENT) guards
</span></span></pre></div>
<a id="trunkSourceWebKitmacWebViewWebHTMLViewmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/mac/WebView/WebHTMLView.mm (210778 => 210779)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/mac/WebView/WebHTMLView.mm        2017-01-15 17:47:00 UTC (rev 210778)
+++ trunk/Source/WebKit/mac/WebView/WebHTMLView.mm        2017-01-15 19:39:39 UTC (rev 210779)
</span><span class="lines">@@ -5335,7 +5335,7 @@
</span><span class="cx"> {
</span><span class="cx">     Frame* coreFrame = core([self _frame]);
</span><span class="cx">     NSAttributedString *string = [[NSAttributedString alloc] initWithString:@&quot;x&quot;
</span><del>-        attributes:coreFrame ? coreFrame-&gt;editor().fontAttributesForSelectionStart() : nil];
</del><ins>+        attributes:coreFrame ? coreFrame-&gt;editor().fontAttributesForSelectionStart().get() : nil];
</ins><span class="cx">     NSData *data = [string RTFFromRange:NSMakeRange(0, [string length]) documentAttributes:@{ }];
</span><span class="cx">     [string release];
</span><span class="cx">     return data;
</span><span class="lines">@@ -6150,7 +6150,7 @@
</span><span class="cx"> 
</span><span class="cx">     bool multipleFonts = false;
</span><span class="cx">     NSFont *font = nil;
</span><del>-    NSDictionary *attributes = nil;
</del><ins>+    RetainPtr&lt;NSDictionary&gt; attributes;
</ins><span class="cx">     if (Frame* coreFrame = core([self _frame])) {
</span><span class="cx">         if (const Font* fd = coreFrame-&gt;editor().fontForSelection(multipleFonts))
</span><span class="cx">             font = (NSFont *)fd-&gt;platformData().registeredFont();
</span><span class="lines">@@ -6165,7 +6165,7 @@
</span><span class="cx"> 
</span><span class="cx">     NSFontManager *fontManager = [NSFontManager sharedFontManager];
</span><span class="cx">     [fontManager setSelectedFont:font isMultiple:multipleFonts];
</span><del>-    [fontManager setSelectedAttributes:(attributes ? attributes : @{ }) isMultiple:multipleFonts];
</del><ins>+    [fontManager setSelectedAttributes:(attributes ? attributes.get() : @{ }) isMultiple:multipleFonts];
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (void)_setSoftSpaceRange:(NSRange)range
</span></span></pre></div>
<a id="trunkSourceWebKitmacWebViewWebViewmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/mac/WebView/WebView.mm (210778 => 210779)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/mac/WebView/WebView.mm        2017-01-15 17:47:00 UTC (rev 210778)
+++ trunk/Source/WebKit/mac/WebView/WebView.mm        2017-01-15 19:39:39 UTC (rev 210779)
</span><span class="lines">@@ -8282,12 +8282,11 @@
</span><span class="cx"> {
</span><span class="cx">     Frame* coreFrame = core([self _selectedOrMainFrame]);
</span><span class="cx">     if (coreFrame)
</span><del>-        return coreFrame-&gt;editor().fontAttributesForSelectionStart();
</del><ins>+        return coreFrame-&gt;editor().fontAttributesForSelectionStart().autorelease();
</ins><span class="cx">     
</span><span class="cx">     return nil;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-
</del><span class="cx"> @end
</span><span class="cx"> 
</span><span class="cx"> @implementation WebView (WebViewEditingInMail)
</span></span></pre>
</div>
</div>

</body>
</html>