Title: [195317] trunk/Source
Revision
195317
Author
[email protected]
Date
2016-01-19 14:58:59 -0800 (Tue, 19 Jan 2016)

Log Message

Add support for DataDetectors in WK (iOS).
https://bugs.webkit.org/show_bug.cgi?id=152989
rdar://problem/22855960

Reviewed by Tim Horton.

Source/_javascript_Core:

Adding feature definition for data detection.

* Configurations/FeatureDefines.xcconfig:

Source/WebCore:

This is the first step toward implementing Data Detectors support
in WK2. The patch adds a new memeber to the Settings object
to retrieve the type of detection desired. The DataDetection files
have been moved under cocoa, since they are no longer OS X specific.

* Configurations/FeatureDefines.xcconfig:
* Configurations/WebCore.xcconfig:
* WebCore.xcodeproj/project.pbxproj:
* editing/cocoa/DataDetection.h: Copied from Source/WebCore/editing/mac/DataDetection.h.
* editing/cocoa/DataDetection.mm: Copied from Source/WebCore/editing/mac/DataDetection.mm.
(WebCore::detectItemAtPositionWithRange):
(WebCore::DataDetection::detectItemAroundHitTestResult):
(WebCore::DataDetection::detectContentInRange):
* editing/mac/DataDetection.h: Removed.
* editing/mac/DataDetection.mm: Removed.
* loader/FrameLoader.cpp:
(WebCore::FrameLoader::checkLoadCompleteForThisFrame):
* page/Settings.h:
* page/Settings.in:
* platform/spi/mac/DataDetectorsSPI.h:

Source/WebKit/mac:

Adding feature definition for data detection.

* Configurations/FeatureDefines.xcconfig:

Source/WebKit2:

This is the first step toward implementing Data Detectors support
in WK2. The patch adds a new property to the configuration
object to indicate the type of detection desired and propagates
to the WebProcess.

* Configurations/FeatureDefines.xcconfig:
* Shared/WebPreferencesDefinitions.h:
* UIProcess/API/Cocoa/WKWebView.mm:
(fromWKDataDetectorTypes):
(-[WKWebView initWithFrame:configuration:]):
* UIProcess/API/Cocoa/WKWebViewConfiguration.h:
* UIProcess/API/Cocoa/WKWebViewConfiguration.mm:
(-[WKWebViewConfiguration copyWithZone:]):
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::updatePreferences):

Source/WTF:

Adding feature definition for data detection.

* wtf/FeatureDefines.h:

Modified Paths

Added Paths

Removed Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (195316 => 195317)


--- trunk/Source/_javascript_Core/ChangeLog	2016-01-19 22:37:02 UTC (rev 195316)
+++ trunk/Source/_javascript_Core/ChangeLog	2016-01-19 22:58:59 UTC (rev 195317)
@@ -1,3 +1,15 @@
+2016-01-19  Enrica Casucci  <[email protected]>
+
+        Add support for DataDetectors in WK (iOS).
+        https://bugs.webkit.org/show_bug.cgi?id=152989
+        rdar://problem/22855960
+
+        Reviewed by Tim Horton.
+
+        Adding feature definition for data detection.
+
+        * Configurations/FeatureDefines.xcconfig:
+
 2016-01-19  Per Arne Vollan  <[email protected]>
 
         [B3][Win64] Compile and warning fixes.

Modified: trunk/Source/_javascript_Core/Configurations/FeatureDefines.xcconfig (195316 => 195317)


--- trunk/Source/_javascript_Core/Configurations/FeatureDefines.xcconfig	2016-01-19 22:37:02 UTC (rev 195316)
+++ trunk/Source/_javascript_Core/Configurations/FeatureDefines.xcconfig	2016-01-19 22:58:59 UTC (rev 195317)
@@ -111,6 +111,7 @@
 ENABLE_MAC_GESTURE_EVENTS_macosx_WITH_INTERNAL_SDK_YES = ENABLE_MAC_GESTURE_EVENTS;
 
 ENABLE_IOS_TEXT_AUTOSIZING[sdk=iphone*] = ENABLE_IOS_TEXT_AUTOSIZING;
+ENABLE_DATA_DETECTION = ENABLE_DATA_DETECTION;
 
 ENABLE_IOS_TOUCH_EVENTS[sdk=iphone*] = $(ENABLE_IOS_TOUCH_EVENTS_ios_WITH_INTERNAL_SDK_$(USE_INTERNAL_SDK));
 ENABLE_IOS_TOUCH_EVENTS_ios_WITH_INTERNAL_SDK_YES = ENABLE_IOS_TOUCH_EVENTS;

Modified: trunk/Source/WTF/ChangeLog (195316 => 195317)


--- trunk/Source/WTF/ChangeLog	2016-01-19 22:37:02 UTC (rev 195316)
+++ trunk/Source/WTF/ChangeLog	2016-01-19 22:58:59 UTC (rev 195317)
@@ -1,3 +1,15 @@
+2016-01-19  Enrica Casucci  <[email protected]>
+
+        Add support for DataDetectors in WK (iOS).
+        https://bugs.webkit.org/show_bug.cgi?id=152989
+        rdar://problem/22855960
+
+        Reviewed by Tim Horton.
+
+        Adding feature definition for data detection.
+
+        * wtf/FeatureDefines.h:
+
 2016-01-19  Commit Queue  <[email protected]>
 
         Unreviewed, rolling out r195300.

Modified: trunk/Source/WTF/wtf/FeatureDefines.h (195316 => 195317)


--- trunk/Source/WTF/wtf/FeatureDefines.h	2016-01-19 22:37:02 UTC (rev 195316)
+++ trunk/Source/WTF/wtf/FeatureDefines.h	2016-01-19 22:58:59 UTC (rev 195317)
@@ -272,6 +272,14 @@
 
 #endif /* PLATFORM(MAC) */
 
+#if PLATFORM(COCOA)
+
+#if !defined(ENABLE_DATA_DETECTION)
+#define ENABLE_DATA_DETECTION 1
+#endif
+
+#endif /* PLATFORM(COCOA) */
+
 /* --------- Apple Windows port --------- */
 #if PLATFORM(WIN) && !PLATFORM(WIN_CAIRO)
 

Modified: trunk/Source/WebCore/ChangeLog (195316 => 195317)


