Move DataDetectors scanning code to WebCore
authortimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 14 Nov 2014 21:33:03 +0000 (21:33 +0000)
committertimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 14 Nov 2014 21:33:03 +0000 (21:33 +0000)
https://bugs.webkit.org/show_bug.cgi?id=138731
<rdar://problem/18877535>

Reviewed by Anders Carlsson.

Move DataDetectors scanning code to WebCore, so that both WebKits can use it.

* Shared/TextIndicator.cpp:
(WebKit::TextIndicator::createWithRange):
Move createWithRange in from WebPageMac's textIndicatorForRange.

(WebKit::TextIndicator::createWithSelectionInFrame):
* Shared/TextIndicator.h:
* WebProcess/WebPage/WebFrame.cpp:
(WebKit::WebFrame::createSelectionSnapshot):
* WebProcess/WebPage/WebFrame.h:
Constify some things.

* WebProcess/WebPage/mac/WebPageMac.mm:
(WebKit::WebPage::performActionMenuHitTestAtLocation):
Avoid using the DD result if it didn't come with a non-null Range.
Make use of detectItemAroundHitTestResult and TextIndicator::createWithRange.

(WebKit::scanForDataDetectedItems): Deleted.
(WebKit::textIndicatorForRange): Deleted.
Moved these two to other places.

* WebCore.exp.in:
Export our new function.

* WebCore.xcodeproj/project.pbxproj:
Add DataDetection.{mm, h}
Adjust the project so that editing/mac actually points to editing/mac instead of editing/

* editing/mac/DictionaryLookup.h:
* editing/mac/DictionaryLookup.mm:
Swap to PLATFORM(MAC) instead of !PLATFORM(IOS).
Move DictionaryLookup.{mm, h} to editing/mac, where they were in the project but not on disk.

* editing/mac/DataDetection.h: Added.
* editing/mac/DataDetection.mm: Added.
(WebCore::DataDetection::detectItemAroundHitTestResult):
Moved from WebKit2.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@176137 268f45cc-cd09-0410-ab3c-d52691b4dbfc

13 files changed:
Source/WebCore/ChangeLog
Source/WebCore/WebCore.exp.in
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/editing/mac/DataDetection.h [new file with mode: 0644]
Source/WebCore/editing/mac/DataDetection.mm [new file with mode: 0644]
Source/WebCore/editing/mac/DictionaryLookup.h [moved from Source/WebCore/editing/DictionaryLookup.h with 98% similarity]
Source/WebCore/editing/mac/DictionaryLookup.mm [moved from Source/WebCore/editing/DictionaryLookup.mm with 99% similarity]
Source/WebKit2/ChangeLog
Source/WebKit2/Shared/TextIndicator.cpp
Source/WebKit2/Shared/TextIndicator.h
Source/WebKit2/WebProcess/WebPage/WebFrame.cpp
Source/WebKit2/WebProcess/WebPage/WebFrame.h
Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm

index 4c0df26d965e46d08874900fc0957638d6574279..a0ea840e9e877e204b8b83670daff67fedaf80d0 100644 (file)
@@ -1,3 +1,28 @@
+2014-11-14  Tim Horton  <timothy_horton@apple.com>
+
+        Move DataDetectors scanning code to WebCore
+        https://bugs.webkit.org/show_bug.cgi?id=138731
+        <rdar://problem/18877535>
+
+        Reviewed by Anders Carlsson.
+
+        * WebCore.exp.in:
+        Export our new function.
+
+        * WebCore.xcodeproj/project.pbxproj:
+        Add DataDetection.{mm, h}
+        Adjust the project so that editing/mac actually points to editing/mac instead of editing/
+
+        * editing/mac/DictionaryLookup.h:
+        * editing/mac/DictionaryLookup.mm:
+        Swap to PLATFORM(MAC) instead of !PLATFORM(IOS).
+        Move DictionaryLookup.{mm, h} to editing/mac, where they were in the project but not on disk.
+
+        * editing/mac/DataDetection.h: Added.
+        * editing/mac/DataDetection.mm: Added.
+        (WebCore::DataDetection::detectItemAroundHitTestResult):
+        Moved from WebKit2.
+
 2014-11-14  Dan Bernstein  <mitz@apple.com>
 
         <rdar://problem/18978497> Wrong (off-by-1) navigation snapshots shown after a mix of gesture and button back/forward navigation
