Diff
Modified: trunk/Source/WebCore/ChangeLog (198652 => 198653)
--- trunk/Source/WebCore/ChangeLog 2016-03-24 23:18:49 UTC (rev 198652)
+++ trunk/Source/WebCore/ChangeLog 2016-03-24 23:56:27 UTC (rev 198653)
@@ -1,5 +1,28 @@
2016-03-24 Enrica Casucci <enr...@apple.com>
+ Adopt new SPI from DataDetectorsCore to decide link behavior.
+ https://bugs.webkit.org/show_bug.cgi?id=155780
+ rdar://problem/25303631
+
+ Reviewed by Sam Weinig.
+
+ isDataDetectorLink and shouldCancelDefaultAction now
+ use the SPI provided by DataDetectorsCore to decide
+ what is the link behavior when the user taps on it.
+
+ * editing/cocoa/DataDetection.h:
+ * editing/cocoa/DataDetection.mm:
+ (WebCore::detectItemAtPositionWithRange):
+ (WebCore::DataDetection::isDataDetectorLink):
+ (WebCore::DataDetection::requiresExtendedContext):
+ (WebCore::DataDetection::dataDetectorIdentifier):
+ (WebCore::DataDetection::shouldCancelDefaultAction):
+ * platform/cocoa/DataDetectorsCoreSoftLink.h:
+ * platform/cocoa/DataDetectorsCoreSoftLink.mm:
+ * platform/spi/cocoa/DataDetectorsCoreSPI.h:
+
+2016-03-24 Enrica Casucci <enr...@apple.com>
+
DataDetection creates links that are longer than the actual result.
https://bugs.webkit.org/show_bug.cgi?id=155850
rdar://problem/25280740
Modified: trunk/Source/WebCore/editing/cocoa/DataDetection.h (198652 => 198653)
--- trunk/Source/WebCore/editing/cocoa/DataDetection.h 2016-03-24 23:18:49 UTC (rev 198652)
+++ trunk/Source/WebCore/editing/cocoa/DataDetection.h 2016-03-24 23:56:27 UTC (rev 198653)
@@ -58,10 +58,12 @@
WEBCORE_EXPORT static RetainPtr<DDActionContext> detectItemAroundHitTestResult(const HitTestResult&, FloatRect& detectedDataBoundingBox, RefPtr<Range>& detectedDataRange);
#endif
WEBCORE_EXPORT static NSArray *detectContentInRange(RefPtr<Range>& contextRange, DataDetectorTypes);
- WEBCORE_EXPORT static bool isDataDetectorLink(Element*);
- WEBCORE_EXPORT static String dataDetectorIdentifier(Element*);
- WEBCORE_EXPORT static bool shouldCancelDefaultAction(Element*);
- WEBCORE_EXPORT static bool requiresExtendedContext(Element*);
+#if PLATFORM(IOS)
+ WEBCORE_EXPORT static bool isDataDetectorLink(Element&);
+ WEBCORE_EXPORT static String dataDetectorIdentifier(Element&);
+ WEBCORE_EXPORT static bool shouldCancelDefaultAction(Element&);
+ WEBCORE_EXPORT static bool requiresExtendedContext(Element&);
+#endif
};
} // namespace WebCore
Modified: trunk/Source/WebCore/editing/cocoa/DataDetection.mm (198652 => 198653)
--- trunk/Source/WebCore/editing/cocoa/DataDetection.mm 2016-03-24 23:18:49 UTC (rev 198652)
+++ trunk/Source/WebCore/editing/cocoa/DataDetection.mm 2016-03-24 23:56:27 UTC (rev 198653)
@@ -55,48 +55,8 @@
namespace WebCore {
-bool DataDetection::isDataDetectorLink(Element* element)
-{
- // FIXME: We should be able to ask this from DataDetectorsCore when rdar://problem/25206062 is fixed.
- if (!is<HTMLAnchorElement>(*element))
- return false;
-
- if (element->getAttribute(dataDetectorsURLScheme) == "true")
- return true;
- URL url = ""
- return url.protocolIs("mailto") || url.protocolIs("tel");
-}
-
-bool DataDetection::requiresExtendedContext(Element* element)
-{
- return element->getAttribute(dataDetectorsAttributeTypeKey) == "calendar-event";
-}
-
-String DataDetection::dataDetectorIdentifier(Element* element)
-{
- return element->getAttribute(dataDetectorsAttributeResultKey);
-}
-
-bool DataDetection::shouldCancelDefaultAction(Element* element)
-{
#if PLATFORM(MAC)
- UNUSED_PARAM(element);
- return false;
-#else
- // FIXME: We should be able to retrieve this information from DataDetectorsCore when rdar://problem/25169133 is fixed.
- if (!is<HTMLAnchorElement>(*element))
- return false;
- if (element->getAttribute(dataDetectorsURLScheme) != "true")
- return false;
- String type = element->getAttribute(dataDetectorsAttributeTypeKey);
- if (type == "misc" || type == "calendar-event" || type == "telephone")
- return true;
- return false;
-#endif
-}
-#if PLATFORM(MAC)
-
static RetainPtr<DDActionContext> detectItemAtPositionWithRange(VisiblePosition position, RefPtr<Range> contextRange, FloatRect& detectedDataBoundingBox, RefPtr<Range>& detectedDataRange)
{
String fullPlainTextString = plainText(contextRange.get());
@@ -189,7 +149,49 @@
#endif // PLATFORM(MAC)
#if PLATFORM(IOS)
+bool DataDetection::isDataDetectorLink(Element& element)
+{
+ if (!is<HTMLAnchorElement>(element))
+ return false;
+ return [softLink_DataDetectorsCore_DDURLTapAndHoldSchemes() containsObject:(NSString *)downcast<HTMLAnchorElement>(element).href().protocol().convertToASCIILowercase()];
+}
+
+bool DataDetection::requiresExtendedContext(Element& element)
+{
+ return equalIgnoringASCIICase(element.fastGetAttribute(QualifiedName(nullAtom, dataDetectorsAttributeTypeKey, nullAtom)), "calendar-event");
+}
+
+String DataDetection::dataDetectorIdentifier(Element& element)
+{
+ return element.fastGetAttribute(QualifiedName(nullAtom, dataDetectorsAttributeResultKey, nullAtom));
+}
+
+bool DataDetection::shouldCancelDefaultAction(Element& element)
+{
+ if (!isDataDetectorLink(element))
+ return false;
+
+ if (softLink_DataDetectorsCore_DDShouldImmediatelyShowActionSheetForURL(downcast<HTMLAnchorElement>(element).href()))
+ return true;
+
+ const AtomicString& resultAttribute = element.fastGetAttribute(QualifiedName(nullAtom, dataDetectorsAttributeResultKey, nullAtom));
+ if (resultAttribute.isEmpty())
+ return false;
+ NSArray *results = element.document().frame()->dataDetectionResults();
+ if (!results)
+ return false;
+ Vector<String> resultIndices;
+ resultAttribute.string().split('/', resultIndices);
+ DDResultRef result = [[results objectAtIndex:resultIndices[0].toInt()] coreResult];
+ // Handle the case of a signature block, where we need to check the correct subresult.
+ for (size_t i = 1; i < resultIndices.size(); i++) {
+ results = (NSArray *)softLink_DataDetectorsCore_DDResultGetSubResults(result);
+ result = (DDResultRef)[results objectAtIndex:resultIndices[i].toInt()];
+ }
+ return softLink_DataDetectorsCore_DDShouldImmediatelyShowActionSheetForResult(result);
+}
+
static BOOL resultIsURL(DDResultRef result)
{
if (!result)
Modified: trunk/Source/WebCore/platform/cocoa/DataDetectorsCoreSoftLink.h (198652 => 198653)
--- trunk/Source/WebCore/platform/cocoa/DataDetectorsCoreSoftLink.h 2016-03-24 23:18:49 UTC (rev 198652)
+++ trunk/Source/WebCore/platform/cocoa/DataDetectorsCoreSoftLink.h 2016-03-24 23:56:27 UTC (rev 198653)
@@ -48,6 +48,9 @@
SOFT_LINK_FUNCTION_FOR_HEADER(WebCore, DataDetectorsCore, DDResultGetSubResults, CFArrayRef, (DDResultRef result), (result))
SOFT_LINK_FUNCTION_FOR_HEADER(WebCore, DataDetectorsCore, DDResultGetQueryRangeForURLification, DDQueryRange, (DDResultRef result), (result))
SOFT_LINK_FUNCTION_FOR_HEADER(WebCore, DataDetectorsCore, DDURLStringForResult, NSString *, (DDResultRef currentResult, NSString * resultIdentifier, DDURLifierPhoneNumberDetectionTypes includingTelGroups, NSDate * referenceDate, NSTimeZone * referenceTimeZone), (currentResult, resultIdentifier, includingTelGroups, referenceDate, referenceTimeZone))
+SOFT_LINK_FUNCTION_FOR_HEADER(WebCore, DataDetectorsCore, DDURLTapAndHoldSchemes, NSArray *, (), ())
+SOFT_LINK_FUNCTION_FOR_HEADER(WebCore, DataDetectorsCore, DDShouldImmediatelyShowActionSheetForURL, BOOL, (NSURL *url), (url))
+SOFT_LINK_FUNCTION_FOR_HEADER(WebCore, DataDetectorsCore, DDShouldImmediatelyShowActionSheetForResult, BOOL, (DDResultRef result), (result))
SOFT_LINK_POINTER_FOR_HEADER(WebCore, DataDetectorsCore, DDBinderHttpURLKey, CFStringRef)
SOFT_LINK_POINTER_FOR_HEADER(WebCore, DataDetectorsCore, DDBinderWebURLKey, CFStringRef)
SOFT_LINK_POINTER_FOR_HEADER(WebCore, DataDetectorsCore, DDBinderMailURLKey, CFStringRef)
Modified: trunk/Source/WebCore/platform/cocoa/DataDetectorsCoreSoftLink.mm (198652 => 198653)
--- trunk/Source/WebCore/platform/cocoa/DataDetectorsCoreSoftLink.mm 2016-03-24 23:18:49 UTC (rev 198652)
+++ trunk/Source/WebCore/platform/cocoa/DataDetectorsCoreSoftLink.mm 2016-03-24 23:56:27 UTC (rev 198653)
@@ -47,6 +47,9 @@
SOFT_LINK_FUNCTION_FOR_SOURCE(WebCore, DataDetectorsCore, DDResultGetSubResults, CFArrayRef, (DDResultRef result), (result))
SOFT_LINK_FUNCTION_FOR_SOURCE(WebCore, DataDetectorsCore, DDResultGetQueryRangeForURLification, DDQueryRange, (DDResultRef result), (result))
SOFT_LINK_FUNCTION_FOR_SOURCE(WebCore, DataDetectorsCore, DDURLStringForResult, NSString *, (DDResultRef currentResult, NSString * resultIdentifier, DDURLifierPhoneNumberDetectionTypes includingTelGroups, NSDate * referenceDate, NSTimeZone * referenceTimeZone), (currentResult, resultIdentifier, includingTelGroups, referenceDate, referenceTimeZone))
+SOFT_LINK_FUNCTION_FOR_SOURCE(WebCore, DataDetectorsCore, DDURLTapAndHoldSchemes, NSArray *, (), ())
+SOFT_LINK_FUNCTION_FOR_SOURCE(WebCore, DataDetectorsCore, DDShouldImmediatelyShowActionSheetForURL, BOOL, (NSURL *url), (url))
+SOFT_LINK_FUNCTION_FOR_SOURCE(WebCore, DataDetectorsCore, DDShouldImmediatelyShowActionSheetForResult, BOOL, (DDResultRef result), (result))
SOFT_LINK_POINTER_FOR_SOURCE(WebCore, DataDetectorsCore, DDBinderHttpURLKey, CFStringRef)
SOFT_LINK_POINTER_FOR_SOURCE(WebCore, DataDetectorsCore, DDBinderWebURLKey, CFStringRef)
SOFT_LINK_POINTER_FOR_SOURCE(WebCore, DataDetectorsCore, DDBinderMailURLKey, CFStringRef)
Modified: trunk/Source/WebCore/platform/spi/cocoa/DataDetectorsCoreSPI.h (198652 => 198653)
--- trunk/Source/WebCore/platform/spi/cocoa/DataDetectorsCoreSPI.h 2016-03-24 23:18:49 UTC (rev 198652)
+++ trunk/Source/WebCore/platform/spi/cocoa/DataDetectorsCoreSPI.h 2016-03-24 23:56:27 UTC (rev 198653)
@@ -26,6 +26,8 @@
#ifndef DataDetectorsCoreSPI_h
#define DataDetectorsCoreSPI_h
+typedef struct __DDResult *DDResultRef;
+
#if USE(APPLE_INTERNAL_SDK)
#import <DataDetectorsCore/DDBinderKeys_Private.h>
@@ -97,6 +99,7 @@
@interface DDScannerResult : NSObject <NSCoding, NSSecureCoding>
+ (NSArray *)resultsFromCoreResults:(CFArrayRef)coreResults;
+- (DDResultRef)coreResult;
@end
#define DDResultPropertyPassiveDisplay (1 << 0)
@@ -113,7 +116,6 @@
#endif // !USE(APPLE_INTERNAL_SDK)
-typedef struct __DDResult *DDResultRef;
typedef struct __DDScanQuery *DDScanQueryRef;
typedef struct __DDScanner *DDScannerRef;
Modified: trunk/Source/WebKit2/ChangeLog (198652 => 198653)
--- trunk/Source/WebKit2/ChangeLog 2016-03-24 23:18:49 UTC (rev 198652)
+++ trunk/Source/WebKit2/ChangeLog 2016-03-24 23:56:27 UTC (rev 198653)
@@ -1,3 +1,19 @@
+2016-03-24 Enrica Casucci <enr...@apple.com>
+
+ Adopt new SPI from DataDetectorsCore to decide link behavior.
+ https://bugs.webkit.org/show_bug.cgi?id=155780
+ rdar://problem/25303631
+
+ Reviewed by Sam Weinig.
+
+ Changed use of data detection functions to take
+ a reference to Element instead of a pointer.
+
+ * WebProcess/WebPage/ios/WebPageIOS.mm:
+ (WebKit::WebPage::handleTap):
+ (WebKit::WebPage::commitPotentialTap):
+ (WebKit::WebPage::getPositionInformation):
+
2016-03-24 Chris Dumez <cdu...@apple.com>
[WK2] Disable network cache speculative validation by default
Modified: trunk/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm (198652 => 198653)
--- trunk/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm 2016-03-24 23:18:49 UTC (rev 198652)
+++ trunk/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm 2016-03-24 23:56:27 UTC (rev 198653)
@@ -600,7 +600,7 @@
if (!frameRespondingToClick || lastLayerTreeTransactionId < WebFrame::fromCoreFrame(*frameRespondingToClick)->firstLayerTreeTransactionIDAfterDidCommitLoad())
send(Messages::WebPageProxy::DidNotHandleTapAsClick(adjustedIntPoint));
- else if (is<Element>(*nodeRespondingToClick) && DataDetection::shouldCancelDefaultAction(&downcast<Element>(*nodeRespondingToClick))) {
+ else if (is<Element>(*nodeRespondingToClick) && DataDetection::shouldCancelDefaultAction(downcast<Element>(*nodeRespondingToClick))) {
requestPositionInformation(adjustedIntPoint);
send(Messages::WebPageProxy::DidNotHandleTapAsClick(adjustedIntPoint));
} else
@@ -683,7 +683,7 @@
}
if (m_potentialTapNode == nodeRespondingToClick) {
- if (is<Element>(*nodeRespondingToClick) && DataDetection::shouldCancelDefaultAction(&downcast<Element>(*nodeRespondingToClick))) {
+ if (is<Element>(*nodeRespondingToClick) && DataDetection::shouldCancelDefaultAction(downcast<Element>(*nodeRespondingToClick))) {
requestPositionInformation(roundedIntPoint(m_potentialTapLocation));
commitPotentialTapFailed();
} else
@@ -2223,12 +2223,12 @@
info.linkIndicator = textIndicator->data();
}
#if ENABLE(DATA_DETECTION)
- info.isDataDetectorLink = DataDetection::isDataDetectorLink(element);
+ info.isDataDetectorLink = DataDetection::isDataDetectorLink(*element);
if (info.isDataDetectorLink) {
const int dataDetectionExtendedContextLength = 350;
- info.dataDetectorIdentifier = DataDetection::dataDetectorIdentifier(element);
+ info.dataDetectorIdentifier = DataDetection::dataDetectorIdentifier(*element);
info.dataDetectorResults = element->document().frame()->dataDetectionResults();
- if (DataDetection::requiresExtendedContext(element)) {
+ if (DataDetection::requiresExtendedContext(*element)) {
RefPtr<Range> linkRange = Range::create(element->document());
linkRange->selectNodeContents(element, ASSERT_NO_EXCEPTION);
info.textBefore = plainTextReplacingNoBreakSpace(rangeExpandedByCharactersInDirectionAtWordBoundary(linkRange->startPosition(), dataDetectionExtendedContextLength, DirectionBackward).get(), TextIteratorDefaultBehavior, true);