--- trunk/Source/WebCore/ChangeLog	2016-01-19 22:37:02 UTC (rev 195316)
+++ trunk/Source/WebCore/ChangeLog	2016-01-19 22:58:59 UTC (rev 195317)
@@ -1,3 +1,32 @@
+2016-01-19  Enrica Casucci  <[email protected]>
+
+        Add support for DataDetectors in WK (iOS).
+        https://bugs.webkit.org/show_bug.cgi?id=152989
+        rdar://problem/22855960
+
+        Reviewed by Tim Horton.
+
+        This is the first step toward implementing Data Detectors support
+        in WK2. The patch adds a new memeber to the Settings object
+        to retrieve the type of detection desired. The DataDetection files
+        have been moved under cocoa, since they are no longer OS X specific.
+
+        * Configurations/FeatureDefines.xcconfig:
+        * Configurations/WebCore.xcconfig:
+        * WebCore.xcodeproj/project.pbxproj:
+        * editing/cocoa/DataDetection.h: Copied from Source/WebCore/editing/mac/DataDetection.h.
+        * editing/cocoa/DataDetection.mm: Copied from Source/WebCore/editing/mac/DataDetection.mm.
+        (WebCore::detectItemAtPositionWithRange):
+        (WebCore::DataDetection::detectItemAroundHitTestResult):
+        (WebCore::DataDetection::detectContentInRange):
+        * editing/mac/DataDetection.h: Removed.
+        * editing/mac/DataDetection.mm: Removed.
+        * loader/FrameLoader.cpp:
+        (WebCore::FrameLoader::checkLoadCompleteForThisFrame):
+        * page/Settings.h:
+        * page/Settings.in:
+        * platform/spi/mac/DataDetectorsSPI.h:
+
 2016-01-19  Nikos Andronikos  <[email protected]>
 
         SVG 2 requires a mechanism for restricting enum values exposed through the DOM
@@ -99,6 +128,7 @@
         (WebCore::matchesFutureCuePseudoClass):
         (WebCore::matchesPastCuePseudoClass):
 
+>>>>>>> .r195316
 2016-01-19  Chris Dumez  <[email protected]>
 
         Unreviewed, rolling out r195179.

Modified: trunk/Source/WebCore/Configurations/FeatureDefines.xcconfig (195316 => 195317)


--- trunk/Source/WebCore/Configurations/FeatureDefines.xcconfig	2016-01-19 22:37:02 UTC (rev 195316)
+++ trunk/Source/WebCore/Configurations/FeatureDefines.xcconfig	2016-01-19 22:58:59 UTC (rev 195317)
@@ -111,6 +111,7 @@
 ENABLE_MAC_GESTURE_EVENTS_macosx_WITH_INTERNAL_SDK_YES = ENABLE_MAC_GESTURE_EVENTS;
 
 ENABLE_IOS_TEXT_AUTOSIZING[sdk=iphone*] = ENABLE_IOS_TEXT_AUTOSIZING;
+ENABLE_DATA_DETECTION = ENABLE_DATA_DETECTION;
 
 ENABLE_IOS_TOUCH_EVENTS[sdk=iphone*] = $(ENABLE_IOS_TOUCH_EVENTS_ios_WITH_INTERNAL_SDK_$(USE_INTERNAL_SDK));
 ENABLE_IOS_TOUCH_EVENTS_ios_WITH_INTERNAL_SDK_YES = ENABLE_IOS_TOUCH_EVENTS;

Modified: trunk/Source/WebCore/Configurations/WebCore.xcconfig (195316 => 195317)


--- trunk/Source/WebCore/Configurations/WebCore.xcconfig	2016-01-19 22:37:02 UTC (rev 195316)
+++ trunk/Source/WebCore/Configurations/WebCore.xcconfig	2016-01-19 22:58:59 UTC (rev 195317)
@@ -50,7 +50,7 @@
 UNEXPORTED_SYMBOLS_FILE = Configurations/WebCore.unexp;
 OTHER_LDFLAGS = $(inherited) $(OTHER_LDFLAGS_PLATFORM);
 OTHER_LDFLAGS_BASE = -lsqlite3 -lobjc -lANGLE;
-OTHER_LDFLAGS_BASE_ios = $(OTHER_LDFLAGS_BASE) -framework CFNetwork -framework CoreGraphics -framework CoreText -framework Foundation -framework GraphicsServices -framework ImageIO -framework OpenGLES -lMobileGestalt;
+OTHER_LDFLAGS_BASE_ios = $(OTHER_LDFLAGS_BASE) -framework CFNetwork -framework CoreGraphics -framework CoreText -framework Foundation -framework GraphicsServices -framework ImageIO -framework OpenGLES -lMobileGestalt -framework DataDetectorsCore;
 OTHER_LDFLAGS_PLATFORM[sdk=iphoneos*] = $(OTHER_LDFLAGS_BASE_ios) -framework IOSurface;
 OTHER_LDFLAGS_PLATFORM[sdk=iphonesimulator*] = $(OTHER_LDFLAGS_BASE_ios);
 OTHER_LDFLAGS_PLATFORM[sdk=macosx*] = $(OTHER_LDFLAGS_BASE) -sub_library libobjc -umbrella WebKit -allowable_client WebCoreTestSupport -allowable_client WebKit2 -allowable_client WebKitLegacy -framework ApplicationServices -framework AudioUnit -framework Carbon -framework Cocoa -framework DataDetectorsCore -framework IOSurface -framework OpenGL;

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (195316 => 195317)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2016-01-19 22:37:02 UTC (rev 195316)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2016-01-19 22:58:59 UTC (rev 195317)
@@ -1137,8 +1137,6 @@
 		2D5002FC1B56D7990020AAF7 /* PathUtilities.h in Headers */ = {isa = PBXBuildFile; fileRef = 2D5002FA1B56D7990020AAF7 /* PathUtilities.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		2D5036681BCDDDC400E20BB3 /* GestureEvents.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2D5036671BCDDDC400E20BB3 /* GestureEvents.cpp */; };
 		2D5646B01B8F8493003C4994 /* DictionaryPopupInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = 2D5646AF1B8F8493003C4994 /* DictionaryPopupInfo.h */; settings = {ATTRIBUTES = (Private, ); }; };