index 1d3944c8ceb1f385ca9388633586ca96100a6128..a3cf4759ff83eba4ad281cfd25f46561f0fea1d2 100644 (file)
@@ -288,6 +288,7 @@ __ZN7WebCore13AXObjectCache42gAccessibilityEnhancedUserInterfaceEnabledE
 __ZN7WebCore13CharacterData7setDataERKN3WTF6StringERi
 __ZN7WebCore13ContainerNode11appendChildEN3WTF10PassRefPtrINS_4NodeEEERi
 __ZN7WebCore13ContainerNode11removeChildEPNS_4NodeERi
+__ZN7WebCore13DataDetection29detectItemAroundHitTestResultERKNS_13HitTestResultERNS_9FloatRectERN3WTF6RefPtrINS_5RangeEEE
 __ZN7WebCore13GraphicsLayer11setChildrenERKN3WTF6VectorIPS0_Lm0ENS1_15CrashOnOverflowEEE
 __ZN7WebCore13GraphicsLayer12replaceChildEPS0_S1_
 __ZN7WebCore13GraphicsLayer12setZPositionEf
@@ -2404,6 +2405,7 @@ __ZN7WebCore6Editor33toggleAutomaticSpellingCorrectionEv
 __ZN7WebCore6Editor34isAutomaticDashSubstitutionEnabledEv
 __ZN7WebCore6Editor35isAutomaticQuoteSubstitutionEnabledEv
 __ZN7WebCore6Editor36isAutomaticSpellingCorrectionEnabledEv
+__ZN7WebCore6Editor9copyImageERKNS_13HitTestResultE
 __ZN7WebCore6Widget17setPlatformWidgetEP6NSView
 __ZN7WebCore6WidgetC2EP6NSView
 __ZN7WebCore7nsColorERKNS_5ColorE
@@ -2507,10 +2509,6 @@ _wkNSReboundDeltaForElasticDelta
 _wkCreateMemoryStatusPressureCriticalDispatchOnMainQueue
 #endif
 
-#if !PLATFORM(IOS)
-__ZN7WebCore6Editor9copyImageERKNS_13HitTestResultE
-#endif
-
 #if PLATFORM(IOS)
 .objc_class_name_NSCursor
 .objc_class_name_WAKClipView
index c9308bf93376bb32c462d0b34442a8660bd064c9..dc4571e7efec353f33796645812efdc48b656abe 100644 (file)
                2D481F02146B5C5500AA7834 /* CrossfadeGeneratedImage.h in Headers */ = {isa = PBXBuildFile; fileRef = 2D2FC0551460CD6F00263633 /* CrossfadeGeneratedImage.h */; };
                2D481F03146B5C6500AA7834 /* GradientImage.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2D2FC0561460CD6F00263633 /* GradientImage.cpp */; };
                2D481F04146B5C6B00AA7834 /* GradientImage.h in Headers */ = {isa = PBXBuildFile; fileRef = 2D2FC0571460CD6F00263633 /* GradientImage.h */; };
