<!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>[211227] 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/211227">211227</a></dd>
<dt>Author</dt> <dd>wenson_hsieh@apple.com</dd>
<dt>Date</dt> <dd>2017-01-26 12:58:08 -0800 (Thu, 26 Jan 2017)</dd>
</dl>
<h3>Log Message</h3>
<pre>Add support for recognizing data interaction gestures in WebKit2
https://bugs.webkit.org/show_bug.cgi?id=167444
Reviewed by Beth Dakin.
Source/WebCore:
Minor tweaks to pasteboard code to support data interaction.
* WebCore.xcodeproj/project.pbxproj:
* platform/PlatformPasteboard.h:
* platform/ios/PasteboardIOS.mm:
(WebCore::Pasteboard::read):
* platform/ios/PlatformPasteboardIOS.mm:
(WebCore::PlatformPasteboard::PlatformPasteboard):
If the pasteboard is the special data interaction type, use the shared item provider pasteboard; otherwise,
fall back to the general pasteboard.
(WebCore::PlatformPasteboard::getTypes):
Actually populate the list of available types using available pasteboardTypes.
(WebCore::PlatformPasteboard::write):
Add UTF8 plaintext type (kUTTypeUTF8PlainText) when vending data representations of rich text.
* platform/ios/WebItemProviderPasteboard.mm:
(-[WebItemProviderPasteboard setItems:]):
(-[WebItemProviderPasteboard dataForPasteboardType:inItemSet:]):
(-[WebItemProviderPasteboard valuesForPasteboardType:inItemSet:]):
Move off of deprecated methods when retrieving and supplying data to the item provider pasteboard.
* platform/spi/ios/UIKitSPI.h:
Source/WebKit2:
Adds a new data interaction gesture recognizer, responsible for determining when to begin data interaction. This
is a new long press gesture recognizer that fires simultaneously with the existing long press gesture
recognizers (for performing long-press actions, and for showing the tap highlight).
Also tweaks logic for determining whether selection gesture recognizers should fire to account for data
interaction -- in particular, we don't want selection gesture recognizers to cause the current selection to
change while data interaction is possible. See -hasSelectablePositionAtPoint and -pointIsInAssistedNode for
more details.
* UIProcess/ios/PageClientImplIOS.mm:
(WebKit::PageClientImpl::didPerformDataInteractionControllerOperation):
(WebKit::PageClientImpl::startDataInteractionWithImage):
* UIProcess/ios/WKContentViewInteraction.h:
* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView _createAndConfigureLongPressGestureRecognizer]):
(-[WKContentView setupInteraction]):
(-[WKContentView cleanupInteraction]):
(-[WKContentView _removeDefaultGestureRecognizers]):
(-[WKContentView _addDefaultGestureRecognizers]):
(-[WKContentView resignFirstResponder]):
(-[WKContentView gestureRecognizer:shouldRecognizeSimultaneouslyWithGestureRecognizer:]):
(-[WKContentView gestureRecognizerShouldBegin:]):
(-[WKContentView hasSelectablePositionAtPoint:]):
(-[WKContentView pointIsInDataInteractionContent:]):
(-[WKContentView pointIsInAssistedNode:]):</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="#trunkSourceWebCoreplatformPlatformPasteboardh">trunk/Source/WebCore/platform/PlatformPasteboard.h</a></li>
<li><a href="#trunkSourceWebCoreplatformiosPasteboardIOSmm">trunk/Source/WebCore/platform/ios/PasteboardIOS.mm</a></li>
<li><a href="#trunkSourceWebCoreplatformiosPlatformPasteboardIOSmm">trunk/Source/WebCore/platform/ios/PlatformPasteboardIOS.mm</a></li>
<li><a href="#trunkSourceWebCoreplatformiosWebItemProviderPasteboardmm">trunk/Source/WebCore/platform/ios/WebItemProviderPasteboard.mm</a></li>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2UIProcessiosPageClientImplIOSmm">trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.mm</a></li>
<li><a href="#trunkSourceWebKit2UIProcessiosWKContentViewInteractionh">trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessiosWKContentViewInteractionmm">trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (211226 => 211227)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2017-01-26 20:41:13 UTC (rev 211226)
+++ trunk/Source/WebCore/ChangeLog        2017-01-26 20:58:08 UTC (rev 211227)
</span><span class="lines">@@ -1,3 +1,39 @@
</span><ins>+2017-01-26 Wenson Hsieh <wenson_hsieh@apple.com>
+
+ Add support for recognizing data interaction gestures in WebKit2
+ https://bugs.webkit.org/show_bug.cgi?id=167444
+
+ Reviewed by Beth Dakin.
+
+ Minor tweaks to pasteboard code to support data interaction.
+
+ * WebCore.xcodeproj/project.pbxproj:
+ * platform/PlatformPasteboard.h:
+ * platform/ios/PasteboardIOS.mm:
+ (WebCore::Pasteboard::read):
+ * platform/ios/PlatformPasteboardIOS.mm:
+ (WebCore::PlatformPasteboard::PlatformPasteboard):
+
+ If the pasteboard is the special data interaction type, use the shared item provider pasteboard; otherwise,
+ fall back to the general pasteboard.
+
+ (WebCore::PlatformPasteboard::getTypes):
+
+ Actually populate the list of available types using available pasteboardTypes.
+
+ (WebCore::PlatformPasteboard::write):
+
+ Add UTF8 plaintext type (kUTTypeUTF8PlainText) when vending data representations of rich text.
+
+ * platform/ios/WebItemProviderPasteboard.mm:
+ (-[WebItemProviderPasteboard setItems:]):
+ (-[WebItemProviderPasteboard dataForPasteboardType:inItemSet:]):
+ (-[WebItemProviderPasteboard valuesForPasteboardType:inItemSet:]):
+
+ Move off of deprecated methods when retrieving and supplying data to the item provider pasteboard.
+
+ * platform/spi/ios/UIKitSPI.h:
+
</ins><span class="cx"> 2017-01-26 Matt Rajca <mrajca@apple.com>
</span><span class="cx">
</span><span class="cx"> Notify clients when the user plays media otherwise prevented from autoplaying
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (211226 => 211227)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2017-01-26 20:41:13 UTC (rev 211226)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2017-01-26 20:58:08 UTC (rev 211227)
</span><span class="lines">@@ -6511,8 +6511,8 @@
</span><span class="cx">                 F47A5E3E195B8C8A00483100 /* StyleScrollSnapPoints.h in Headers */ = {isa = PBXBuildFile; fileRef = F47A5E3B195B8C8A00483100 /* StyleScrollSnapPoints.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 F47A5E3F195B8E4800483100 /* StyleScrollSnapPoints.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F47A5E3A195B8C8A00483100 /* StyleScrollSnapPoints.cpp */; };
</span><span class="cx">                 F48223101E3869B80066FC79 /* WebItemProviderPasteboard.mm in Sources */ = {isa = PBXBuildFile; fileRef = F482230E1E3869B80066FC79 /* WebItemProviderPasteboard.mm */; };
</span><del>-                F48223111E3869B80066FC79 /* WebItemProviderPasteboard.h in Headers */ = {isa = PBXBuildFile; fileRef = F482230F1E3869B80066FC79 /* WebItemProviderPasteboard.h */; };
-                F48223131E386E240066FC79 /* AbstractPasteboard.h in Headers */ = {isa = PBXBuildFile; fileRef = F48223121E386E240066FC79 /* AbstractPasteboard.h */; };
</del><ins>+                F48223111E3869B80066FC79 /* WebItemProviderPasteboard.h in Headers */ = {isa = PBXBuildFile; fileRef = F482230F1E3869B80066FC79 /* WebItemProviderPasteboard.h */; settings = {ATTRIBUTES = (Private, ); }; };
+                F48223131E386E240066FC79 /* AbstractPasteboard.h in Headers */ = {isa = PBXBuildFile; fileRef = F48223121E386E240066FC79 /* AbstractPasteboard.h */; settings = {ATTRIBUTES = (Private, ); }; };
</ins><span class="cx">                 F4BFB9851E1DDF9B00862C24 /* DumpEditingHistory.js in Copy Scripts */ = {isa = PBXBuildFile; fileRef = F48389831E1DDF2B0076B7EA /* DumpEditingHistory.js */; };
</span><span class="cx">                 F4BFB9861E1DDF9B00862C24 /* EditingHistoryUtil.js in Copy Scripts */ = {isa = PBXBuildFile; fileRef = F48389841E1DDF2B0076B7EA /* EditingHistoryUtil.js */; };
</span><span class="cx">                 F50664F7157F52DC00AC226F /* FormController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F50664F5157F52DC00AC226F /* FormController.cpp */; };
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformPlatformPasteboardh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/PlatformPasteboard.h (211226 => 211227)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/PlatformPasteboard.h        2017-01-26 20:41:13 UTC (rev 211226)
+++ trunk/Source/WebCore/platform/PlatformPasteboard.h        2017-01-26 20:58:08 UTC (rev 211227)
</span><span class="lines">@@ -92,7 +92,7 @@
</span><span class="cx"> RetainPtr<NSPasteboard> m_pasteboard;
</span><span class="cx"> #endif
</span><span class="cx"> #if PLATFORM(IOS)
</span><del>- RetainPtr<UIPasteboard> m_pasteboard;
</del><ins>+ RetainPtr<id> m_pasteboard;
</ins><span class="cx"> #endif
</span><span class="cx"> #if PLATFORM(GTK)
</span><span class="cx"> GtkClipboard* m_clipboard;
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformiosPasteboardIOSmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/ios/PasteboardIOS.mm (211226 => 211227)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/ios/PasteboardIOS.mm        2017-01-26 20:41:13 UTC (rev 211226)
+++ trunk/Source/WebCore/platform/ios/PasteboardIOS.mm        2017-01-26 20:58:08 UTC (rev 211227)
</span><span class="lines">@@ -150,9 +150,14 @@
</span><span class="cx"> void Pasteboard::read(PasteboardPlainText& text)
</span><span class="cx"> {
</span><span class="cx"> PasteboardStrategy& strategy = *platformStrategies()->pasteboardStrategy();
</span><ins>+ text.text = strategy.readStringFromPasteboard(0, kUTTypeURL, m_pasteboardName);
+ if (!text.text.isNull() && !text.text.isEmpty()) {
+ text.isURL = true;
+ return;
+ }
+
</ins><span class="cx"> text.text = strategy.readStringFromPasteboard(0, kUTTypeText, m_pasteboardName);
</span><del>- if (text.text.isEmpty())
- text.text = strategy.readStringFromPasteboard(0, kUTTypeURL, m_pasteboardName);
</del><ins>+ text.isURL = false;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static NSArray* supportedImageTypes()
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformiosPlatformPasteboardIOSmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/ios/PlatformPasteboardIOS.mm (211226 => 211227)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/ios/PlatformPasteboardIOS.mm        2017-01-26 20:41:13 UTC (rev 211226)
+++ trunk/Source/WebCore/platform/ios/PlatformPasteboardIOS.mm        2017-01-26 20:58:08 UTC (rev 211227)
</span><span class="lines">@@ -32,6 +32,7 @@
</span><span class="cx"> #import "Pasteboard.h"
</span><span class="cx"> #import "SharedBuffer.h"
</span><span class="cx"> #import "SoftLinking.h"
</span><ins>+#import "WebItemProviderPasteboard.h"
</ins><span class="cx"> #import <MobileCoreServices/MobileCoreServices.h>
</span><span class="cx">
</span><span class="cx"> SOFT_LINK_FRAMEWORK(UIKit)
</span><span class="lines">@@ -53,13 +54,25 @@
</span><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+#if ENABLE(DATA_INTERACTION)
+PlatformPasteboard::PlatformPasteboard(const String& name)
+{
+ if (name == "data interaction pasteboard")
+ m_pasteboard = [WebItemProviderPasteboard sharedInstance];
+ else
+ m_pasteboard = [getUIPasteboardClass() generalPasteboard];
+}
+#else
</ins><span class="cx"> PlatformPasteboard::PlatformPasteboard(const String&)
</span><span class="cx"> : m_pasteboard([getUIPasteboardClass() generalPasteboard])
</span><span class="cx"> {
</span><span class="cx"> }
</span><ins>+#endif
</ins><span class="cx">
</span><del>-void PlatformPasteboard::getTypes(Vector<String>&)
</del><ins>+void PlatformPasteboard::getTypes(Vector<String>& types)
</ins><span class="cx"> {
</span><ins>+ for (NSString *pasteboardType in [m_pasteboard pasteboardTypes])
+ types.append(pasteboardType);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> RefPtr<SharedBuffer> PlatformPasteboard::bufferForType(const String&)
</span><span class="lines">@@ -145,7 +158,9 @@
</span><span class="cx"> [representations setValue:content.dataInRTFDFormat->createNSData().get() forKey:(NSString *)kUTTypeFlatRTFD];
</span><span class="cx"> if (content.dataInRTFFormat)
</span><span class="cx"> [representations setValue:content.dataInRTFFormat->createNSData().get() forKey:(NSString *)kUTTypeRTF];
</span><ins>+
</ins><span class="cx"> [representations setValue:content.dataInStringFormat forKey:(NSString *)kUTTypeText];
</span><ins>+ [representations setValue:[(NSString *)content.dataInStringFormat dataUsingEncoding:NSUTF8StringEncoding] forKey:(NSString *)kUTTypeUTF8PlainText];
</ins><span class="cx"> [m_pasteboard setItems:@[representations.get()]];
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformiosWebItemProviderPasteboardmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/ios/WebItemProviderPasteboard.mm (211226 => 211227)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/ios/WebItemProviderPasteboard.mm        2017-01-26 20:41:13 UTC (rev 211226)
+++ trunk/Source/WebCore/platform/ios/WebItemProviderPasteboard.mm        2017-01-26 20:58:08 UTC (rev 211227)
</span><span class="lines">@@ -30,6 +30,7 @@
</span><span class="cx">
</span><span class="cx"> #import "SoftLinking.h"
</span><span class="cx"> #import "UIKitSPI.h"
</span><ins>+#import <Foundation/NSProgress.h>
</ins><span class="cx"> #import <MobileCoreServices/MobileCoreServices.h>
</span><span class="cx"> #import <UIKit/UIColor.h>
</span><span class="cx"> #import <UIKit/UIImage.h>
</span><span class="lines">@@ -131,8 +132,10 @@
</span><span class="cx"> continue;
</span><span class="cx"> UIItemProvider *itemProvider = [[getUIItemProviderClass() alloc] init];
</span><span class="cx"> for (NSString *typeIdentifier in item) {
</span><del>- [itemProvider registerDataRepresentationForTypeIdentifier:typeIdentifier loadHandler:^(UIItemProviderDataLoadCompletionBlock completionBlock, NSDictionary *) {
</del><ins>+ [itemProvider registerDataRepresentationForTypeIdentifier:typeIdentifier options:nil loadHandler:^NSProgress *(UIItemProviderDataLoadCompletionBlock completionBlock)
+ {
</ins><span class="cx"> completionBlock(item[typeIdentifier], nil);
</span><ins>+ return [NSProgress discreteProgressWithTotalUnitCount:100];
</ins><span class="cx"> }];
</span><span class="cx"> }
</span><span class="cx"> [providers addObject:itemProvider];
</span><span class="lines">@@ -149,7 +152,7 @@
</span><span class="cx"> if (!provider)
</span><span class="cx"> return;
</span><span class="cx">
</span><del>- NSData *data = [provider copyDataRepresentationForTypeIdentifier:pasteboardType options:nil error:nil];
</del><ins>+ NSData *data = [provider copyDataRepresentationForTypeIdentifier:pasteboardType error:nil];
</ins><span class="cx"> if (data)
</span><span class="cx"> [values addObject:data];
</span><span class="cx"> }];
</span><span class="lines">@@ -165,28 +168,29 @@
</span><span class="cx"> if (!provider)
</span><span class="cx"> return;
</span><span class="cx">
</span><del>- if (isRichTextType(pasteboardType) && [provider canInstantiateObjectOfClass:[NSAttributedString class]]) {
- [values addObject:[provider instantiateObjectOfClass:[NSAttributedString class] options:nil error:nil]];
</del><ins>+ // FIXME: These should be refactored to use asynchronous calls.
+ if (isColorType(pasteboardType) && [provider canCreateObjectOfClass:[getUIColorClass() class]]) {
+ [values addObject:[provider createObjectOfClass:[getUIColorClass() class] error:nil]];
</ins><span class="cx"> return;
</span><span class="cx"> }
</span><span class="cx">
</span><del>- if (isStringType(pasteboardType) && [provider canInstantiateObjectOfClass:[NSString class]]) {
- [values addObject:[provider instantiateObjectOfClass:[NSString class] options:nil error:nil]];
</del><ins>+ if (isImageType(pasteboardType) && [provider canCreateObjectOfClass:[getUIImageClass() class]]) {
+ [values addObject:[provider createObjectOfClass:[getUIImageClass() class] error:nil]];
</ins><span class="cx"> return;
</span><span class="cx"> }
</span><span class="cx">
</span><del>- if (isColorType(pasteboardType) && [provider canInstantiateObjectOfClass:[getUIColorClass() class]]) {
- [values addObject:[provider instantiateObjectOfClass:[getUIColorClass() class] options:nil error:nil]];
</del><ins>+ if (isURLType(pasteboardType) && [provider canCreateObjectOfClass:[NSURL class]]) {
+ [values addObject:[provider createObjectOfClass:[NSURL class] error:nil]];
</ins><span class="cx"> return;
</span><span class="cx"> }
</span><span class="cx">
</span><del>- if (isURLType(pasteboardType) && [provider canInstantiateObjectOfClass:[NSURL class]]) {
- [values addObject:[provider instantiateObjectOfClass:[NSURL class] options:nil error:nil]];
</del><ins>+ if (isRichTextType(pasteboardType) && [provider canCreateObjectOfClass:[NSAttributedString class]]) {
+ [values addObject:[provider createObjectOfClass:[NSAttributedString class] error:nil]];
</ins><span class="cx"> return;
</span><span class="cx"> }
</span><span class="cx">
</span><del>- if (isImageType(pasteboardType) && [provider canInstantiateObjectOfClass:[getUIImageClass() class]]) {
- [values addObject:[provider instantiateObjectOfClass:[getUIImageClass() class] options:nil error:nil]];
</del><ins>+ if (isStringType(pasteboardType) && [provider canCreateObjectOfClass:[NSString class]]) {
+ [values addObject:[provider createObjectOfClass:[NSString class] error:nil]];
</ins><span class="cx"> return;
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (211226 => 211227)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2017-01-26 20:41:13 UTC (rev 211226)
+++ trunk/Source/WebKit2/ChangeLog        2017-01-26 20:58:08 UTC (rev 211227)
</span><span class="lines">@@ -1,3 +1,36 @@
</span><ins>+2017-01-26 Wenson Hsieh <wenson_hsieh@apple.com>
+
+ Add support for recognizing data interaction gestures in WebKit2
+ https://bugs.webkit.org/show_bug.cgi?id=167444
+
+ Reviewed by Beth Dakin.
+
+ Adds a new data interaction gesture recognizer, responsible for determining when to begin data interaction. This
+ is a new long press gesture recognizer that fires simultaneously with the existing long press gesture
+ recognizers (for performing long-press actions, and for showing the tap highlight).
+
+ Also tweaks logic for determining whether selection gesture recognizers should fire to account for data
+ interaction -- in particular, we don't want selection gesture recognizers to cause the current selection to
+ change while data interaction is possible. See -hasSelectablePositionAtPoint and -pointIsInAssistedNode for
+ more details.
+
+ * UIProcess/ios/PageClientImplIOS.mm:
+ (WebKit::PageClientImpl::didPerformDataInteractionControllerOperation):
+ (WebKit::PageClientImpl::startDataInteractionWithImage):
+ * UIProcess/ios/WKContentViewInteraction.h:
+ * UIProcess/ios/WKContentViewInteraction.mm:
+ (-[WKContentView _createAndConfigureLongPressGestureRecognizer]):
+ (-[WKContentView setupInteraction]):
+ (-[WKContentView cleanupInteraction]):
+ (-[WKContentView _removeDefaultGestureRecognizers]):
+ (-[WKContentView _addDefaultGestureRecognizers]):
+ (-[WKContentView resignFirstResponder]):
+ (-[WKContentView gestureRecognizer:shouldRecognizeSimultaneouslyWithGestureRecognizer:]):
+ (-[WKContentView gestureRecognizerShouldBegin:]):
+ (-[WKContentView hasSelectablePositionAtPoint:]):
+ (-[WKContentView pointIsInDataInteractionContent:]):
+ (-[WKContentView pointIsInAssistedNode:]):
+
</ins><span class="cx"> 2017-01-26 Matt Rajca <mrajca@apple.com>
</span><span class="cx">
</span><span class="cx"> Notify clients when the user plays media otherwise prevented from autoplaying
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessiosPageClientImplIOSmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.mm (211226 => 211227)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.mm        2017-01-26 20:41:13 UTC (rev 211226)
+++ trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.mm        2017-01-26 20:58:08 UTC (rev 211227)
</span><span class="lines">@@ -765,10 +765,12 @@
</span><span class="cx"> #if ENABLE(DATA_INTERACTION)
</span><span class="cx"> void PageClientImpl::didPerformDataInteractionControllerOperation()
</span><span class="cx"> {
</span><ins>+ [m_contentView _didPerformDataInteractionControllerOperation];
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-void PageClientImpl::startDataInteractionWithImage(const WebCore::IntPoint& clientPosition, const ShareableBitmap::Handle& image, bool isLink)
</del><ins>+void PageClientImpl::startDataInteractionWithImage(const IntPoint& clientPosition, const ShareableBitmap::Handle& image, bool isLink)
</ins><span class="cx"> {
</span><ins>+ [m_contentView _startDataInteractionWithImage:ShareableBitmap::create(image)->makeCGImageCopy() atClientPosition:CGPointMake(clientPosition.x(), clientPosition.y()) isLink:isLink];
</ins><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessiosWKContentViewInteractionh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.h (211226 => 211227)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.h        2017-01-26 20:41:13 UTC (rev 211226)
+++ trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.h        2017-01-26 20:58:08 UTC (rev 211227)
</span><span class="lines">@@ -44,6 +44,10 @@
</span><span class="cx"> #import <wtf/Vector.h>
</span><span class="cx"> #import <wtf/text/WTFString.h>
</span><span class="cx">
</span><ins>+#if USE(APPLE_INTERNAL_SDK) && __has_include(<WebKitAdditions/WKContentViewInteractionAdditions.h>)
+#import <WebKitAdditions/WKContentViewInteractionAdditions.h>
+#endif
+
</ins><span class="cx"> namespace API {
</span><span class="cx"> class OpenPanelParameters;
</span><span class="cx"> }
</span><span class="lines">@@ -179,11 +183,22 @@
</span><span class="cx">
</span><span class="cx"> BOOL _resigningFirstResponder;
</span><span class="cx"> BOOL _needsDeferredEndScrollingSelectionUpdate;
</span><ins>+
+#if ENABLE(DATA_INTERACTION)
+ RetainPtr<UILongPressGestureRecognizer> _dataInteractionGestureRecognizer;
+ RetainPtr<UIImage> _currentDataInteractionImage;
+ CGPoint _currentDataInteractionOrigin;
+ BOOL _shouldHandleLongPressActionAfterDataInteraction;
+#endif
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> @end
</span><span class="cx">
</span><del>-@interface WKContentView (WKInteraction) <UIGestureRecognizerDelegate, UIWebTouchEventsGestureRecognizerDelegate, UITextInputPrivate, UIWebFormAccessoryDelegate, UIWKInteractionViewProtocol, WKFileUploadPanelDelegate, WKActionSheetAssistantDelegate>
</del><ins>+@interface WKContentView (WKInteraction) <UIGestureRecognizerDelegate, UIWebTouchEventsGestureRecognizerDelegate, UITextInputPrivate, UIWebFormAccessoryDelegate, UIWKInteractionViewProtocol, WKFileUploadPanelDelegate, WKActionSheetAssistantDelegate
+#if ENABLE(DATA_INTERACTION)
+ , WKViewDataInteractionSourceDelegate, WKDataInteractionSessionDelegate, WKViewDataInteractionDestinationDelegate, WKDataInteractionItemVisualTarget
+#endif
+>
</ins><span class="cx">
</span><span class="cx"> @property (nonatomic, readonly) CGPoint lastInteractionLocation;
</span><span class="cx"> @property (nonatomic, readonly) BOOL isEditable;
</span><span class="lines">@@ -232,6 +247,12 @@
</span><span class="cx"> - (NSArray *)_dataDetectionResults;
</span><span class="cx"> - (NSArray<NSValue *> *)_uiTextSelectionRects;
</span><span class="cx"> - (void)accessibilityRetrieveSpeakSelectionContent;
</span><ins>+
+#if ENABLE(DATA_INTERACTION)
+- (void)_didPerformDataInteractionControllerOperation;
+- (void)_startDataInteractionWithImage:(RetainPtr<CGImageRef>)image atClientPosition:(CGPoint)clientPosition isLink:(BOOL)isLink;
+#endif
+
</ins><span class="cx"> @end
</span><span class="cx">
</span><span class="cx"> @interface WKContentView (WKTesting)
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessiosWKContentViewInteractionmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm (211226 => 211227)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm        2017-01-26 20:41:13 UTC (rev 211226)
+++ trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm        2017-01-26 20:58:08 UTC (rev 211227)
</span><span class="lines">@@ -67,6 +67,7 @@
</span><span class="cx"> #import <WebCore/DataDetectorsCoreSPI.h>
</span><span class="cx"> #import <WebCore/DataDetectorsUISPI.h>
</span><span class="cx"> #import <WebCore/FloatQuad.h>
</span><ins>+#import <WebCore/NotImplemented.h>
</ins><span class="cx"> #import <WebCore/Pasteboard.h>
</span><span class="cx"> #import <WebCore/Path.h>
</span><span class="cx"> #import <WebCore/PathUtilities.h>
</span><span class="lines">@@ -80,6 +81,11 @@
</span><span class="cx"> #import <WebKit/WebSelectionRect.h> // FIXME: WK2 should not include WebKit headers!
</span><span class="cx"> #import <wtf/RetainPtr.h>
</span><span class="cx">
</span><ins>+#if ENABLE(DATA_INTERACTION)
+#import <WebCore/PlatformPasteboard.h>
+#import <WebCore/WebItemProviderPasteboard.h>
+#endif
+
</ins><span class="cx"> @interface UIEvent(UIEventInternal)
</span><span class="cx"> @property (nonatomic, assign) UIKeyboardInputFlags _inputFlags;
</span><span class="cx"> @end
</span><span class="lines">@@ -493,6 +499,10 @@
</span><span class="cx">
</span><span class="cx"> @implementation WKContentView (WKInteraction)
</span><span class="cx">
</span><ins>+#if USE(APPLE_INTERNAL_SDK) && __has_include(<WebKitAdditions/WKContentViewInteractionAdditions.mm>)
+#import <WebKitAdditions/WKContentViewInteractionAdditions.mm>
+#endif
+
</ins><span class="cx"> static UIWebSelectionMode toUIWebSelectionMode(WKSelectionGranularity granularity)
</span><span class="cx"> {
</span><span class="cx"> switch (granularity) {
</span><span class="lines">@@ -515,6 +525,15 @@
</span><span class="cx"> [_singleTapGestureRecognizer requireGestureRecognizerToFail:_doubleTapGestureRecognizer.get()];
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+- (void)_createAndConfigureLongPressGestureRecognizer
+{
+ _longPressGestureRecognizer = adoptNS([[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(_longPressRecognized:)]);
+ [_longPressGestureRecognizer setDelay:tapAndHoldDelay];
+ [_longPressGestureRecognizer setDelegate:self];
+ [_longPressGestureRecognizer _setRequiresQuietImpulse:YES];
+ [self addGestureRecognizer:_longPressGestureRecognizer.get()];
+}
+
</ins><span class="cx"> - (void)setupInteraction
</span><span class="cx"> {
</span><span class="cx"> if (!_interactionViewsContainerView) {
</span><span class="lines">@@ -557,12 +576,17 @@
</span><span class="cx"> [_highlightLongPressGestureRecognizer setDelegate:self];
</span><span class="cx"> [self addGestureRecognizer:_highlightLongPressGestureRecognizer.get()];
</span><span class="cx">
</span><del>- _longPressGestureRecognizer = adoptNS([[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(_longPressRecognized:)]);
- [_longPressGestureRecognizer setDelay:tapAndHoldDelay];
- [_longPressGestureRecognizer setDelegate:self];
- [_longPressGestureRecognizer _setRequiresQuietImpulse:YES];
- [self addGestureRecognizer:_longPressGestureRecognizer.get()];
</del><ins>+ [self _createAndConfigureLongPressGestureRecognizer];
</ins><span class="cx">
</span><ins>+#if ENABLE(DATA_INTERACTION)
+ _dataInteractionGestureRecognizer = adoptNS([[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(_dataInteractionGestureRecognizer:)]);
+ [_dataInteractionGestureRecognizer setDelay:0.25];
+ [_dataInteractionGestureRecognizer setDelegate:self];
+ [_dataInteractionGestureRecognizer _setRequiresQuietImpulse:YES];
+ [self addGestureRecognizer:_dataInteractionGestureRecognizer.get()];
+ [self setupDataInteractionDelegates];
+#endif
+
</ins><span class="cx"> _twoFingerSingleTapGestureRecognizer = adoptNS([[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(_twoFingerSingleTapGestureRecognized:)]);
</span><span class="cx"> [_twoFingerSingleTapGestureRecognizer setAllowableMovement:60];
</span><span class="cx"> [_twoFingerSingleTapGestureRecognizer _setAllowableSeparation:150];
</span><span class="lines">@@ -637,6 +661,12 @@
</span><span class="cx"> [_twoFingerSingleTapGestureRecognizer setDelegate:nil];
</span><span class="cx"> [self removeGestureRecognizer:_twoFingerSingleTapGestureRecognizer.get()];
</span><span class="cx">
</span><ins>+#if ENABLE(DATA_INTERACTION)
+ [_dataInteractionGestureRecognizer setDelegate:nil];
+ [self removeGestureRecognizer:_dataInteractionGestureRecognizer.get()];
+ [self teardownDataInteractionDelegates];
+#endif
+
</ins><span class="cx"> _inspectorNodeSearchEnabled = NO;
</span><span class="cx"> if (_inspectorNodeSearchGestureRecognizer) {
</span><span class="cx"> [_inspectorNodeSearchGestureRecognizer setDelegate:nil];
</span><span class="lines">@@ -664,6 +694,9 @@
</span><span class="cx"> [self removeGestureRecognizer:_nonBlockingDoubleTapGestureRecognizer.get()];
</span><span class="cx"> [self removeGestureRecognizer:_twoFingerDoubleTapGestureRecognizer.get()];
</span><span class="cx"> [self removeGestureRecognizer:_twoFingerSingleTapGestureRecognizer.get()];
</span><ins>+#if ENABLE(DATA_INTERACTION)
+ [self removeGestureRecognizer:_dataInteractionGestureRecognizer.get()];
+#endif
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> - (void)_addDefaultGestureRecognizers
</span><span class="lines">@@ -675,6 +708,9 @@
</span><span class="cx"> [self addGestureRecognizer:_nonBlockingDoubleTapGestureRecognizer.get()];
</span><span class="cx"> [self addGestureRecognizer:_twoFingerDoubleTapGestureRecognizer.get()];
</span><span class="cx"> [self addGestureRecognizer:_twoFingerSingleTapGestureRecognizer.get()];
</span><ins>+#if ENABLE(DATA_INTERACTION)
+ [self addGestureRecognizer:_dataInteractionGestureRecognizer.get()];
+#endif
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> - (UIView*)unscaledView
</span><span class="lines">@@ -812,6 +848,9 @@
</span><span class="cx">
</span><span class="cx"> - (BOOL)resignFirstResponder
</span><span class="cx"> {
</span><ins>+#if ENABLE(DATA_INTERACTION)
+ _shouldHandleLongPressActionAfterDataInteraction = NO;
+#endif
</ins><span class="cx"> // FIXME: Maybe we should call resignFirstResponder on the superclass
</span><span class="cx"> // and do nothing if the return value is NO.
</span><span class="cx">
</span><span class="lines">@@ -1190,6 +1229,14 @@
</span><span class="cx"> if (isSamePair(gestureRecognizer, otherGestureRecognizer, _highlightLongPressGestureRecognizer.get(), _previewGestureRecognizer.get()))
</span><span class="cx"> return YES;
</span><span class="cx">
</span><ins>+#if ENABLE(DATA_INTERACTION)
+ if (isSamePair(gestureRecognizer, otherGestureRecognizer, _highlightLongPressGestureRecognizer.get(), _dataInteractionGestureRecognizer.get()))
+ return YES;
+
+ if (isSamePair(gestureRecognizer, otherGestureRecognizer, _longPressGestureRecognizer.get(), _dataInteractionGestureRecognizer.get()))
+ return YES;
+#endif
+
</ins><span class="cx"> return NO;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -1360,6 +1407,11 @@
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+#if ENABLE(DATA_INTERACTION)
+ if (gestureRecognizer == _dataInteractionGestureRecognizer)
+ return [self pointIsInDataInteractionContent:point];
+#endif
+
</ins><span class="cx"> return YES;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -1390,9 +1442,37 @@
</span><span class="cx">
</span><span class="cx"> InteractionInformationRequest request(roundedIntPoint(point));
</span><span class="cx"> [self ensurePositionInformationIsUpToDate:request];
</span><ins>+
+#if ENABLE(DATA_INTERACTION)
+ if (_positionInformation.hasDataInteractionAtPosition) {
+ // If the position might initiate a data interaction, we don't want to consider the content at this position to be selectable.
+ // FIXME: This should be renamed to something more precise, such as textSelectionShouldRecognizeGestureAtPoint:
+ return NO;
+ }
+#endif
+
</ins><span class="cx"> return _positionInformation.isSelectable;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+#if ENABLE(DATA_INTERACTION)
+
+- (BOOL)pointIsInDataInteractionContent:(CGPoint)point
+{
+ InteractionInformationRequest request(roundedIntPoint(point));
+ [self ensurePositionInformationIsUpToDate:request];
+
+ if (_positionInformation.isImage)
+ return YES;
+
+ // FIXME: Add support for links.
+ if (_positionInformation.isLink)
+ return NO;
+
+ return _positionInformation.hasDataInteractionAtPosition;
+}
+
+#endif
+
</ins><span class="cx"> - (BOOL)pointIsNearMarkedText:(CGPoint)point
</span><span class="cx"> {
</span><span class="cx"> InteractionInformationRequest request(roundedIntPoint(point));
</span><span class="lines">@@ -1404,6 +1484,15 @@
</span><span class="cx"> {
</span><span class="cx"> InteractionInformationRequest request(roundedIntPoint(point));
</span><span class="cx"> [self ensurePositionInformationIsUpToDate:request];
</span><ins>+
+#if ENABLE(DATA_INTERACTION)
+ if (_positionInformation.hasDataInteractionAtPosition) {
+ // If the position might initiate data interaction, we don't want to change the selection.
+ // FIXME: This should be renamed to something more precise, such as textInteractionShouldRecognizeGestureAtPoint:
+ return NO;
+ }
+#endif
+
</ins><span class="cx"> return _positionInformation.nodeAtPositionIsAssistedNode;
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre>
</div>
</div>
</body>
</html>