-		2D58D8551A15F65F00A5F726 /* DataDetection.h in Headers */ = {isa = PBXBuildFile; fileRef = 2D58D8531A15F65F00A5F726 /* DataDetection.h */; settings = {ATTRIBUTES = (Private, ); }; };
-		2D58D8561A15F65F00A5F726 /* DataDetection.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2D58D8541A15F65F00A5F726 /* DataDetection.mm */; };
 		2D59F1BF1A0044C6001F3D29 /* DataDetectorsSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = 2D59F1BE1A0044C6001F3D29 /* DataDetectorsSPI.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		2D5A592F152525230036EE51 /* ImageOrientation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A8748D7412CC3F89001FBA41 /* ImageOrientation.cpp */; };
 		2D5A5931152525D00036EE51 /* ImageOrientation.h in Headers */ = {isa = PBXBuildFile; fileRef = A8748D6612CC3763001FBA41 /* ImageOrientation.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -5882,6 +5880,8 @@
 		C50D0E830FF4272900AC2644 /* StorageNamespace.h in Headers */ = {isa = PBXBuildFile; fileRef = C50D0E810FF4272900AC2644 /* StorageNamespace.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		C5137CF211A58378004ADB99 /* JSDOMStringList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C5137CF011A58378004ADB99 /* JSDOMStringList.cpp */; };
 		C5137CF311A58378004ADB99 /* JSDOMStringList.h in Headers */ = {isa = PBXBuildFile; fileRef = C5137CF111A58378004ADB99 /* JSDOMStringList.h */; };
+		C5227DF11C3C6DF100F5ED54 /* DataDetection.h in Headers */ = {isa = PBXBuildFile; fileRef = C5227DEF1C3C6DD700F5ED54 /* DataDetection.h */; settings = {ATTRIBUTES = (Private, ); }; };
+		C5227DF21C3C6DF900F5ED54 /* DataDetection.mm in Sources */ = {isa = PBXBuildFile; fileRef = C5227DF01C3C6DD700F5ED54 /* DataDetection.mm */; };
 		C5278B0C17F212EA003A2998 /* PlatformPasteboardIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = C5278B0B17F212EA003A2998 /* PlatformPasteboardIOS.mm */; };
 		C544274B11A57E7A0063A749 /* DOMStringList.h in Headers */ = {isa = PBXBuildFile; fileRef = C544274911A57E7A0063A749 /* DOMStringList.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		C55610F111A704EB00B82D27 /* DOMStringList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C55610F011A704EB00B82D27 /* DOMStringList.cpp */; };