+               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, ); }; };
                293EAE1E1356B2FE0067ACF9 /* RuntimeApplicationChecks.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RuntimeApplicationChecks.h; sourceTree = "<group>"; };
                293EAE201356B32E0067ACF9 /* RuntimeApplicationChecks.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RuntimeApplicationChecks.cpp; sourceTree = "<group>"; };
                29489FC512C00F0300D83F0F /* AccessibilityScrollView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AccessibilityScrollView.h; sourceTree = "<group>"; };
-               29498681195341940072D2BD /* TextUndoInsertionMarkupMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = TextUndoInsertionMarkupMac.mm; path = mac/TextUndoInsertionMarkupMac.mm; sourceTree = "<group>"; };
+               29498681195341940072D2BD /* TextUndoInsertionMarkupMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = TextUndoInsertionMarkupMac.mm; sourceTree = "<group>"; };
                297BE3D916C043D8003316BD /* PlatformSpeechSynthesizer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PlatformSpeechSynthesizer.cpp; sourceTree = "<group>"; };
                2981CA9D131822EC00D12F2A /* AccessibilityARIAGrid.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = AccessibilityARIAGrid.cpp; sourceTree = "<group>"; };
                2981CA9E131822EC00D12F2A /* AccessibilityARIAGridCell.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = AccessibilityARIAGridCell.cpp; sourceTree = "<group>"; };
                29E04A27BED2F81F98E9022B /* JSBeforeUnloadEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSBeforeUnloadEvent.h; sourceTree = "<group>"; };
                29E4D8DF16B0940F00C84704 /* PlatformSpeechSynthesizer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PlatformSpeechSynthesizer.h; sourceTree = "<group>"; };
                29E4D8E016B0959800C84704 /* PlatformSpeechSynthesizerMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PlatformSpeechSynthesizerMac.mm; sourceTree = "<group>"; };
-               29FAF4B5195AB08900A522DC /* TextUndoInsertionMarkupMac.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TextUndoInsertionMarkupMac.h; path = mac/TextUndoInsertionMarkupMac.h; sourceTree = "<group>"; };
+               29FAF4B5195AB08900A522DC /* TextUndoInsertionMarkupMac.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextUndoInsertionMarkupMac.h; sourceTree = "<group>"; };
                2B42359F15250F6000DBBCD8 /* RenderSVGEllipse.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderSVGEllipse.cpp; sourceTree = "<group>"; };
                2B4235A015250F6000DBBCD8 /* RenderSVGEllipse.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderSVGEllipse.h; sourceTree = "<group>"; };
                2BE8E2C612A589EC00FAD550 /* HTMLMetaCharsetParser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = HTMLMetaCharsetParser.h; path = parser/HTMLMetaCharsetParser.h; sourceTree = "<group>"; };
                2D3EF4471917915C00034184 /* WebCoreCALayerExtras.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebCoreCALayerExtras.mm; sourceTree = "<group>"; };
                2D46F04D17B96FBD005647F0 /* IntPoint.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = IntPoint.cpp; sourceTree = "<group>"; };
                2D46F04F17B96FD2005647F0 /* IntSize.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = IntSize.cpp; 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>"; };
                4A6E9FC213C17D1D0046A7F8 /* CSSFontFeatureValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSSFontFeatureValue.h; sourceTree = "<group>"; };
                4A6E9FC513C17D570046A7F8 /* FontFeatureSettings.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FontFeatureSettings.cpp; sourceTree = "<group>"; };
                4A6E9FC613C17D570046A7F8 /* FontFeatureSettings.h */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.h; fileEncoding = 4; path = FontFeatureSettings.h; sourceTree = "<group>"; };
