<!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>[215184] 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/215184">215184</a></dd>
<dt>Author</dt> <dd>wenson_hsieh@apple.com</dd>
<dt>Date</dt> <dd>2017-04-10 10:07:44 -0700 (Mon, 10 Apr 2017)</dd>
</dl>

<h3>Log Message</h3>
<pre>Data interaction on an image enclosed by an anchor should vend the anchor's URL
https://bugs.webkit.org/show_bug.cgi?id=170660
&lt;rdar://problem/31043220&gt;

Reviewed by Tim Horton.

Source/WebCore:

When writing an image embedded inside an anchor to the pasteboard, actually use the enclosing anchor's href if
it exists. Previously, we were simply dropping this argument on the floor.

Covered by 2 new DataInteractionTests: ImageInLinkToInput and ImageInLinkWithoutHREFToInput.

* editing/ios/EditorIOS.mm:
(WebCore::Editor::writeImageToPasteboard):

Tools:

Adds two new unit tests covering cases where data interaction is triggered from an image nested underneath an
anchor. In one of the tests, the link has an href, and in the other, its href is missing, in which case we
should fall back to the image URL instead. Also fixes a related unit test that was trying to check selection
rects, but should not be.

See WebCore ChangeLog for more details.

* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WebKit2Cocoa/image-in-link-and-input.html: Added.
* TestWebKitAPI/Tests/ios/DataInteractionTests.mm:
(TestWebKitAPI::TEST):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreeditingiosEditorIOSmm">trunk/Source/WebCore/editing/ios/EditorIOS.mm</a></li>
<li><a href="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsTestWebKitAPITestWebKitAPIxcodeprojprojectpbxproj">trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsiosDataInteractionTestsmm">trunk/Tools/TestWebKitAPI/Tests/ios/DataInteractionTests.mm</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkToolsTestWebKitAPITestsWebKit2Cocoaimageinlinkandinputhtml">trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/image-in-link-and-input.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (215183 => 215184)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2017-04-10 16:44:01 UTC (rev 215183)
+++ trunk/Source/WebCore/ChangeLog        2017-04-10 17:07:44 UTC (rev 215184)
</span><span class="lines">@@ -1,3 +1,19 @@
</span><ins>+2017-04-10  Wenson Hsieh  &lt;wenson_hsieh@apple.com&gt;
+
+        Data interaction on an image enclosed by an anchor should vend the anchor's URL
+        https://bugs.webkit.org/show_bug.cgi?id=170660
+        &lt;rdar://problem/31043220&gt;
+
+        Reviewed by Tim Horton.
+
+        When writing an image embedded inside an anchor to the pasteboard, actually use the enclosing anchor's href if
+        it exists. Previously, we were simply dropping this argument on the floor.
+
+        Covered by 2 new DataInteractionTests: ImageInLinkToInput and ImageInLinkWithoutHREFToInput.
+
+        * editing/ios/EditorIOS.mm:
+        (WebCore::Editor::writeImageToPasteboard):
+
</ins><span class="cx"> 2017-04-10  Jon Lee  &lt;jonlee@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Update localizable strings to &quot;full screen&quot; from &quot;fullscreen&quot;
</span></span></pre></div>
<a id="trunkSourceWebCoreeditingiosEditorIOSmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/editing/ios/EditorIOS.mm (215183 => 215184)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/editing/ios/EditorIOS.mm        2017-04-10 16:44:01 UTC (rev 215183)
+++ trunk/Source/WebCore/editing/ios/EditorIOS.mm        2017-04-10 17:07:44 UTC (rev 215184)
</span><span class="lines">@@ -197,7 +197,7 @@
</span><span class="cx">     cachedImage = tentativeCachedImage;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void Editor::writeImageToPasteboard(Pasteboard&amp; pasteboard, Element&amp; imageElement, const URL&amp;, const String&amp; title)
</del><ins>+void Editor::writeImageToPasteboard(Pasteboard&amp; pasteboard, Element&amp; imageElement, const URL&amp; url, const String&amp; title)
</ins><span class="cx"> {
</span><span class="cx">     PasteboardImage pasteboardImage;
</span><span class="cx"> 
</span><span class="lines">@@ -207,7 +207,7 @@
</span><span class="cx">         return;
</span><span class="cx">     ASSERT(cachedImage);
</span><span class="cx"> 
</span><del>-    pasteboardImage.url.url = imageElement.document().completeURL(stripLeadingAndTrailingHTMLSpaces(imageElement.imageSourceURL()));
</del><ins>+    pasteboardImage.url.url = url.isEmpty() ? imageElement.document().completeURL(stripLeadingAndTrailingHTMLSpaces(imageElement.imageSourceURL())) : url;
</ins><span class="cx">     pasteboardImage.url.title = title;
</span><span class="cx">     pasteboardImage.resourceMIMEType = pasteboard.resourceMIMEType(cachedImage-&gt;response().mimeType());
</span><span class="cx">     pasteboardImage.resourceData = cachedImage-&gt;resourceBuffer();
</span></span></pre></div>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (215183 => 215184)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog        2017-04-10 16:44:01 UTC (rev 215183)
+++ trunk/Tools/ChangeLog        2017-04-10 17:07:44 UTC (rev 215184)
</span><span class="lines">@@ -1,3 +1,23 @@
</span><ins>+2017-04-10  Wenson Hsieh  &lt;wenson_hsieh@apple.com&gt;
+
+        Data interaction on an image enclosed by an anchor should vend the anchor's URL
+        https://bugs.webkit.org/show_bug.cgi?id=170660
+        &lt;rdar://problem/31043220&gt;
+
+        Reviewed by Tim Horton.
+
+        Adds two new unit tests covering cases where data interaction is triggered from an image nested underneath an
+        anchor. In one of the tests, the link has an href, and in the other, its href is missing, in which case we
+        should fall back to the image URL instead. Also fixes a related unit test that was trying to check selection
+        rects, but should not be.
+
+        See WebCore ChangeLog for more details.
+
+        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+        * TestWebKitAPI/Tests/WebKit2Cocoa/image-in-link-and-input.html: Added.
+        * TestWebKitAPI/Tests/ios/DataInteractionTests.mm:
+        (TestWebKitAPI::TEST):
+
</ins><span class="cx"> 2017-04-10  Carlos Garcia Campos  &lt;cgarcia@igalia.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [GTK] Remove the GDK dependency from ImageDiff
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestWebKitAPIxcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (215183 => 215184)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj        2017-04-10 16:44:01 UTC (rev 215183)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj        2017-04-10 17:07:44 UTC (rev 215184)
</span><span class="lines">@@ -585,6 +585,7 @@
</span><span class="cx">                 F4C2AB221DD6D95E00E06D5B /* enormous-video-with-sound.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F4C2AB211DD6D94100E06D5B /* enormous-video-with-sound.html */; };
</span><span class="cx">                 F4D4F3B61E4E2BCB00BB2767 /* DataInteractionSimulator.mm in Sources */ = {isa = PBXBuildFile; fileRef = F4D4F3B41E4E2BCB00BB2767 /* DataInteractionSimulator.mm */; };
</span><span class="cx">                 F4D4F3B91E4E36E400BB2767 /* DataInteractionTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = F4D4F3B71E4E36E400BB2767 /* DataInteractionTests.mm */; };
</span><ins>+                F4DEF6ED1E9B4DB60048EF61 /* image-in-link-and-input.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F4DEF6EC1E9B4D950048EF61 /* image-in-link-and-input.html */; };
</ins><span class="cx">                 F4F137921D9B683E002BEC57 /* large-video-test-now-playing.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F4F137911D9B6832002BEC57 /* large-video-test-now-playing.html */; };
</span><span class="cx">                 F4F405BC1D4C0D1C007A9707 /* full-size-autoplaying-video-with-audio.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F4F405BA1D4C0CF8007A9707 /* full-size-autoplaying-video-with-audio.html */; };
</span><span class="cx">                 F4F405BD1D4C0D1C007A9707 /* skinny-autoplaying-video-with-audio.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F4F405BB1D4C0CF8007A9707 /* skinny-autoplaying-video-with-audio.html */; };
</span><span class="lines">@@ -659,6 +660,7 @@
</span><span class="cx">                         dstPath = TestWebKitAPI.resources;
</span><span class="cx">                         dstSubfolderSpec = 7;
</span><span class="cx">                         files = (
</span><ins>+                                F4DEF6ED1E9B4DB60048EF61 /* image-in-link-and-input.html in Copy Resources */,
</ins><span class="cx">                                 1A9E52C913E65EF4006917F5 /* 18-characters.html in Copy Resources */,
</span><span class="cx">                                 379028B914FAC24C007E6B43 /* acceptsFirstMouse.html in Copy Resources */,
</span><span class="cx">                                 1C2B81871C8925A000A5529F /* Ahem.ttf in Copy Resources */,
</span><span class="lines">@@ -1448,6 +1450,7 @@
</span><span class="cx">                 F4D4F3B41E4E2BCB00BB2767 /* DataInteractionSimulator.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DataInteractionSimulator.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 F4D4F3B51E4E2BCB00BB2767 /* DataInteractionSimulator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DataInteractionSimulator.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 F4D4F3B71E4E36E400BB2767 /* DataInteractionTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DataInteractionTests.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><ins>+                F4DEF6EC1E9B4D950048EF61 /* image-in-link-and-input.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = &quot;image-in-link-and-input.html&quot;; sourceTree = &quot;&lt;group&gt;&quot;; };
</ins><span class="cx">                 F4F137911D9B6832002BEC57 /* large-video-test-now-playing.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = &quot;large-video-test-now-playing.html&quot;; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 F4F405BA1D4C0CF8007A9707 /* full-size-autoplaying-video-with-audio.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = &quot;full-size-autoplaying-video-with-audio.html&quot;; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 F4F405BB1D4C0CF8007A9707 /* skinny-autoplaying-video-with-audio.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = &quot;skinny-autoplaying-video-with-audio.html&quot;; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -1830,6 +1833,7 @@
</span><span class="cx">                                 CD78E11B1DB7EA360014A2DE /* FullscreenDelegate.html */,
</span><span class="cx">                                 3FBD1B491D39D1DB00E6D6FA /* FullscreenLayoutConstraints.html */,
</span><span class="cx">                                 CDE195B21CFE0ADE0053D256 /* FullscreenTopContentInset.html */,
</span><ins>+                                F4DEF6EC1E9B4D950048EF61 /* image-in-link-and-input.html */,
</ins><span class="cx">                                 510477761D298E57009747EB /* IDBDeleteRecovery.html */,
</span><span class="cx">                                 5104776F1D298D85009747EB /* IDBDeleteRecovery.sqlite3 */,
</span><span class="cx">                                 510477701D298D85009747EB /* IDBDeleteRecovery.sqlite3-shm */,
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebKit2Cocoaimageinlinkandinputhtml"></a>
<div class="addfile"><h4>Added: trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/image-in-link-and-input.html (0 => 215184)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/image-in-link-and-input.html                                (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/image-in-link-and-input.html        2017-04-10 17:07:44 UTC (rev 215184)
</span><span class="lines">@@ -0,0 +1,30 @@
</span><ins>+&lt;head&gt;
+    &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1&quot;&gt;
+        &lt;style&gt;
+        body {
+            width: 100%;
+            height: 100%;
+            margin: 0;
+        }
+
+        img, a, #editor {
+            width: 100%;
+            height: 200px;
+            font-size: 200px;
+            white-space: nowrap;
+        }
+
+        a {
+            display: block;
+        }
+
+        #editor {
+            border: black 1px solid;
+        }
+        &lt;/style&gt;
+&lt;/head&gt;
+
+&lt;body&gt;
+    &lt;div&gt;&lt;a id=&quot;link&quot; href=&quot;https://www.apple.com&quot;&gt;&lt;img src=&quot;icon.png&quot;&gt;&lt;/img&gt;&lt;/a&gt;&lt;/div&gt;
+    &lt;div&gt;&lt;input id=&quot;editor&quot;&gt;&lt;/input&gt;&lt;/div&gt;
+&lt;/body&gt;
</ins></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsiosDataInteractionTestsmm"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/Tests/ios/DataInteractionTests.mm (215183 => 215184)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/ios/DataInteractionTests.mm        2017-04-10 16:44:01 UTC (rev 215183)
+++ trunk/Tools/TestWebKitAPI/Tests/ios/DataInteractionTests.mm        2017-04-10 17:07:44 UTC (rev 215184)
</span><span class="lines">@@ -106,11 +106,34 @@
</span><span class="cx">     EXPECT_TRUE([observedEventNames containsObject:DataInteractionOverEventName]);
</span><span class="cx">     EXPECT_TRUE([observedEventNames containsObject:DataInteractionPerformOperationEventName]);
</span><span class="cx"> 
</span><del>-    NSArray *expectedSelectionRects = [NSArray arrayWithObjects:makeCGRectValue(6, 203, 188, 14), makeCGRectValue(6, 217, 188, 14), makeCGRectValue(6, 231, 66, 14), nil];
-    checkSelectionRectsWithLogging(expectedSelectionRects, [dataInteractionSimulator finalSelectionRects]);
</del><span class="cx">     checkTypeIdentifierPrecedesOtherTypeIdentifier(dataInteractionSimulator.get(), (NSString *)kUTTypePNG, (NSString *)kUTTypeFileURL);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+TEST(DataInteractionTests, ImageInLinkToInput)
+{
+    RetainPtr&lt;TestWKWebView&gt; webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 500)]);
+    [webView synchronouslyLoadTestPageNamed:@&quot;image-in-link-and-input&quot;];
+
+    RetainPtr&lt;DataInteractionSimulator&gt; dataInteractionSimulator = adoptNS([[DataInteractionSimulator alloc] initWithWebView:webView.get()]);
+    [dataInteractionSimulator runFrom:CGPointMake(100, 50) to:CGPointMake(100, 300)];
+
+    EXPECT_WK_STREQ(&quot;https://www.apple.com/&quot;, [webView editorValue].UTF8String);
+    checkSelectionRectsWithLogging(@[ makeCGRectValue(101, 241, 2057, 232) ], [dataInteractionSimulator finalSelectionRects]);
+}
+
+TEST(DataInteractionTests, ImageInLinkWithoutHREFToInput)
+{
+    RetainPtr&lt;TestWKWebView&gt; webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 500)]);
+    [webView synchronouslyLoadTestPageNamed:@&quot;image-in-link-and-input&quot;];
+    [webView stringByEvaluatingJavaScript:@&quot;link.href = ''&quot;];
+
+    RetainPtr&lt;DataInteractionSimulator&gt; dataInteractionSimulator = adoptNS([[DataInteractionSimulator alloc] initWithWebView:webView.get()]);
+    [dataInteractionSimulator runFrom:CGPointMake(100, 50) to:CGPointMake(100, 300)];
+
+    NSURL *imageURL = [NSURL fileURLWithPath:[webView editorValue]];
+    EXPECT_WK_STREQ(&quot;icon.png&quot;, imageURL.lastPathComponent);
+}
+
</ins><span class="cx"> TEST(DataInteractionTests, ContentEditableToContentEditable)
</span><span class="cx"> {
</span><span class="cx">     RetainPtr&lt;TestWKWebView&gt; webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 500)]);
</span></span></pre>
</div>
</div>

</body>
</html>