@@ -8514,8 +8514,6 @@
 		2D5002FA1B56D7990020AAF7 /* PathUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PathUtilities.h; sourceTree = "<group>"; };
 		2D5036671BCDDDC400E20BB3 /* GestureEvents.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GestureEvents.cpp; sourceTree = "<group>"; };
 		2D5646AF1B8F8493003C4994 /* DictionaryPopupInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DictionaryPopupInfo.h; sourceTree = "<group>"; };
-		2D58D8531A15F65F00A5F726 /* DataDetection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DataDetection.h; sourceTree = "<group>"; };
-		2D58D8541A15F65F00A5F726 /* DataDetection.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DataDetection.mm; sourceTree = "<group>"; };
 		2D59F1BE1A0044C6001F3D29 /* DataDetectorsSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DataDetectorsSPI.h; sourceTree = "<group>"; };
 		2D5BC42516F882BE007048D0 /* SecurityPolicyViolationEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SecurityPolicyViolationEvent.h; sourceTree = "<group>"; };
 		2D5BC42616F882BE007048D0 /* SecurityPolicyViolationEvent.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = SecurityPolicyViolationEvent.idl; sourceTree = "<group>"; };
@@ -13713,6 +13711,8 @@
 		C50D0E810FF4272900AC2644 /* StorageNamespace.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StorageNamespace.h; sourceTree = "<group>"; };
 		C5137CF011A58378004ADB99 /* JSDOMStringList.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSDOMStringList.cpp; sourceTree = "<group>"; };
 		C5137CF111A58378004ADB99 /* JSDOMStringList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSDOMStringList.h; sourceTree = "<group>"; };
+		C5227DEF1C3C6DD700F5ED54 /* DataDetection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DataDetection.h; sourceTree = "<group>"; };
+		C5227DF01C3C6DD700F5ED54 /* DataDetection.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DataDetection.mm; sourceTree = "<group>"; };
 		C5278B0B17F212EA003A2998 /* PlatformPasteboardIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PlatformPasteboardIOS.mm; sourceTree = "<group>"; };
 		C544274911A57E7A0063A749 /* DOMStringList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DOMStringList.h; sourceTree = "<group>"; };
 		C544274A11A57E7A0063A749 /* DOMStringList.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = DOMStringList.idl; sourceTree = "<group>"; };
@@ -17885,6 +17885,8 @@
 		7C3E510718DF8F1200C112F7 /* cocoa */ = {
 			isa = PBXGroup;
 			children = (
+				C5227DEF1C3C6DD700F5ED54 /* DataDetection.h */,
+				C5227DF01C3C6DD700F5ED54 /* DataDetection.mm */,
 				9B55EEEA1B3F3FEF005342BC /* EditorCocoa.h */,
 				9B55EEE81B3E8898005342BC /* EditorCocoa.mm */,
 				7C3E510818DF8F3500C112F7 /* HTMLConverter.h */,
@@ -23191,8 +23193,6 @@
 			children = (
 				CE7B2DAF1586ABAD0098B3FA /* AlternativeTextUIController.h */,
 				CE7B2DB01586ABAD0098B3FA /* AlternativeTextUIController.mm */,
-				2D58D8531A15F65F00A5F726 /* DataDetection.h */,
-				2D58D8541A15F65F00A5F726 /* DataDetection.mm */,
 				937FF3D41A1012D6008EBA31 /* DictionaryLookup.h */,
 				937FF3D61A10131B008EBA31 /* DictionaryLookup.mm */,
 				ED501DC50B249F2900AE18D9 /* EditorMac.mm */,
@@ -25068,7 +25068,6 @@
 				97BC6A301505F081001B74AC /* DatabaseThread.h in Headers */,
 				97BC6A321505F081001B74AC /* DatabaseTracker.h in Headers */,
 				BE23480D18A9871400E4B6E8 /* DataCue.h in Headers */,
-				2D58D8551A15F65F00A5F726 /* DataDetection.h in Headers */,
 				935E2B4E1AFF06CA00976F9F /* DataDetectorsCoreSPI.h in Headers */,
 				2D59F1BF1A0044C6001F3D29 /* DataDetectorsSPI.h in Headers */,
 				BC22746F0E83664500E7F975 /* DataRef.h in Headers */,
@@ -26040,6 +26039,7 @@
 				B27535750B053814002CE64F /* IntSize.h in Headers */,
 				B27535760B053814002CE64F /* IntSizeHash.h in Headers */,
 				CE12524D1A1A77DE00864480 /* IOPMLibSPI.h in Headers */,
+				C5227DF11C3C6DF100F5ED54 /* DataDetection.h in Headers */,
 				44DEF6431A6FF92700D45EEC /* IOReturnSPI.h in Headers */,
 				2D0B4AAB18DA1CCD00434DE1 /* IOSurface.h in Headers */,
 				1C21E57D183ED1FF001C289D /* IOSurfacePool.h in Headers */,
@@ -28747,6 +28747,7 @@
 				85031B3F0A44EFC700F992E0 /* ClipboardEvent.cpp in Sources */,
 				580371611A66F00A00BAF519 /* ClipRect.cpp in Sources */,
 				CDEA76351460B71A008B31F1 /* Clock.cpp in Sources */,
+				C5227DF21C3C6DF900F5ED54 /* DataDetection.mm in Sources */,
 				CDEA76341460B56F008B31F1 /* ClockGeneric.cpp in Sources */,
 				9BD8A95A18BEFC7600987E9A /* CollectionIndexCache.cpp in Sources */,
 				B27535660B053814002CE64F /* Color.cpp in Sources */,
@@ -28926,7 +28927,6 @@
 				97BC6A2F1505F081001B74AC /* DatabaseThread.cpp in Sources */,
 				97BC6A311505F081001B74AC /* DatabaseTracker.cpp in Sources */,
 				BE23480C18A9870B00E4B6E8 /* DataCue.cpp in Sources */,
-				2D58D8561A15F65F00A5F726 /* DataDetection.mm in Sources */,
 				BC64641D11D7F416006455B0 /* DatasetDOMStringMap.cpp in Sources */,
 				A784941B0B5FE507001E237A /* DataTransfer.cpp in Sources */,
 				93F19AFF08245E59001E9ABC /* DataTransferMac.mm in Sources */,

Copied: trunk/Source/WebCore/editing/cocoa/DataDetection.h (from rev 195310, trunk/Source/WebCore/editing/mac/DataDetection.h) (0 => 195317)


--- trunk/Source/WebCore/editing/cocoa/DataDetection.h	                        (rev 0)
+++ trunk/Source/WebCore/editing/cocoa/DataDetection.h	2016-01-19 22:58:59 UTC (rev 195317)
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef DataDetection_h
+#define DataDetection_h
+
+#import <wtf/RefPtr.h>
+#import <wtf/RetainPtr.h>
+
+OBJC_CLASS DDActionContext;
+
+namespace WebCore {
+
+class FloatRect;
+class HitTestResult;
+class Range;
+
+enum DataDetectorTypes {
+    DataDetectorTypeNone = 0,
+    DataDetectorTypePhoneNumber = 1 << 0,
+    DataDetectorTypeLink = 1 << 1,
+    DataDetectorTypeAddress = 1 << 2,
+    DataDetectorTypeCalendarEvent = 1 << 3,
+    DataDetectorTypeTrackingNumber = 1 << 4, // Not individually selectable with the API
+    DataDetectorTypeFlight = 1 << 5, // Not individually selectable with the API
+    DataDetectorTypeAll = ULONG_MAX
+};
+
+class DataDetection {
+public:
+#if PLATFORM(MAC)
+    WEBCORE_EXPORT static RetainPtr<DDActionContext> detectItemAroundHitTestResult(const HitTestResult&, FloatRect& detectedDataBoundingBox, RefPtr<Range>& detectedDataRange);
+#endif
+    WEBCORE_EXPORT static void detectContentInRange(RefPtr<Range>& contextRange, DataDetectorTypes);
+};
+
+} // namespace WebCore
+
+#endif // DataDetection_h

Copied: trunk/Source/WebCore/editing/cocoa/DataDetection.mm (from rev 195310, trunk/Source/WebCore/editing/mac/DataDetection.mm) (0 => 195317)


--- trunk/Source/WebCore/editing/cocoa/DataDetection.mm	                        (rev 0)
+++ trunk/Source/WebCore/editing/cocoa/DataDetection.mm	2016-01-19 22:58:59 UTC (rev 195317)
@@ -0,0 +1,146 @@
+/*
+ * Copyright (C) 2014 Apple, Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "config.h"
+#import "DataDetection.h"
+
+#import "Attr.h"
+#import "CSSStyleDeclaration.h"
+#import "DataDetectorsSPI.h"
+#import "FrameView.h"
+#import "HTMLAnchorElement.h"
+#import "HTMLTextFormControlElement.h"
+#import "HitTestResult.h"
+#import "Node.h"
+#import "NodeList.h"
+#import "NodeTraversal.h"
+#import "Range.h"
+#import "RenderObject.h"
+#import "Text.h"
+#import "TextIterator.h"
+#import "VisiblePosition.h"
+#import "VisibleUnits.h"
+#import "htmlediting.h"
+
+namespace WebCore {
+
+#if PLATFORM(MAC)
+
+static RetainPtr<DDActionContext> detectItemAtPositionWithRange(VisiblePosition position, RefPtr<Range> contextRange, FloatRect& detectedDataBoundingBox, RefPtr<Range>& detectedDataRange)
+{
+    String fullPlainTextString = plainText(contextRange.get());
+    int hitLocation = TextIterator::rangeLength(makeRange(contextRange->startPosition(), position).get());
+
+    RetainPtr<DDScannerRef> scanner = adoptCF(DDScannerCreate(DDScannerTypeStandard, 0, nullptr));
+    RetainPtr<DDScanQueryRef> scanQuery = adoptCF(DDScanQueryCreateFromString(kCFAllocatorDefault, fullPlainTextString.createCFString().get(), CFRangeMake(0, fullPlainTextString.length())));
+
+    if (!DDScannerScanQuery(scanner.get(), scanQuery.get()))
+        return nullptr;
+
+    RetainPtr<CFArrayRef> results = adoptCF(DDScannerCopyResultsWithOptions(scanner.get(), DDScannerCopyResultsOptionsNoOverlap));
+
+    // Find the DDResultRef that intersects the hitTestResult's VisiblePosition.
+    DDResultRef mainResult = nullptr;
+    RefPtr<Range> mainResultRange;
+    CFIndex resultCount = CFArrayGetCount(results.get());
+    for (CFIndex i = 0; i < resultCount; i++) {
+        DDResultRef result = (DDResultRef)CFArrayGetValueAtIndex(results.get(), i);
+        CFRange resultRangeInContext = DDResultGetRange(result);
+        if (hitLocation >= resultRangeInContext.location && (hitLocation - resultRangeInContext.location) < resultRangeInContext.length) {
+            mainResult = result;
+            mainResultRange = TextIterator::subrange(contextRange.get(), resultRangeInContext.location, resultRangeInContext.length);
+            break;
+        }
+    }
+
+    if (!mainResult)
+        return nullptr;
+
+    RetainPtr<DDActionContext> actionContext = adoptNS([allocDDActionContextInstance() init]);
+    [actionContext setAllResults:@[ (id)mainResult ]];
+    [actionContext setMainResult:mainResult];
+
+    Vector<FloatQuad> quads;
+    mainResultRange->absoluteTextQuads(quads);
+    detectedDataBoundingBox = FloatRect();
+    FrameView* frameView = mainResultRange->ownerDocument().view();
+    for (const auto& quad : quads)
+        detectedDataBoundingBox.unite(frameView->contentsToWindow(quad.enclosingBoundingBox()));
+    
+    detectedDataRange = mainResultRange;
+    
+    return actionContext;
+}
+
+RetainPtr<DDActionContext> DataDetection::detectItemAroundHitTestResult(const HitTestResult& hitTestResult, FloatRect& detectedDataBoundingBox, RefPtr<Range>& detectedDataRange)
+{
+    if (!DataDetectorsLibrary())
+        return nullptr;
+
+    Node* node = hitTestResult.innerNonSharedNode();
+    if (!node)
+        return nullptr;
+    auto renderer = node->renderer();
+    if (!renderer)
+        return nullptr;
+
+    VisiblePosition position;
+    RefPtr<Range> contextRange;
+
+    if (!is<HTMLTextFormControlElement>(*node)) {
+        position = renderer->positionForPoint(hitTestResult.localPoint(), nullptr);
+        if (position.isNull())
+            position = firstPositionInOrBeforeNode(node);
+
+        contextRange = rangeExpandedAroundPositionByCharacters(position, 250);
+        if (!contextRange)
+            return nullptr;
+    } else {
+        Frame* frame = node->document().frame();
+        if (!frame)
+            return nullptr;
+
+        IntPoint framePoint = hitTestResult.roundedPointInInnerNodeFrame();
+        if (!frame->rangeForPoint(framePoint))
+            return nullptr;
+
+        VisiblePosition position = frame->visiblePositionForPoint(framePoint);
+        if (position.isNull())
+            return nullptr;
+
+        contextRange = enclosingTextUnitOfGranularity(position, LineGranularity, DirectionForward);
+        if (!contextRange)
+            return nullptr;
+    }
+
+    return detectItemAtPositionWithRange(position, contextRange, detectedDataBoundingBox, detectedDataRange);
+}
+#endif // PLATFORM(MAC)
+
+void DataDetection::detectContentInRange(RefPtr<Range>&, DataDetectorTypes)
+{
+}
+
+} // namespace WebCore

Deleted: trunk/Source/WebCore/editing/mac/DataDetection.h (195316 => 195317)


--- trunk/Source/WebCore/editing/mac/DataDetection.h	2016-01-19 22:37:02 UTC (rev 195316)
+++ trunk/Source/WebCore/editing/mac/DataDetection.h	2016-01-19 22:58:59 UTC (rev 195317)
@@ -1,51 +0,0 @@
-/*
- * Copyright (C) 2014 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef DataDetection_h
-#define DataDetection_h
-
-#if PLATFORM(MAC)
-
-#import <wtf/RefPtr.h>
-#import <wtf/RetainPtr.h>
-
-OBJC_CLASS DDActionContext;
-
-namespace WebCore {
-
-class FloatRect;
-class HitTestResult;
-class Range;
-
-class DataDetection {
-public:
-    WEBCORE_EXPORT static RetainPtr<DDActionContext> detectItemAroundHitTestResult(const HitTestResult&, FloatRect& detectedDataBoundingBox, RefPtr<Range>& detectedDataRange);
-};
-
-} // namespace WebCore
-
-#endif // PLATFORM(MAC)
-
-#endif // DataDetection_h

Deleted: trunk/Source/WebCore/editing/mac/DataDetection.mm (195316 => 195317)


--- trunk/Source/WebCore/editing/mac/DataDetection.mm	2016-01-19 22:37:02 UTC (rev 195316)
+++ trunk/Source/WebCore/editing/mac/DataDetection.mm	2016-01-19 22:58:59 UTC (rev 195317)
@@ -1,137 +0,0 @@
-/*
- * Copyright (C) 2014 Apple, Inc.  All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import "config.h"
-#import "DataDetection.h"
-
-#if PLATFORM(MAC)
-
-#import "DataDetectorsSPI.h"
-#import "FrameView.h"
-#import "HTMLTextFormControlElement.h"
-#import "HitTestResult.h"
-#import "Node.h"
-#import "Range.h"
-#import "RenderObject.h"
-#import "TextIterator.h"
-#import "VisiblePosition.h"
-#import "VisibleUnits.h"
-#import "htmlediting.h"
-
-namespace WebCore {
-
-static RetainPtr<DDActionContext> detectItemAtPositionWithRange(VisiblePosition position, RefPtr<Range> contextRange, FloatRect& detectedDataBoundingBox, RefPtr<Range>& detectedDataRange)
-{
-    String fullPlainTextString = plainText(contextRange.get());
-    int hitLocation = TextIterator::rangeLength(makeRange(contextRange->startPosition(), position).get());
-
-    RetainPtr<DDScannerRef> scanner = adoptCF(DDScannerCreate(DDScannerTypeStandard, 0, nullptr));
-    RetainPtr<DDScanQueryRef> scanQuery = adoptCF(DDScanQueryCreateFromString(kCFAllocatorDefault, fullPlainTextString.createCFString().get(), CFRangeMake(0, fullPlainTextString.length())));
-
-    if (!DDScannerScanQuery(scanner.get(), scanQuery.get()))
-        return nullptr;
-
-    RetainPtr<CFArrayRef> results = adoptCF(DDScannerCopyResultsWithOptions(scanner.get(), DDScannerCopyResultsOptionsNoOverlap));
-
-    // Find the DDResultRef that intersects the hitTestResult's VisiblePosition.
-    DDResultRef mainResult = nullptr;
-    RefPtr<Range> mainResultRange;
-    CFIndex resultCount = CFArrayGetCount(results.get());
-    for (CFIndex i = 0; i < resultCount; i++) {
-        DDResultRef result = (DDResultRef)CFArrayGetValueAtIndex(results.get(), i);
-        CFRange resultRangeInContext = DDResultGetRange(result);
-        if (hitLocation >= resultRangeInContext.location && (hitLocation - resultRangeInContext.location) < resultRangeInContext.length) {
-            mainResult = result;
-            mainResultRange = TextIterator::subrange(contextRange.get(), resultRangeInContext.location, resultRangeInContext.length);
-            break;
-        }
-    }
-
-    if (!mainResult)
-        return nullptr;
-
-    RetainPtr<DDActionContext> actionContext = adoptNS([allocDDActionContextInstance() init]);
-    [actionContext setAllResults:@[ (id)mainResult ]];
-    [actionContext setMainResult:mainResult];
-
-    Vector<FloatQuad> quads;
-    mainResultRange->absoluteTextQuads(quads);
-    detectedDataBoundingBox = FloatRect();
-    FrameView* frameView = mainResultRange->ownerDocument().view();
-    for (const auto& quad : quads)
-        detectedDataBoundingBox.unite(frameView->contentsToWindow(quad.enclosingBoundingBox()));
-    
-    detectedDataRange = mainResultRange;
-    
-    return actionContext;
-}
-
-RetainPtr<DDActionContext> DataDetection::detectItemAroundHitTestResult(const HitTestResult& hitTestResult, FloatRect& detectedDataBoundingBox, RefPtr<Range>& detectedDataRange)
-{
-    if (!DataDetectorsLibrary())
-        return nullptr;
-
-    Node* node = hitTestResult.innerNonSharedNode();
-    if (!node)
-        return nullptr;
-    auto renderer = node->renderer();
-    if (!renderer)
-        return nullptr;
-
-    VisiblePosition position;
-    RefPtr<Range> contextRange;
-
-    if (!is<HTMLTextFormControlElement>(*node)) {
-        position = renderer->positionForPoint(hitTestResult.localPoint(), nullptr);
-        if (position.isNull())
-            position = firstPositionInOrBeforeNode(node);
-
-        contextRange = rangeExpandedAroundPositionByCharacters(position, 250);
-        if (!contextRange)
-            return nullptr;
-    } else {
-        Frame* frame = node->document().frame();
-        if (!frame)
-            return nullptr;
-
-        IntPoint framePoint = hitTestResult.roundedPointInInnerNodeFrame();
-        if (!frame->rangeForPoint(framePoint))
-            return nullptr;
-
-        VisiblePosition position = frame->visiblePositionForPoint(framePoint);
-        if (position.isNull())
-            return nullptr;
-
-        contextRange = enclosingTextUnitOfGranularity(position, LineGranularity, DirectionForward);
-        if (!contextRange)
-            return nullptr;
-    }
-
-    return detectItemAtPositionWithRange(position, contextRange, detectedDataBoundingBox, detectedDataRange);
-}
-
-} // namespace WebCore
-
-#endif // PLATFORM(MAC)

Modified: trunk/Source/WebCore/loader/FrameLoader.cpp (195316 => 195317)


--- trunk/Source/WebCore/loader/FrameLoader.cpp	2016-01-19 22:37:02 UTC (rev 195316)
+++ trunk/Source/WebCore/loader/FrameLoader.cpp	2016-01-19 22:58:59 UTC (rev 195317)
@@ -125,6 +125,10 @@
 #include "Archive.h"
 #endif
 
+#if ENABLE(DATA_DETECTION)
+#include "DataDetection.h"
+#endif
+
 #if PLATFORM(IOS)
 #include "DocumentType.h"
 #include "MemoryPressureHandler.h"
@@ -2277,6 +2281,12 @@
             } else {
                 m_client.dispatchDidFinishLoad();
                 loadingEvent = AXObjectCache::AXLoadingFinished;
+#if ENABLE(DATA_DETECTION)
+                if (m_frame.settings().dataDetectorTypes() != DataDetectorTypeNone) {
+                    RefPtr<Range> documentRange = makeRange(firstPositionInNode(m_frame.document()->documentElement()), lastPositionInNode(m_frame.document()->documentElement()));
+                    DataDetection::detectContentInRange(documentRange, m_frame.settings().dataDetectorTypes());
+                }
+#endif
             }
 
             // Notify accessibility.

Modified: trunk/Source/WebCore/page/Settings.h (195316 => 195317)


--- trunk/Source/WebCore/page/Settings.h	2016-01-19 22:37:02 UTC (rev 195316)
+++ trunk/Source/WebCore/page/Settings.h	2016-01-19 22:58:59 UTC (rev 195317)
@@ -42,6 +42,10 @@
 #include <wtf/text/AtomicString.h>
 #include <wtf/text/AtomicStringHash.h>
 
+#if ENABLE(DATA_DETECTION)
+#include "DataDetection.h"
+#endif
+
 namespace WebCore {
 
 class FontGenericFamilies;

Modified: trunk/Source/WebCore/page/Settings.in (195316 => 195317)


--- trunk/Source/WebCore/page/Settings.in	2016-01-19 22:37:02 UTC (rev 195316)
+++ trunk/Source/WebCore/page/Settings.in	2016-01-19 22:58:59 UTC (rev 195317)
@@ -228,6 +228,7 @@
 temporaryTileCohortRetentionEnabled initial=true
 
 useImageDocumentForSubframePDF initial=false
+dataDetectorTypes type=DataDetectorTypes, initial=DataDetectorTypeNone, conditional=DATA_DETECTION
 
 # Allow SourceBuffers to store up to 304MB each, enough for approximately five minutes
 # of 1080p video and stereo audio.

Modified: trunk/Source/WebCore/platform/spi/mac/DataDetectorsSPI.h (195316 => 195317)


--- trunk/Source/WebCore/platform/spi/mac/DataDetectorsSPI.h	2016-01-19 22:37:02 UTC (rev 195316)
+++ trunk/Source/WebCore/platform/spi/mac/DataDetectorsSPI.h	2016-01-19 22:58:59 UTC (rev 195317)
@@ -25,11 +25,12 @@
 
 #import <wtf/Platform.h>
 
-#if PLATFORM(MAC)
 
 #import <WebCore/DataDetectorsCoreSPI.h>
 #import <WebCore/SoftLinking.h>
 
+#if PLATFORM(MAC)
+
 #if USE(APPLE_INTERNAL_SDK)
 
 // Can't include DDAction.h because as of this writing it is a private header that includes a non-private header with an "" include.

Modified: trunk/Source/WebKit/mac/ChangeLog (195316 => 195317)


--- trunk/Source/WebKit/mac/ChangeLog	2016-01-19 22:37:02 UTC (rev 195316)
+++ trunk/Source/WebKit/mac/ChangeLog	2016-01-19 22:58:59 UTC (rev 195317)
@@ -1,3 +1,15 @@
+2016-01-19  Enrica Casucci  <[email protected]>
+
+        Add support for DataDetectors in WK (iOS).
+        https://bugs.webkit.org/show_bug.cgi?id=152989
+        rdar://problem/22855960
+
+        Reviewed by Tim Horton.
+
+        Adding feature definition for data detection.
+
+        * Configurations/FeatureDefines.xcconfig:
+
 2016-01-19  Commit Queue  <[email protected]>
 
         Unreviewed, rolling out r195300.

Modified: trunk/Source/WebKit/mac/Configurations/FeatureDefines.xcconfig (195316 => 195317)


--- trunk/Source/WebKit/mac/Configurations/FeatureDefines.xcconfig	2016-01-19 22:37:02 UTC (rev 195316)
+++ trunk/Source/WebKit/mac/Configurations/FeatureDefines.xcconfig	2016-01-19 22:58:59 UTC (rev 195317)
@@ -111,6 +111,7 @@
 ENABLE_MAC_GESTURE_EVENTS_macosx_WITH_INTERNAL_SDK_YES = ENABLE_MAC_GESTURE_EVENTS;
 
 ENABLE_IOS_TEXT_AUTOSIZING[sdk=iphone*] = ENABLE_IOS_TEXT_AUTOSIZING;
+ENABLE_DATA_DETECTION = ENABLE_DATA_DETECTION;
 
 ENABLE_IOS_TOUCH_EVENTS[sdk=iphone*] = $(ENABLE_IOS_TOUCH_EVENTS_ios_WITH_INTERNAL_SDK_$(USE_INTERNAL_SDK));
 ENABLE_IOS_TOUCH_EVENTS_ios_WITH_INTERNAL_SDK_YES = ENABLE_IOS_TOUCH_EVENTS;

Modified: trunk/Source/WebKit2/ChangeLog (195316 => 195317)


--- trunk/Source/WebKit2/ChangeLog	2016-01-19 22:37:02 UTC (rev 195316)
+++ trunk/Source/WebKit2/ChangeLog	2016-01-19 22:58:59 UTC (rev 195317)
@@ -1,3 +1,27 @@
+2016-01-19  Enrica Casucci  <[email protected]>
+
+        Add support for DataDetectors in WK (iOS).
+        https://bugs.webkit.org/show_bug.cgi?id=152989
+        rdar://problem/22855960
+
+        Reviewed by Tim Horton.
+
+        This is the first step toward implementing Data Detectors support
+        in WK2. The patch adds a new property to the configuration
+        object to indicate the type of detection desired and propagates
+        to the WebProcess.
+
+        * Configurations/FeatureDefines.xcconfig:
+        * Shared/WebPreferencesDefinitions.h:
+        * UIProcess/API/Cocoa/WKWebView.mm:
+        (fromWKDataDetectorTypes):
+        (-[WKWebView initWithFrame:configuration:]):
+        * UIProcess/API/Cocoa/WKWebViewConfiguration.h:
+        * UIProcess/API/Cocoa/WKWebViewConfiguration.mm:
+        (-[WKWebViewConfiguration copyWithZone:]):
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::updatePreferences):
+
 2016-01-19  Commit Queue  <[email protected]>
 
         Unreviewed, rolling out r195300.

Modified: trunk/Source/WebKit2/Configurations/FeatureDefines.xcconfig (195316 => 195317)


--- trunk/Source/WebKit2/Configurations/FeatureDefines.xcconfig	2016-01-19 22:37:02 UTC (rev 195316)
+++ trunk/Source/WebKit2/Configurations/FeatureDefines.xcconfig	2016-01-19 22:58:59 UTC (rev 195317)
@@ -111,6 +111,7 @@
 ENABLE_MAC_GESTURE_EVENTS_macosx_WITH_INTERNAL_SDK_YES = ENABLE_MAC_GESTURE_EVENTS;
 
 ENABLE_IOS_TEXT_AUTOSIZING[sdk=iphone*] = ENABLE_IOS_TEXT_AUTOSIZING;
+ENABLE_DATA_DETECTION = ENABLE_DATA_DETECTION;
 
 ENABLE_IOS_TOUCH_EVENTS[sdk=iphone*] = $(ENABLE_IOS_TOUCH_EVENTS_ios_WITH_INTERNAL_SDK_$(USE_INTERNAL_SDK));
 ENABLE_IOS_TOUCH_EVENTS_ios_WITH_INTERNAL_SDK_YES = ENABLE_IOS_TOUCH_EVENTS;

Modified: trunk/Source/WebKit2/Shared/WebPreferencesDefinitions.h (195316 => 195317)


--- trunk/Source/WebKit2/Shared/WebPreferencesDefinitions.h	2016-01-19 22:37:02 UTC (rev 195316)
+++ trunk/Source/WebKit2/Shared/WebPreferencesDefinitions.h	2016-01-19 22:58:59 UTC (rev 195317)
@@ -239,6 +239,7 @@
     macro(InspectorAttachmentSide, inspectorAttachmentSide, UInt32, uint32_t, 0) \
     macro(StorageBlockingPolicy, storageBlockingPolicy, UInt32, uint32_t, WebCore::SecurityOrigin::BlockThirdPartyStorage) \
     macro(_javascript_RuntimeFlags, _javascript_RuntimeFlags, UInt32, uint32_t, 0) \
+    macro(DataDetectorTypes, dataDetectorTypes, UInt32, uint32_t, 0) \
     \
 
 #define FOR_EACH_WEBKIT_DEBUG_BOOL_PREFERENCE(macro) \

Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm (195316 => 195317)


--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm	2016-01-19 22:37:02 UTC (rev 195316)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm	2016-01-19 22:58:59 UTC (rev 195317)
@@ -314,6 +314,28 @@
 
 #endif
 
+#if ENABLE(DATA_DETECTION)
+static WebCore::DataDetectorTypes fromWKDataDetectorTypes(uint32_t types)
+{
+    if (static_cast<WKDataDetectorTypes>(types) == WKDataDetectorTypeNone)
+        return WebCore::DataDetectorTypeNone;
+    if (static_cast<WKDataDetectorTypes>(types) == WKDataDetectorTypeAll)
+        return WebCore::DataDetectorTypeAll;
+    
+    uint32_t value = WebCore::DataDetectorTypeNone;
+    if (types & WKDataDetectorTypePhoneNumber)
+        value |= WebCore::DataDetectorTypePhoneNumber;
+    if (types & WKDataDetectorTypeLink)
+        value |= WebCore::DataDetectorTypeLink;
+    if (types & WKDataDetectorTypeAddress)
+        value |= WebCore::DataDetectorTypeAddress;
+    if (types & WKDataDetectorTypeCalendarEvent)
+        value |= WebCore::DataDetectorTypeCalendarEvent;
+    
+    return static_cast<WebCore::DataDetectorTypes>(value);
+}
+#endif
+
 - (instancetype)initWithFrame:(CGRect)frame configuration:(WKWebViewConfiguration *)configuration
 {
     if (!(self = [super initWithFrame:frame]))
@@ -383,6 +405,9 @@
     pageConfiguration->preferenceValues().set(WebKit::WebPreferencesKey::invisibleAutoplayNotPermittedKey(), WebKit::WebPreferencesStore::Value(!![_configuration _invisibleAutoplayNotPermitted]));
     pageConfiguration->preferenceValues().set(WebKit::WebPreferencesKey::mediaDataLoadsAutomaticallyKey(), WebKit::WebPreferencesStore::Value(!![_configuration _mediaDataLoadsAutomatically]));
 #endif
+#if ENABLE(DATA_DETECTION)
+    pageConfiguration->preferenceValues().set(WebKit::WebPreferencesKey::dataDetectorTypesKey(), WebKit::WebPreferencesStore::Value(static_cast<uint32_t>(fromWKDataDetectorTypes([_configuration dataDetectorTypes]))));
+#endif
 #if ENABLE(WIRELESS_PLAYBACK_TARGET)
     pageConfiguration->preferenceValues().set(WebKit::WebPreferencesKey::allowsAirPlayForMediaPlaybackKey(), WebKit::WebPreferencesStore::Value(!![_configuration allowsAirPlayForMediaPlayback]));
 #endif

Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewConfiguration.h (195316 => 195317)


--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewConfiguration.h	2016-01-19 22:37:02 UTC (rev 195316)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewConfiguration.h	2016-01-19 22:58:59 UTC (rev 195317)
@@ -51,6 +51,25 @@
 } WK_ENUM_AVAILABLE_IOS(8_0);
 #endif
 
+/*! @enum WKDataDetectorTypes
+ @abstract The type of data detected.
+ @constant WKDataDetectorTypeNone No detection is performed.
+ @constant WKDataDetectorTypePhoneNumber Phone numbers are detected and turned into links.
+ @constant WKDataDetectorTypeLink URLs in text are detected and turned into links.
+ @constant WKDataDetectorTypeAddress Addresses are detected and turned into links.
+ @constant WKDataDetectorTypeCalendarEvent Dates and times that are in the future are detected and turned into links.
+ @constant WKDataDetectorTypeAll All of the above data types are turned into links when detected. Choosing this value will
+ automatically include any new detection type that is added.
+ */
+typedef NS_OPTIONS(NSUInteger, WKDataDetectorTypes) {
+    WKDataDetectorTypeNone = 0,
+    WKDataDetectorTypePhoneNumber = 1 << 0,
+    WKDataDetectorTypeLink = 1 << 1,
+    WKDataDetectorTypeAddress = 1 << 2,
+    WKDataDetectorTypeCalendarEvent = 1 << 3,
+    WKDataDetectorTypeAll = NSUIntegerMax
+} WK_ENUM_AVAILABLE(WK_MAC_TBA, WK_IOS_TBA);
+
 /*! A WKWebViewConfiguration object is a collection of properties with
  which to initialize a web view.
  @helps Contains properties used to configure a @link WKWebView @/link.
@@ -93,6 +112,15 @@
  */
 @property (nonatomic) BOOL allowsAirPlayForMediaPlayback WK_AVAILABLE(10_11, 9_0);
 
+/*! @abstract An enum value indicating the type of data detection desired.
+ @discussion The default value is WKDataDetectorTypeNone.
+ An example of how this property may affect the content loaded in the WKWebView is that content like
+ 'Visit apple.com on July 4th or call 1 800 555-5545' will be transformed to add links around 'apple.com', 'July 4th' and '1 800 555-5545'
+ if the dataDetectorTypes property is set to WKDataDetectorTypePhoneNumber | WKDataDetectorTypeLink | WKDataDetectorTypeCalendarEvent.
+
+ */
+@property (nonatomic) WKDataDetectorTypes dataDetectorTypes WK_AVAILABLE(WK_MAC_TBA, WK_IOS_TBA);
+
 #if TARGET_OS_IPHONE
 /*! @abstract A Boolean value indicating whether HTML5 videos play inline
  (YES) or use the native full-screen controller (NO).

Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewConfiguration.mm (195316 => 195317)


--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewConfiguration.mm	2016-01-19 22:37:02 UTC (rev 195316)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewConfiguration.mm	2016-01-19 22:58:59 UTC (rev 195317)
@@ -198,6 +198,9 @@
     configuration->_serviceControlsEnabled = self->_serviceControlsEnabled;
     configuration->_imageControlsEnabled = self->_imageControlsEnabled;
 #endif
+#if ENABLE(DATA_DETECTION)
+    configuration->_dataDetectorTypes = self->_dataDetectorTypes;
+#endif
 #if ENABLE(WIRELESS_TARGET_PLAYBACK)
     configuration->_allowsAirPlayForMediaPlayback = self->_allowsAirPlayForMediaPlayback;
 #endif

Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp (195316 => 195317)


--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp	2016-01-19 22:37:02 UTC (rev 195316)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp	2016-01-19 22:58:59 UTC (rev 195317)
@@ -219,6 +219,10 @@
 #include "CoordinatedLayerTreeHostMessages.h"
 #endif
 
+#if ENABLE(DATA_DETECTION)
+#include <WebCore/DataDetection.h>
+#endif
+
 #if ENABLE(VIDEO) && USE(GSTREAMER)
 #include <WebCore/MediaPlayerRequestInstallMissingPluginsCallback.h>
 #endif
@@ -2935,6 +2939,9 @@
     settings.setUseImageDocumentForSubframePDF(true);
 #endif
 
+#if ENABLE(DATA_DETECTION)
+    settings.setDataDetectorTypes(static_cast<DataDetectorTypes>(store.getUInt32ValueForKey(WebPreferencesKey::dataDetectorTypesKey())));
+#endif
 #if ENABLE(GAMEPAD)
     RuntimeEnabledFeatures::sharedFeatures().setGamepadsEnabled(store.getBoolValueForKey(WebPreferencesKey::gamepadsEnabledKey()));
 #endif
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to