-               4A8C96EA0BE69032004EEFF0 /* FrameSelectionMac.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; name = FrameSelectionMac.mm; path = mac/FrameSelectionMac.mm; sourceTree = "<group>"; };
+               4A8C96EA0BE69032004EEFF0 /* FrameSelectionMac.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = FrameSelectionMac.mm; sourceTree = "<group>"; };
                4A9755351858ED9B00BD6D15 /* RTCPeerConnectionErrorCallback.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RTCPeerConnectionErrorCallback.h; sourceTree = "<group>"; };
                4A9755361858ED9B00BD6D15 /* RTCPeerConnectionErrorCallback.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = RTCPeerConnectionErrorCallback.idl; sourceTree = "<group>"; };
                4A9CC81516BB9AC600EC645A /* CSSDefaultStyleSheets.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CSSDefaultStyleSheets.cpp; sourceTree = "<group>"; };
                CE08C3D0152B599A0021B8C2 /* AlternativeTextController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AlternativeTextController.h; sourceTree = "<group>"; };
                CE5CB1B314EDAB6F00BB2795 /* EventSender.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EventSender.h; sourceTree = "<group>"; };
                CE6D89294C7AACE0AD89B3DD /* MathMLMencloseElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MathMLMencloseElement.h; sourceTree = "<group>"; };
-               CE7B2DAF1586ABAD0098B3FA /* AlternativeTextUIController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AlternativeTextUIController.h; path = mac/AlternativeTextUIController.h; sourceTree = "<group>"; };
-               CE7B2DB01586ABAD0098B3FA /* AlternativeTextUIController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = AlternativeTextUIController.mm; path = mac/AlternativeTextUIController.mm; sourceTree = "<group>"; };
-               CE7B2DB11586ABAD0098B3FA /* TextAlternativeWithRange.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TextAlternativeWithRange.h; path = mac/TextAlternativeWithRange.h; sourceTree = "<group>"; };
-               CE7B2DB21586ABAD0098B3FA /* TextAlternativeWithRange.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = TextAlternativeWithRange.mm; path = mac/TextAlternativeWithRange.mm; sourceTree = "<group>"; };
+               CE7B2DAF1586ABAD0098B3FA /* AlternativeTextUIController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AlternativeTextUIController.h; sourceTree = "<group>"; };
+               CE7B2DB01586ABAD0098B3FA /* AlternativeTextUIController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = AlternativeTextUIController.mm; sourceTree = "<group>"; };
+               CE7B2DB11586ABAD0098B3FA /* TextAlternativeWithRange.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextAlternativeWithRange.h; sourceTree = "<group>"; };
+               CE7B2DB21586ABAD0098B3FA /* TextAlternativeWithRange.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = TextAlternativeWithRange.mm; sourceTree = "<group>"; };
                CE8245EF19B671BA00AC0122 /* CFNetworkConnectionCacheSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CFNetworkConnectionCacheSPI.h; sourceTree = "<group>"; };
                CE8245F119B671D500AC0122 /* CFURLRequestSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CFURLRequestSPI.h; sourceTree = "<group>"; };
                CECADFC2153778FF00E37068 /* DictationAlternative.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DictationAlternative.cpp; sourceTree = "<group>"; };
                EBF5121A1696496C0056BD25 /* JSTypeConversions.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSTypeConversions.cpp; sourceTree = "<group>"; };
                EBF5121B1696496C0056BD25 /* JSTypeConversions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSTypeConversions.h; sourceTree = "<group>"; };
                ED2BA83B09A24B91006C0AC4 /* DocumentMarker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DocumentMarker.h; sourceTree = "<group>"; };
-               ED501DC50B249F2900AE18D9 /* EditorMac.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; name = EditorMac.mm; path = mac/EditorMac.mm; sourceTree = "<group>"; };
+               ED501DC50B249F2900AE18D9 /* EditorMac.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = EditorMac.mm; sourceTree = "<group>"; };
                EDE3A4FF0C7A430600956A37 /* ColorMac.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ColorMac.h; sourceTree = "<group>"; };
                EDEC98020AED7E170059137F /* WebCorePrefix.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = WebCorePrefix.h; sourceTree = "<group>"; tabWidth = 4; usesTabs = 0; };
                F12171F316A8BC63000053CA /* WebVTTElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebVTTElement.cpp; sourceTree = "<group>"; };
                        children = (
                                CE7B2DAF1586ABAD0098B3FA /* AlternativeTextUIController.h */,
                                CE7B2DB01586ABAD0098B3FA /* AlternativeTextUIController.mm */,
+                               2D58D8531A15F65F00A5F726 /* DataDetection.h */,
+                               2D58D8541A15F65F00A5F726 /* DataDetection.mm */,
                                937FF3D41A1012D6008EBA31 /* DictionaryLookup.h */,
                                937FF3D61A10131B008EBA31 /* DictionaryLookup.mm */,
                                ED501DC50B249F2900AE18D9 /* EditorMac.mm */,
                                29FAF4B5195AB08900A522DC /* TextUndoInsertionMarkupMac.h */,
                                29498681195341940072D2BD /* TextUndoInsertionMarkupMac.mm */,
                        );
-                       name = mac;
+                       path = mac;
                        sourceTree = "<group>";
                };
                F523D18402DE42E8018635CA /* css */ = {
                                B2227A880D00BF220071B782 /* SVGPatternElement.h in Headers */,
                                B2227A8C0D00BF220071B782 /* SVGPointList.h in Headers */,
                                B2227A8F0D00BF220071B782 /* SVGPolyElement.h in Headers */,
+                               2D58D8551A15F65F00A5F726 /* DataDetection.h in Headers */,
                                B2227A910D00BF220071B782 /* SVGPolygonElement.h in Headers */,
                                B2227A940D00BF220071B782 /* SVGPolylineElement.h in Headers */,
                                B2227A970D00BF220071B782 /* SVGPreserveAspectRatio.h in Headers */,
                                84A81F410FC7E02700955300 /* SourceGraphic.cpp in Sources */,
                                076306D717E149CF005A7C4E /* SourceInfo.cpp in Sources */,
                                536D5A25193F40FC00CE4CAB /* SourceSizeList.cpp in Sources */,
+                               2D58D8561A15F65F00A5F726 /* DataDetection.mm in Sources */,
                                D01A27AD10C9BFD800026A42 /* SpaceSplitString.cpp in Sources */,
                                626CDE0E1140424C001E5A68 /* SpatialNavigation.cpp in Sources */,
                                AA2A5AD516A4861400975A25 /* SpeechSynthesis.cpp in Sources */,
diff --git a/Source/WebCore/editing/mac/DataDetection.h b/Source/WebCore/editing/mac/DataDetection.h
new file mode 100644 (file)
index 0000000..f448403
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * 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
diff --git a/Source/WebCore/editing/mac/DataDetection.mm b/Source/WebCore/editing/mac/DataDetection.mm
new file mode 100644 (file)
index 0000000..5676374
--- /dev/null
@@ -0,0 +1,102 @@
+/*
+ * 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 "DataDetectorsSPI.h"
+#import "DictionaryLookup.h"
+#import "FrameView.h"
+#import "HitTestResult.h"
+#import "Node.h"
+#import "Range.h"
+#import "RenderObject.h"
+#import "TextIterator.h"
+#import "VisiblePosition.h"
+#import "htmlediting.h"
+
+namespace WebCore {
+
+RetainPtr<DDActionContext> DataDetection::detectItemAroundHitTestResult(const HitTestResult& hitTestResult, FloatRect& detectedDataBoundingBox, RefPtr<Range>& detectedDataRange)
+{
+    Node* node = hitTestResult.innerNonSharedNode();
+    if (!node)
+        return nullptr;
+    auto renderer = node->renderer();
+    if (!renderer)
+        return nullptr;
+    VisiblePosition position = renderer->positionForPoint(hitTestResult.localPoint(), nullptr);
+    if (position.isNull())
+        position = firstPositionInOrBeforeNode(node);
+
+    RefPtr<Range> contextRange = rangeExpandedAroundPositionByCharacters(position, 250);
+    if (!contextRange)
+        return nullptr;
+
+    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([[getDDActionContextClass() alloc] init]);
+    [actionContext setAllResults:@[ (id)mainResult ]];
+    [actionContext setMainResult:mainResult];
+
+    Vector<FloatQuad> quads;
+    mainResultRange->textQuads(quads);
+    detectedDataBoundingBox = FloatRect();
+    FrameView* frameView = mainResultRange->ownerDocument().view();
+    for (const auto& quad : quads)
+        detectedDataBoundingBox.unite(frameView->contentsToWindow(quad.enclosingBoundingBox()));
+    
+    detectedDataRange = mainResultRange;
+    
+    return actionContext;
+}
+
+} // namespace WebCore
similarity index 98%
rename from Source/WebCore/editing/DictionaryLookup.h
rename to Source/WebCore/editing/mac/DictionaryLookup.h
index 5ed85aa1af07adc9ad450e0dd7459ad9ea219795..2e25da124f5fdf69cb6ba8c22be6b8a8d9345c8e 100644 (file)
@@ -26,7 +26,7 @@
 #ifndef DictionaryLookup_h
 #define DictionaryLookup_h
 
-#if !PLATFORM(IOS)
+#if PLATFORM(MAC)
 
 #include <wtf/PassRefPtr.h>
 
@@ -50,6 +50,6 @@ PassRefPtr<Range> rangeForDictionaryLookupAtHitTestResult(const HitTestResult&,
 
 } // namespace WebCore
 
-#endif // !PLATFORM(IOS)
+#endif // PLATFORM(MAC)
 
 #endif // DictionaryLookup_h
similarity index 99%
rename from Source/WebCore/editing/DictionaryLookup.mm
rename to Source/WebCore/editing/mac/DictionaryLookup.mm
index c4a134bdc7b30c95b8539046b782d5effc7dede7..db642875befe2f839ac63fde445f805b64511244 100644 (file)
@@ -26,7 +26,7 @@
 #import "config.h"
 #import "DictionaryLookup.h"
 
-#if !PLATFORM(IOS)
+#if PLATFORM(MAC)
 
 #import "Document.h"
 #import "FocusController.h"
@@ -166,5 +166,5 @@ PassRefPtr<Range> rangeForDictionaryLookupAtHitTestResult(const HitTestResult& h
 
 } // namespace WebCore
 
-#endif // !PLATFORM(IOS)
+#endif // PLATFORM(MAC)
 
index 467e213644008633718d8680b3770d13cf24ead1..b469a111e2daabe7c91061e8ef5888d58541657e 100644 (file)
@@ -1,3 +1,33 @@
+2014-11-14  Tim Horton  <timothy_horton@apple.com>
+
+        Move DataDetectors scanning code to WebCore
+        https://bugs.webkit.org/show_bug.cgi?id=138731
+        <rdar://problem/18877535>
+
+        Reviewed by Anders Carlsson.
+
+        Move DataDetectors scanning code to WebCore, so that both WebKits can use it.
+
+        * Shared/TextIndicator.cpp:
+        (WebKit::TextIndicator::createWithRange):
+        Move createWithRange in from WebPageMac's textIndicatorForRange.
+
+        (WebKit::TextIndicator::createWithSelectionInFrame):
+        * Shared/TextIndicator.h:
+        * WebProcess/WebPage/WebFrame.cpp:
+        (WebKit::WebFrame::createSelectionSnapshot):
+        * WebProcess/WebPage/WebFrame.h:
+        Constify some things.
+
+        * WebProcess/WebPage/mac/WebPageMac.mm:
+        (WebKit::WebPage::performActionMenuHitTestAtLocation):
+        Avoid using the DD result if it didn't come with a non-null Range.
+        Make use of detectItemAroundHitTestResult and TextIndicator::createWithRange.
+
+        (WebKit::scanForDataDetectedItems): Deleted.
+        (WebKit::textIndicatorForRange): Deleted.
+        Moved these two to other places.
+
 2014-11-14  Dan Bernstein  <mitz@apple.com>
 
         <rdar://problem/18978497> Wrong (off-by-1) navigation snapshots shown after a mix of gesture and button back/forward navigation
index 8aa3ba5044fc9d2bfe8e72180ec4ba3b56f755db..42d8363f17f7ec107b92dcf5cc396582f5034baa 100644 (file)
@@ -36,6 +36,7 @@
 #include "WebCoreArgumentCoders.h"
 #include "WebFrame.h"
 #include "WebPage.h"
+#include <WebCore/Document.h>
 #include <WebCore/Frame.h>
 #include <WebCore/FrameSelection.h>
 #include <WebCore/FrameView.h>
@@ -154,7 +155,24 @@ PassRefPtr<TextIndicator> TextIndicator::create(const TextIndicator::Data& data)
     return adoptRef(new TextIndicator(data));
 }
 
-PassRefPtr<TextIndicator> TextIndicator::createWithSelectionInFrame(WebFrame& frame)
+PassRefPtr<TextIndicator> TextIndicator::createWithRange(const Range& range)
+{
+    Frame* frame = range.startContainer()->document().frame();
+
+    if (!frame)
+        return nullptr;
+
+    VisibleSelection oldSelection = frame->selection().selection();
+    frame->selection().setSelection(&range);
+
+    RefPtr<TextIndicator> indicator = TextIndicator::createWithSelectionInFrame(*WebFrame::fromCoreFrame(*frame));
+
+    frame->selection().setSelection(oldSelection);
+    
+    return indicator.release();
+}
+
+PassRefPtr<TextIndicator> TextIndicator::createWithSelectionInFrame(const WebFrame& frame)
 {
     Frame& coreFrame = *frame.coreFrame();
     IntRect selectionRect = enclosingIntRect(coreFrame.selection().selectionBounds());
index 849958f61c02394914786733488a145c402204d9..72c56d5a512838a7d9103a8bb897a7ef60267e48 100644 (file)
@@ -34,6 +34,7 @@
 
 namespace WebCore {
 class GraphicsContext;
+class Range;
 }
 
 namespace IPC {
@@ -59,7 +60,8 @@ public:
     };
 
     static PassRefPtr<TextIndicator> create(const TextIndicator::Data&);
-    static PassRefPtr<TextIndicator> createWithSelectionInFrame(WebFrame&);
+    static PassRefPtr<TextIndicator> createWithSelectionInFrame(const WebFrame&);
+    static PassRefPtr<TextIndicator> createWithRange(const WebCore::Range&);
 
     ~TextIndicator();
 
index 0e40e260fc590d28e580f9ad79ff6131e03227ee..827c0608710839bd3b46a8223105d54ac87ae17e 100644 (file)
@@ -783,7 +783,7 @@ RetainPtr<CFDataRef> WebFrame::webArchiveData(FrameFilterFunction callback, void
 }
 #endif
 
-PassRefPtr<ShareableBitmap> WebFrame::createSelectionSnapshot()
+PassRefPtr<ShareableBitmap> WebFrame::createSelectionSnapshot() const
 {
     std::unique_ptr<ImageBuffer> snapshot = snapshotSelection(*coreFrame(), WebCore::SnapshotOptionsForceBlackText);
     if (!snapshot)
index 60c94346185d83953a28556eb0a43388a97b7f18..3a573e03f4dc5dfb65a8351ed1fd266d13273124 100644 (file)
@@ -150,7 +150,7 @@ public:
     RetainPtr<CFDataRef> webArchiveData(FrameFilterFunction, void* context);
 #endif
 
-    PassRefPtr<ShareableBitmap> createSelectionSnapshot();
+    PassRefPtr<ShareableBitmap> createSelectionSnapshot() const;
 
 private:
     static PassRefPtr<WebFrame> create(std::unique_ptr<WebFrameLoaderClient>);
index cd55354d3cdfb87016e0f6268732c5d7c091376d..c8a01e25be9eead0ee4acb96e0949e45add28749 100644 (file)
@@ -56,6 +56,7 @@
 #import <QuartzCore/QuartzCore.h>
 #import <WebCore/AXObjectCache.h>
 #import <WebCore/BackForwardController.h>
+#import <WebCore/DataDetection.h>
 #import <WebCore/DataDetectorsSPI.h>
 #import <WebCore/DictionaryLookup.h>
 #import <WebCore/EventHandler.h>
@@ -967,86 +968,6 @@ String WebPage::platformUserAgent(const URL&) const
     return String();
 }
 
-static RetainPtr<DDActionContext> scanForDataDetectedItems(const HitTestResult& hitTestResult, FloatRect& detectedDataBoundingBox, RefPtr<Range>& detectedDataRange)
-{
-    Node* node = hitTestResult.innerNonSharedNode();
-    if (!node)
-        return nullptr;
-    auto renderer = node->renderer();
-    if (!renderer)
-        return nullptr;
-    VisiblePosition position = renderer->positionForPoint(hitTestResult.localPoint(), nullptr);
-    if (position.isNull())
-        position = firstPositionInOrBeforeNode(node);
-
-    RefPtr<Range> contextRange = rangeExpandedAroundPositionByCharacters(position, 250);
-    if (!contextRange)
-        return nullptr;
-
-    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([[getDDActionContextClass() alloc] init]);
-    [actionContext setAllResults:@[ (id)mainResult ]];
-    [actionContext setMainResult:mainResult];
-
-    Vector<FloatQuad> quads;
-    mainResultRange->textQuads(quads);
-    detectedDataBoundingBox = FloatRect();
-    FrameView* frameView = mainResultRange->ownerDocument().view();
-    for (const auto& quad : quads)
-        detectedDataBoundingBox.unite(frameView->contentsToWindow(quad.enclosingBoundingBox()));
-
-    detectedDataRange = mainResultRange;
-
-    return actionContext;
-}
-
-static PassRefPtr<TextIndicator> textIndicatorForRange(Range* range)
-{
-    if (!range)
-        return nullptr;
-
-    Frame* frame = range->startContainer()->document().frame();
-
-    if (!frame)
-        return nullptr;
-
-    VisibleSelection oldSelection = frame->selection().selection();
-    frame->selection().setSelection(range);
-
-    RefPtr<TextIndicator> indicator = TextIndicator::createWithSelectionInFrame(*WebFrame::fromCoreFrame(*frame));
-
-    frame->selection().setSelection(oldSelection);
-
-    return indicator.release();
-}
-
 void WebPage::performActionMenuHitTestAtLocation(WebCore::FloatPoint locationInViewCooordinates)
 {
     m_lastActionMenuHitPageOverlay = nullptr;
@@ -1112,7 +1033,7 @@ void WebPage::performActionMenuHitTestAtLocation(WebCore::FloatPoint locationInV
             detectedDataBoundingBox.unite(frameView->contentsToWindow(quad.enclosingBoundingBox()));
 
         actionMenuResult.detectedDataBoundingBox = detectedDataBoundingBox;
-        actionMenuResult.detectedDataTextIndicator = textIndicatorForRange(mainResultRange.get());
+        actionMenuResult.detectedDataTextIndicator = TextIndicator::createWithRange(*mainResultRange);
         m_lastActionMenuRangeForSelection = mainResultRange;
         m_lastActionMenuHitPageOverlay = webOverlay;
 
@@ -1123,10 +1044,10 @@ void WebPage::performActionMenuHitTestAtLocation(WebCore::FloatPoint locationInV
     if (!pageOverlayDidOverrideDataDetectors && hitTestResult.innerNode() && hitTestResult.innerNode()->isTextNode()) {
         FloatRect detectedDataBoundingBox;
         RefPtr<Range> detectedDataRange;
-        actionMenuResult.actionContext = scanForDataDetectedItems(hitTestResult, detectedDataBoundingBox, detectedDataRange);
-        if (actionMenuResult.actionContext) {
+        actionMenuResult.actionContext = DataDetection::detectItemAroundHitTestResult(hitTestResult, detectedDataBoundingBox, detectedDataRange);
+        if (actionMenuResult.actionContext && detectedDataRange) {
             actionMenuResult.detectedDataBoundingBox = detectedDataBoundingBox;
-            actionMenuResult.detectedDataTextIndicator = textIndicatorForRange(detectedDataRange.get());
+            actionMenuResult.detectedDataTextIndicator = TextIndicator::createWithRange(*detectedDataRange);
             m_lastActionMenuRangeForSelection = detectedDataRange;
         }
     }