Changeset 277479 in webkit
- Timestamp:
- May 13, 2021, 9:06:37 PM (5 years ago)
- Location:
- trunk/Source
- Files:
-
- 2 added
- 2 deleted
- 13 edited
-
WebCore/ChangeLog (modified) (1 diff)
-
WebCore/PAL/ChangeLog (modified) (1 diff)
-
WebCore/PAL/PAL.xcodeproj/project.pbxproj (modified) (5 diffs)
-
WebCore/PAL/pal/PlatformMac.cmake (modified) (2 diffs)
-
WebCore/PAL/pal/cocoa/DataDetectorsCoreSoftLink.h (added)
-
WebCore/PAL/pal/cocoa/DataDetectorsCoreSoftLink.mm (added)
-
WebCore/PAL/pal/spi/cocoa/DataDetectorsCoreSPI.h (modified) (1 diff)
-
WebCore/SourcesCocoa.txt (modified) (1 diff)
-
WebCore/WebCore.xcodeproj/project.pbxproj (modified) (6 diffs)
-
WebCore/editing/cocoa/DataDetection.mm (modified) (17 diffs)
-
WebCore/platform/ImageExtractionResult.h (modified) (5 diffs)
-
WebCore/platform/cocoa/DataDetectorsCoreSoftLink.h (deleted)
-
WebCore/platform/cocoa/DataDetectorsCoreSoftLink.mm (deleted)
-
WebKit/ChangeLog (modified) (1 diff)
-
WebKit/Shared/Cocoa/WebCoreArgumentCodersCocoa.mm (modified) (3 diffs)
-
WebKit/Shared/WebCoreArgumentCoders.cpp (modified) (4 diffs)
-
WebKit/Shared/WebCoreArgumentCoders.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r277463 r277479 1 2021-05-13 Wenson Hsieh <wenson_hsieh@apple.com> 2 3 [Cocoa] Plumb data detector results through some platform objects 4 https://bugs.webkit.org/show_bug.cgi?id=225775 5 Work towards rdar://75504956 6 7 Reviewed by Tim Horton and Devin Rousso. 8 9 Introduce a new struct to hold data detection results, and add it to the existing results object when 10 `ENABLE(DATA_DETECTION)` is defined. 11 12 No change in behavior. 13 14 * SourcesCocoa.txt: 15 * WebCore.xcodeproj/project.pbxproj: 16 * editing/cocoa/DataDetection.mm: 17 (WebCore::DataDetection::canBePresentedByDataDetectors): 18 (WebCore::DataDetection::canPresentDataDetectorsUIForElement): 19 (WebCore::resultIsURL): 20 (WebCore::constructURLStringForResult): 21 (WebCore::buildQuery): 22 (WebCore::DataDetection::detectContentInRange): 23 24 Add a `PAL` namespace to each of these DataDetectorsCore softlinking call sites, since the soft link header now 25 exists in PAL. 26 27 * platform/ImageExtractionResult.h: 28 (WebCore::ImageExtractionDataDetectorInfo::ImageExtractionDataDetectorInfo): 29 (WebCore::ImageExtractionResult::isEmpty const): 30 (WebCore::ImageExtractionResult::encode const): 31 (WebCore::ImageExtractionResult::decode): 32 * platform/cocoa/DataDetectorsCoreSoftLink.h: Removed. 33 * platform/cocoa/DataDetectorsCoreSoftLink.mm: Removed. 34 35 Additionally, move `DataDetectorsCoreSoftLink.{h|mm}` out of `WebCore/platform` and into PAL as softlinking 36 headers, so that they can be imported in WebKit as well as WebCore. 37 1 38 2021-05-13 Devin Rousso <drousso@apple.com> 2 39 -
trunk/Source/WebCore/PAL/ChangeLog
r277464 r277479 1 2021-05-13 Wenson Hsieh <wenson_hsieh@apple.com> 2 3 [Cocoa] Plumb data detector results through some platform objects 4 https://bugs.webkit.org/show_bug.cgi?id=225775 5 Work towards rdar://75504956 6 7 Reviewed by Tim Horton and Devin Rousso. 8 9 Move `DataDetectorsCoreSoftLink.{h|mm}` into PAL, so that it can be used in WebKit as well. 10 11 * PAL.xcodeproj/project.pbxproj: 12 * pal/PlatformMac.cmake: 13 14 Add the header and source file to the CMake build. 15 16 * pal/cocoa/DataDetectorsCoreSoftLink.h: Added. 17 * pal/cocoa/DataDetectorsCoreSoftLink.mm: Added. 18 * pal/spi/cocoa/DataDetectorsCoreSPI.h: 19 20 Explicitly import Foundation headers here, so that the forward declarations don't cause compilation failures in 21 non-internal SDKs. 22 1 23 2021-05-13 Tim Horton <timothy_horton@apple.com> 2 24 -
trunk/Source/WebCore/PAL/PAL.xcodeproj/project.pbxproj
r276615 r277479 208 208 F44291641FA52670002CC93E /* FileSizeFormatter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F44291621FA52670002CC93E /* FileSizeFormatter.cpp */; }; 209 209 F44291681FA52705002CC93E /* FileSizeFormatterCocoa.mm in Sources */ = {isa = PBXBuildFile; fileRef = F44291661FA52705002CC93E /* FileSizeFormatterCocoa.mm */; }; 210 F4DDD01B264DC69E00EF1B91 /* DataDetectorsCoreSoftLink.mm in Sources */ = {isa = PBXBuildFile; fileRef = F4DDD019264DC69E00EF1B91 /* DataDetectorsCoreSoftLink.mm */; }; 211 F4DDD01C264DC69E00EF1B91 /* DataDetectorsCoreSoftLink.h in Headers */ = {isa = PBXBuildFile; fileRef = F4DDD01A264DC69E00EF1B91 /* DataDetectorsCoreSoftLink.h */; }; 210 212 /* End PBXBuildFile section */ 211 213 … … 421 423 F44291621FA52670002CC93E /* FileSizeFormatter.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = FileSizeFormatter.cpp; sourceTree = "<group>"; }; 422 424 F44291661FA52705002CC93E /* FileSizeFormatterCocoa.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = FileSizeFormatterCocoa.mm; sourceTree = "<group>"; }; 425 F4DDD019264DC69E00EF1B91 /* DataDetectorsCoreSoftLink.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DataDetectorsCoreSoftLink.mm; sourceTree = "<group>"; }; 426 F4DDD01A264DC69E00EF1B91 /* DataDetectorsCoreSoftLink.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DataDetectorsCoreSoftLink.h; sourceTree = "<group>"; }; 423 427 /* End PBXFileReference section */ 424 428 … … 708 712 57F1C90725DCF0CF00E8F6EA /* CryptoKitCBridgingSoftLink.h */, 709 713 57F1C90825DCF0CF00E8F6EA /* CryptoKitCBridgingSoftLink.mm */, 714 F4DDD01A264DC69E00EF1B91 /* DataDetectorsCoreSoftLink.h */, 715 F4DDD019264DC69E00EF1B91 /* DataDetectorsCoreSoftLink.mm */, 710 716 F44291661FA52705002CC93E /* FileSizeFormatterCocoa.mm */, 711 717 1C022EFC22CFE8E0006DF01B /* Gunzip.cpp */, … … 848 854 57F1C90925DCF0CF00E8F6EA /* CryptoKitCBridgingSoftLink.h in Headers */, 849 855 DF83E209263734F1000825EF /* CryptoKitCBridgingSPI.h in Headers */, 856 F4DDD01C264DC69E00EF1B91 /* DataDetectorsCoreSoftLink.h in Headers */, 850 857 0C2DA1411F3BEB4900DBC317 /* DataDetectorsCoreSPI.h in Headers */, 851 858 0C77858A1F45130F00F4EBB6 /* DataDetectorsSPI.h in Headers */, … … 1060 1067 1C09D0561E31C46500725F18 /* CryptoDigestCommonCrypto.cpp in Sources */, 1061 1068 57F1C90A25DCF0CF00E8F6EA /* CryptoKitCBridgingSoftLink.mm in Sources */, 1069 F4DDD01B264DC69E00EF1B91 /* DataDetectorsCoreSoftLink.mm in Sources */, 1062 1070 A1175B581F6B470500C4B9F0 /* DefaultSearchProvider.cpp in Sources */, 1063 1071 F44291641FA52670002CC93E /* FileSizeFormatter.cpp in Sources */, -
trunk/Source/WebCore/PAL/pal/PlatformMac.cmake
r276614 r277479 13 13 cocoa/AVFoundationSoftLink.h 14 14 cocoa/CryptoKitCBridgingSoftLink.h 15 cocoa/DataDetectorsCoreSoftLink.h 15 16 cocoa/MediaToolboxSoftLink.h 16 17 cocoa/OpenGLSoftLinkCocoa.h … … 149 150 cocoa/AVFoundationSoftLink.mm 150 151 cocoa/CryptoKitCBridgingSoftLink.mm 152 cocoa/DataDetectorsCoreSoftLink.mm 151 153 cocoa/FileSizeFormatterCocoa.mm 152 154 cocoa/Gunzip.cpp -
trunk/Source/WebCore/PAL/pal/spi/cocoa/DataDetectorsCoreSPI.h
r260366 r277479 40 40 41 41 #else // !USE(APPLE_INTERNAL_SDK) 42 43 #import <Foundation/Foundation.h> 42 44 43 45 typedef enum { -
trunk/Source/WebCore/SourcesCocoa.txt
r277364 r277479 238 238 platform/cocoa/ContentFilterUnblockHandlerCocoa.mm @no-unify 239 239 platform/cocoa/CoreVideoSoftLink.cpp 240 platform/cocoa/DataDetectorsCoreSoftLink.mm @no-unify241 240 platform/cocoa/DragDataCocoa.mm 242 241 platform/cocoa/DragImageCocoa.mm -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r277450 r277479 1258 1258 445210DF25D61F00003A2ED8 /* AppHighlight.h in Headers */ = {isa = PBXBuildFile; fileRef = 445210DD25D61EFF003A2ED8 /* AppHighlight.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1259 1259 445775E520472F73008DCE5D /* LocalDefaultSystemAppearance.h in Headers */ = {isa = PBXBuildFile; fileRef = 445775E420472F73008DCE5D /* LocalDefaultSystemAppearance.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1260 4463CF682212FA68001A8577 /* DataDetectorsCoreSoftLink.mm in Sources */ = {isa = PBXBuildFile; fileRef = 7C7941E21C56C29300A4C58E /* DataDetectorsCoreSoftLink.mm */; };1261 1260 4465D7BD2536D05E0016666D /* SelectionRangeData.h in Headers */ = {isa = PBXBuildFile; fileRef = 44B38BF42536901A00A4458D /* SelectionRangeData.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1262 1261 446DC64824A29DAB0061F390 /* PlaybackTargetClientContextIdentifier.h in Headers */ = {isa = PBXBuildFile; fileRef = 446DC64624A29D9B0061F390 /* PlaybackTargetClientContextIdentifier.h */; settings = {ATTRIBUTES = (Private, ); }; }; … … 2391 2390 7C77C3DC1DEF86D700A50BFA /* JSEndingType.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C77C3DA1DEF86D700A50BFA /* JSEndingType.h */; }; 2392 2391 7C7903B31F86F95C00463A70 /* ImageBitmapRenderingContext.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C7903B01F86F95C00463A70 /* ImageBitmapRenderingContext.h */; }; 2393 7C7941E51C56C29300A4C58E /* DataDetectorsCoreSoftLink.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C7941E31C56C29300A4C58E /* DataDetectorsCoreSoftLink.h */; };2394 2392 7C7BF9422516C90C00808682 /* PerformanceMarkOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C7BF93E2516C8BC00808682 /* PerformanceMarkOptions.h */; }; 2395 2393 7C7BF94C2516FA5400808682 /* PerformanceMeasureOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C7BF9492516FA5400808682 /* PerformanceMeasureOptions.h */; }; … … 10701 10699 7C7903BA1F86FF3300463A70 /* PlaceholderRenderingContext.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PlaceholderRenderingContext.cpp; sourceTree = "<group>"; }; 10702 10700 7C7903BC1F86FF3400463A70 /* PlaceholderRenderingContext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PlaceholderRenderingContext.h; sourceTree = "<group>"; }; 10703 7C7941E21C56C29300A4C58E /* DataDetectorsCoreSoftLink.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DataDetectorsCoreSoftLink.mm; sourceTree = "<group>"; };10704 7C7941E31C56C29300A4C58E /* DataDetectorsCoreSoftLink.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DataDetectorsCoreSoftLink.h; sourceTree = "<group>"; };10705 10701 7C7BF93E2516C8BC00808682 /* PerformanceMarkOptions.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PerformanceMarkOptions.h; sourceTree = "<group>"; }; 10706 10702 7C7BF9402516C8BC00808682 /* PerformanceMarkOptions.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = PerformanceMarkOptions.idl; sourceTree = "<group>"; }; … … 24890 24886 CD7D33451C7A16BF00041293 /* CoreVideoSoftLink.cpp */, 24891 24887 CD7D33461C7A16BF00041293 /* CoreVideoSoftLink.h */, 24892 7C7941E31C56C29300A4C58E /* DataDetectorsCoreSoftLink.h */,24893 7C7941E21C56C29300A4C58E /* DataDetectorsCoreSoftLink.mm */,24894 24888 F462E79F242ADA3C00204DDD /* DragDataCocoa.mm */, 24895 24889 F462E7A0242ADA3D00204DDD /* DragImageCocoa.mm */, … … 32160 32154 BE23480D18A9871400E4B6E8 /* DataCue.h in Headers */, 32161 32155 C5227DF11C3C6DF100F5ED54 /* DataDetection.h in Headers */, 32162 7C7941E51C56C29300A4C58E /* DataDetectorsCoreSoftLink.h in Headers */,32163 32156 BC4A533525605A560028C592 /* DataDetectorType.h in Headers */, 32164 32157 E58B45BA20AD07DD00991025 /* DataListButtonElement.h in Headers */, … … 36467 36460 2D22830323A8470700364B7E /* CursorMac.mm in Sources */, 36468 36461 5CBD59592280E926002B22AA /* CustomHeaderFields.cpp in Sources */, 36469 4463CF682212FA68001A8577 /* DataDetectorsCoreSoftLink.mm in Sources */,36470 36462 6E72F54C229DCD0C00B3E151 /* ExtensionsGLANGLE.cpp in Sources */, 36471 36463 7CE6CBFD187F394900D46BF5 /* FormatConverter.cpp in Sources */, -
trunk/Source/WebCore/editing/cocoa/DataDetection.mm
r277437 r277479 51 51 #import "VisiblePosition.h" 52 52 #import "VisibleUnits.h" 53 #import <pal/cocoa/DataDetectorsCoreSoftLink.h> 53 54 #import <pal/spi/ios/DataDetectorsUISPI.h> 54 55 #import <pal/spi/mac/DataDetectorsSPI.h> … … 56 57 #import <wtf/text/StringBuilder.h> 57 58 #import <wtf/text/StringToIntegerConversion.h> 58 59 #import "DataDetectorsCoreSoftLink.h"60 59 61 60 #if PLATFORM(MAC) … … 167 166 bool DataDetection::canBePresentedByDataDetectors(const URL& url) 168 167 { 169 return [ softLink_DataDetectorsCore_DDURLTapAndHoldSchemes() containsObject:(NSString *)url.protocol().toStringWithoutCopying().convertToASCIILowercase()];168 return [PAL::softLink_DataDetectorsCore_DDURLTapAndHoldSchemes() containsObject:(NSString *)url.protocol().toStringWithoutCopying().convertToASCIILowercase()]; 170 169 } 171 170 … … 193 192 return false; 194 193 195 if ( softLink_DataDetectorsCore_DDShouldImmediatelyShowActionSheetForURL(downcast<HTMLAnchorElement>(element).href()))194 if (PAL::softLink_DataDetectorsCore_DDShouldImmediatelyShowActionSheetForURL(downcast<HTMLAnchorElement>(element).href())) 196 195 return true; 197 196 … … 209 208 // Handle the case of a signature block, where we need to follow the path down one or more subresult levels. 210 209 while (++indexIterator != resultIndices.end()) { 211 results = (__bridge NSArray *) softLink_DataDetectorsCore_DDResultGetSubResults(result);210 results = (__bridge NSArray *)PAL::softLink_DataDetectorsCore_DDResultGetSubResults(result); 212 211 result = (__bridge DDResultRef)results[parseIntegerAllowingTrailingJunk<int>(*indexIterator).valueOr(0)]; 213 212 } 214 213 215 return softLink_DataDetectorsCore_DDShouldImmediatelyShowActionSheetForResult(result);214 return PAL::softLink_DataDetectorsCore_DDShouldImmediatelyShowActionSheetForResult(result); 216 215 } 217 216 … … 222 221 223 222 static NeverDestroyed<RetainPtr<NSSet>> urlTypes = [NSSet setWithObjects: 224 (NSString *) get_DataDetectorsCore_DDBinderHttpURLKey(),225 (NSString *) get_DataDetectorsCore_DDBinderWebURLKey(),226 (NSString *) get_DataDetectorsCore_DDBinderMailURLKey(),227 (NSString *) get_DataDetectorsCore_DDBinderGenericURLKey(),228 (NSString *) get_DataDetectorsCore_DDBinderEmailKey(), nil];229 return [urlTypes.get() containsObject:(NSString *) softLink_DataDetectorsCore_DDResultGetType(result)];223 (NSString *)PAL::get_DataDetectorsCore_DDBinderHttpURLKey(), 224 (NSString *)PAL::get_DataDetectorsCore_DDBinderWebURLKey(), 225 (NSString *)PAL::get_DataDetectorsCore_DDBinderMailURLKey(), 226 (NSString *)PAL::get_DataDetectorsCore_DDBinderGenericURLKey(), 227 (NSString *)PAL::get_DataDetectorsCore_DDBinderEmailKey(), nil]; 228 return [urlTypes.get() containsObject:(NSString *)PAL::softLink_DataDetectorsCore_DDResultGetType(result)]; 230 229 } 231 230 232 231 static NSString *constructURLStringForResult(DDResultRef currentResult, NSString *resultIdentifier, NSDate *referenceDate, NSTimeZone *referenceTimeZone, OptionSet<DataDetectorType> detectionTypes) 233 232 { 234 if (! softLink_DataDetectorsCore_DDResultHasProperties(currentResult, DDResultPropertyPassiveDisplay))233 if (!PAL::softLink_DataDetectorsCore_DDResultHasProperties(currentResult, DDResultPropertyPassiveDisplay)) 235 234 return nil; 236 235 237 236 auto phoneTypes = detectionTypes.contains(DataDetectorType::PhoneNumber) ? DDURLifierPhoneNumberDetectionRegular : DDURLifierPhoneNumberDetectionNone; 238 auto category = softLink_DataDetectorsCore_DDResultGetCategory(currentResult);239 auto type = softLink_DataDetectorsCore_DDResultGetType(currentResult);237 auto category = PAL::softLink_DataDetectorsCore_DDResultGetCategory(currentResult); 238 auto type = PAL::softLink_DataDetectorsCore_DDResultGetType(currentResult); 240 239 241 240 if ((detectionTypes.contains(DataDetectorType::Address) && DDResultCategoryAddress == category) 242 || (detectionTypes.contains(DataDetectorType::TrackingNumber) && CFEqual( get_DataDetectorsCore_DDBinderTrackingNumberKey(), type))243 || (detectionTypes.contains(DataDetectorType::FlightNumber) && CFEqual( get_DataDetectorsCore_DDBinderFlightInformationKey(), type))244 || (detectionTypes.contains(DataDetectorType::LookupSuggestion) && CFEqual( get_DataDetectorsCore_DDBinderParsecSourceKey(), type))241 || (detectionTypes.contains(DataDetectorType::TrackingNumber) && CFEqual(PAL::get_DataDetectorsCore_DDBinderTrackingNumberKey(), type)) 242 || (detectionTypes.contains(DataDetectorType::FlightNumber) && CFEqual(PAL::get_DataDetectorsCore_DDBinderFlightInformationKey(), type)) 243 || (detectionTypes.contains(DataDetectorType::LookupSuggestion) && CFEqual(PAL::get_DataDetectorsCore_DDBinderParsecSourceKey(), type)) 245 244 || (detectionTypes.contains(DataDetectorType::PhoneNumber) && DDResultCategoryPhoneNumber == category) 246 245 || (detectionTypes.contains(DataDetectorType::Link) && resultIsURL(currentResult))) { 247 return softLink_DataDetectorsCore_DDURLStringForResult(currentResult, resultIdentifier, phoneTypes, referenceDate, referenceTimeZone);246 return PAL::softLink_DataDetectorsCore_DDURLStringForResult(currentResult, resultIdentifier, phoneTypes, referenceDate, referenceTimeZone); 248 247 } 249 248 if (detectionTypes.contains(DataDetectorType::CalendarEvent) && DDResultCategoryCalendarEvent == category) { 250 if (! softLink_DataDetectorsCore_DDResultIsPastDate(currentResult, (CFDateRef)referenceDate, (CFTimeZoneRef)referenceTimeZone))251 return softLink_DataDetectorsCore_DDURLStringForResult(currentResult, resultIdentifier, phoneTypes, referenceDate, referenceTimeZone);249 if (!PAL::softLink_DataDetectorsCore_DDResultIsPastDate(currentResult, (CFDateRef)referenceDate, (CFTimeZoneRef)referenceTimeZone)) 250 return PAL::softLink_DataDetectorsCore_DDURLStringForResult(currentResult, resultIdentifier, phoneTypes, referenceDate, referenceTimeZone); 252 251 } 253 252 return nil; … … 360 359 size_t currentTextLength = currentText.length(); 361 360 if (!currentTextLength) { 362 softLink_DataDetectorsCore_DDScanQueryAddSeparator(scanQuery, DDTextCoalescingTypeHardBreak);361 PAL::softLink_DataDetectorsCore_DDScanQueryAddSeparator(scanQuery, DDTextCoalescingTypeHardBreak); 363 362 if (iteratorCount > maxFragmentWithHardBreak) 364 363 break; … … 395 394 if (containsOnlyWhiteSpace) { 396 395 if (hasNewline) { 397 softLink_DataDetectorsCore_DDScanQueryAddLineBreak(scanQuery);396 PAL::softLink_DataDetectorsCore_DDScanQueryAddLineBreak(scanQuery); 398 397 if (iteratorCount > maxFragmentWithLinebreak) 399 398 break; 400 399 } else { 401 softLink_DataDetectorsCore_DDScanQueryAddSeparator(scanQuery, hasTab ? DDTextCoalescingTypeTab : DDTextCoalescingTypeSpace);400 PAL::softLink_DataDetectorsCore_DDScanQueryAddSeparator(scanQuery, hasTab ? DDTextCoalescingTypeTab : DDTextCoalescingTypeSpace); 402 401 if (iteratorCount > maxFragmentSpace) 403 402 break; … … 407 406 408 407 auto currentTextCFString = adoptCF(CFStringCreateWithCharacters(kCFAllocatorDefault, reinterpret_cast<const UniChar*>(currentTextUpconvertedCharacters.get()), currentTextLength)); 409 softLink_DataDetectorsCore_DDScanQueryAddTextFragment(scanQuery, currentTextCFString.get(), CFRangeMake(0, currentTextLength), (void *)iteratorCount, (DDTextFragmentMode)0, DDTextCoalescingTypeNone);408 PAL::softLink_DataDetectorsCore_DDScanQueryAddTextFragment(scanQuery, currentTextCFString.get(), CFRangeMake(0, currentTextLength), (void *)iteratorCount, (DDTextFragmentMode)0, DDTextCoalescingTypeNone); 410 409 fragmentCount++; 411 410 } … … 437 436 NSArray *DataDetection::detectContentInRange(const SimpleRange& contextRange, OptionSet<DataDetectorType> types, NSDictionary *context) 438 437 { 439 auto scanner = adoptCF( softLink_DataDetectorsCore_DDScannerCreate(DDScannerTypeStandard, 0, nullptr));440 auto scanQuery = adoptCF( softLink_DataDetectorsCore_DDScanQueryCreate(NULL));438 auto scanner = adoptCF(PAL::softLink_DataDetectorsCore_DDScannerCreate(DDScannerTypeStandard, 0, nullptr)); 439 auto scanQuery = adoptCF(PAL::softLink_DataDetectorsCore_DDScanQueryCreate(NULL)); 441 440 buildQuery(scanQuery.get(), contextRange); 442 441 443 442 if (types.contains(DataDetectorType::LookupSuggestion)) 444 softLink_DataDetectorsCore_DDScannerEnableOptionalSource(scanner.get(), DDScannerSourceSpotlight, true);443 PAL::softLink_DataDetectorsCore_DDScannerEnableOptionalSource(scanner.get(), DDScannerSourceSpotlight, true); 445 444 446 445 // FIXME: we should add a timeout to this call to make sure it doesn't take too much time. 447 if (! softLink_DataDetectorsCore_DDScannerScanQuery(scanner.get(), scanQuery.get()))446 if (!PAL::softLink_DataDetectorsCore_DDScannerScanQuery(scanner.get(), scanQuery.get())) 448 447 return nil; 449 448 450 auto scannerResults = adoptCF( softLink_DataDetectorsCore_DDScannerCopyResultsWithOptions(scanner.get(),get_DataDetectorsCore_DDScannerCopyResultsOptionsForPassiveUse() | DDScannerCopyResultsOptionsCoalesceSignatures));449 auto scannerResults = adoptCF(PAL::softLink_DataDetectorsCore_DDScannerCopyResultsWithOptions(scanner.get(), PAL::get_DataDetectorsCore_DDScannerCopyResultsOptionsForPassiveUse() | DDScannerCopyResultsOptionsCoalesceSignatures)); 451 450 if (!scannerResults) 452 451 return nil; … … 464 463 DDResultRef result = (DDResultRef)resultObject; 465 464 NSIndexPath *indexPath = [NSIndexPath indexPathWithIndex:currentTopLevelIndex]; 466 if (CFEqual( softLink_DataDetectorsCore_DDResultGetType(result),get_DataDetectorsCore_DDBinderSignatureBlockKey())) {467 NSArray *subresults = (NSArray *) softLink_DataDetectorsCore_DDResultGetSubResults(result);465 if (CFEqual(PAL::softLink_DataDetectorsCore_DDResultGetType(result), PAL::get_DataDetectorsCore_DDBinderSignatureBlockKey())) { 466 NSArray *subresults = (NSArray *)PAL::softLink_DataDetectorsCore_DDResultGetSubResults(result); 468 467 469 468 for (NSUInteger subResultIndex = 0 ; subResultIndex < [subresults count] ; subResultIndex++) { … … 486 485 // Each result can be contained all in one text node or can span multiple text nodes. 487 486 for (auto& result : allResults) { 488 DDQueryRange queryRange = softLink_DataDetectorsCore_DDResultGetQueryRangeForURLification(result.get());489 CFIndex iteratorTargetAdvanceCount = (CFIndex) softLink_DataDetectorsCore_DDScanQueryGetFragmentMetaData(scanQuery.get(), queryRange.start.queryIndex);487 DDQueryRange queryRange = PAL::softLink_DataDetectorsCore_DDResultGetQueryRangeForURLification(result.get()); 488 CFIndex iteratorTargetAdvanceCount = (CFIndex)PAL::softLink_DataDetectorsCore_DDScanQueryGetFragmentMetaData(scanQuery.get(), queryRange.start.queryIndex); 490 489 for (; iteratorCount < iteratorTargetAdvanceCount; ++iteratorCount) 491 490 iterator.advance(); … … 506 505 while (fragmentIndex < queryRange.end.queryIndex) { 507 506 ++fragmentIndex; 508 iteratorTargetAdvanceCount = (CFIndex) softLink_DataDetectorsCore_DDScanQueryGetFragmentMetaData(scanQuery.get(), fragmentIndex);507 iteratorTargetAdvanceCount = (CFIndex)PAL::softLink_DataDetectorsCore_DDScanQueryGetFragmentMetaData(scanQuery.get(), fragmentIndex); 509 508 for (; iteratorCount < iteratorTargetAdvanceCount; ++iteratorCount) 510 509 iterator.advance(); … … 535 534 for (CFIndex resultIndex = 0; resultIndex < resultCount; ++resultIndex) { 536 535 DDResultRef coreResult = allResults[resultIndex].get(); 537 DDQueryRange queryRange = softLink_DataDetectorsCore_DDResultGetQueryRangeForURLification(coreResult);536 DDQueryRange queryRange = PAL::softLink_DataDetectorsCore_DDResultGetQueryRangeForURLification(coreResult); 538 537 auto& resultRanges = allResultRanges[resultIndex]; 539 538 … … 552 551 553 552 lastModifiedQueryOffset = queryRange.end; 554 BOOL shouldUseLightLinks = softLink_DataDetectorsCore_DDShouldUseLightLinksForResult(coreResult, [indexPaths[resultIndex] length] > 1);553 BOOL shouldUseLightLinks = PAL::softLink_DataDetectorsCore_DDShouldUseLightLinksForResult(coreResult, [indexPaths[resultIndex] length] > 1); 555 554 556 555 for (auto& range : resultRanges) { … … 617 616 // Add a special attribute to mark this URLification as the result of data detectors. 618 617 anchorElement->setAttributeWithoutSynchronization(x_apple_data_detectorsAttr, AtomString("true", AtomString::ConstructFromLiteral)); 619 anchorElement->setAttributeWithoutSynchronization(x_apple_data_detectors_typeAttr, dataDetectorTypeForCategory( softLink_DataDetectorsCore_DDResultGetCategory(coreResult)));618 anchorElement->setAttributeWithoutSynchronization(x_apple_data_detectors_typeAttr, dataDetectorTypeForCategory(PAL::softLink_DataDetectorsCore_DDResultGetCategory(coreResult))); 620 619 anchorElement->setAttributeWithoutSynchronization(x_apple_data_detectors_resultAttr, identifier); 621 620 … … 632 631 lastTextNodeToUpdate->setData(lastNodeContent); 633 632 634 return [ getDDScannerResultClass() resultsFromCoreResults:scannerResults.get()];633 return [PAL::getDDScannerResultClass() resultsFromCoreResults:scannerResults.get()]; 635 634 } 636 635 -
trunk/Source/WebCore/platform/ImageExtractionResult.h
r276626 r277479 28 28 #if ENABLE(IMAGE_EXTRACTION) 29 29 30 #if ENABLE(DATA_DETECTION) 31 OBJC_CLASS DDScannerResult; 32 #endif 33 30 34 #include "FloatQuad.h" 31 35 #include <wtf/Optional.h> 36 #include <wtf/RetainPtr.h> 32 37 #include <wtf/text/WTFString.h> 33 38 … … 83 88 }; 84 89 90 #if ENABLE(DATA_DETECTION) 91 92 struct ImageExtractionDataDetectorInfo { 93 ImageExtractionDataDetectorInfo() = default; 94 ImageExtractionDataDetectorInfo(DDScannerResult *scannerResult, Vector<FloatQuad>&& quads) 95 : result(scannerResult) 96 , normalizedQuads(WTFMove(quads)) 97 { 98 } 99 100 RetainPtr<DDScannerResult> result; 101 Vector<FloatQuad> normalizedQuads; 102 }; 103 104 #endif // ENABLE(DATA_DETECTION) 105 85 106 template<class Encoder> void ImageExtractionLineData::encode(Encoder& encoder) const 86 107 { … … 107 128 Vector<ImageExtractionLineData> lines; 108 129 109 bool isEmpty() const { return lines.isEmpty(); } 130 #if ENABLE(DATA_DETECTION) 131 Vector<ImageExtractionDataDetectorInfo> dataDetectors; 132 #endif 133 134 bool isEmpty() const 135 { 136 if (!lines.isEmpty()) 137 return false; 138 139 #if ENABLE(DATA_DETECTION) 140 if (!dataDetectors.isEmpty()) 141 return false; 142 #endif 143 144 return true; 145 } 110 146 111 147 template<class Encoder> void encode(Encoder&) const; … … 116 152 { 117 153 encoder << lines; 154 #if ENABLE(DATA_DETECTION) 155 encoder << dataDetectors; 156 #endif 118 157 } 119 158 … … 125 164 return WTF::nullopt; 126 165 127 return {{ WTFMove(*lines) }}; 166 #if ENABLE(DATA_DETECTION) 167 Optional<Vector<ImageExtractionDataDetectorInfo>> dataDetectors; 168 decoder >> dataDetectors; 169 if (!dataDetectors) 170 return WTF::nullopt; 171 #endif 172 173 return {{ 174 WTFMove(*lines), 175 #if ENABLE(DATA_DETECTION) 176 WTFMove(*dataDetectors), 177 #endif 178 }}; 128 179 } 129 180 -
trunk/Source/WebKit/ChangeLog
r277468 r277479 1 2021-05-13 Wenson Hsieh <wenson_hsieh@apple.com> 2 3 [Cocoa] Plumb data detector results through some platform objects 4 https://bugs.webkit.org/show_bug.cgi?id=225775 5 Work towards rdar://75504956 6 7 Reviewed by Tim Horton and Devin Rousso. 8 9 Add IPC encoding and decoding support for the new struct. 10 11 * Shared/Cocoa/WebCoreArgumentCodersCocoa.mm: 12 (IPC::ArgumentCoder<ImageExtractionDataDetectorInfo>::encodePlatformData): 13 (IPC::ArgumentCoder<ImageExtractionDataDetectorInfo>::decodePlatformData): 14 * Shared/WebCoreArgumentCoders.cpp: 15 (IPC::ArgumentCoder<ImageExtractionDataDetectorInfo>::encode): 16 (IPC::ArgumentCoder<ImageExtractionDataDetectorInfo>::decode): 17 * Shared/WebCoreArgumentCoders.h: 18 1 19 2021-05-13 Dean Jackson <dino@apple.com> 2 20 -
trunk/Source/WebKit/Shared/Cocoa/WebCoreArgumentCodersCocoa.mm
r276510 r277479 51 51 #endif 52 52 53 #if ENABLE(IMAGE_EXTRACTION) 54 #import <WebCore/ImageExtractionResult.h> 55 #endif 56 53 57 #if ENABLE(APPLE_PAY) 54 58 #import "DataReference.h" … … 59 63 #if ENABLE(WIRELESS_PLAYBACK_TARGET) 60 64 #import <pal/cocoa/AVFoundationSoftLink.h> 65 #endif 66 67 #if ENABLE(DATA_DETECTION) 68 #import <pal/cocoa/DataDetectorsCoreSoftLink.h> 61 69 #endif 62 70 … … 652 660 #endif 653 661 662 #if ENABLE(IMAGE_EXTRACTION) && ENABLE(DATA_DETECTION) 663 664 void ArgumentCoder<ImageExtractionDataDetectorInfo>::encodePlatformData(Encoder& encoder, const ImageExtractionDataDetectorInfo& info) 665 { 666 encoder << info.result.get(); 667 } 668 669 bool ArgumentCoder<ImageExtractionDataDetectorInfo>::decodePlatformData(Decoder& decoder, ImageExtractionDataDetectorInfo& result) 670 { 671 auto scannerResult = IPC::decode<DDScannerResult>(decoder, @[ PAL::getDDScannerResultClass() ]); 672 if (!scannerResult) 673 return false; 674 675 result.result = WTFMove(*scannerResult); 676 return true; 677 } 678 679 #endif // ENABLE(IMAGE_EXTRACTION) && ENABLE(DATA_DETECTION) 680 654 681 } // namespace IPC -
trunk/Source/WebKit/Shared/WebCoreArgumentCoders.cpp
r277313 r277479 54 54 #include <WebCore/FilterOperation.h> 55 55 #include <WebCore/FilterOperations.h> 56 #include <WebCore/FloatQuad.h> 56 57 #include <WebCore/Font.h> 57 58 #include <WebCore/FontAttributes.h> … … 103 104 104 105 #if PLATFORM(IOS_FAMILY) 105 #include <WebCore/FloatQuad.h>106 106 #include <WebCore/SelectionGeometry.h> 107 107 #include <WebCore/SharedBuffer.h> … … 115 115 #include <WebCore/CaptureDevice.h> 116 116 #include <WebCore/MediaConstraints.h> 117 #endif 118 119 #if ENABLE(IMAGE_EXTRACTION) 120 #include <WebCore/ImageExtractionResult.h> 117 121 #endif 118 122 … … 3199 3203 #endif 3200 3204 3205 #if ENABLE(IMAGE_EXTRACTION) && ENABLE(DATA_DETECTION) 3206 3207 void ArgumentCoder<ImageExtractionDataDetectorInfo>::encode(Encoder& encoder, const ImageExtractionDataDetectorInfo& info) 3208 { 3209 encodePlatformData(encoder, info); 3210 encoder << info.normalizedQuads; 3211 } 3212 3213 Optional<ImageExtractionDataDetectorInfo> ArgumentCoder<ImageExtractionDataDetectorInfo>::decode(Decoder& decoder) 3214 { 3215 ImageExtractionDataDetectorInfo result; 3216 if (!decodePlatformData(decoder, result)) 3217 return WTF::nullopt; 3218 3219 Optional<Vector<FloatQuad>> normalizedQuads; 3220 decoder >> normalizedQuads; 3221 if (!normalizedQuads) 3222 return WTF::nullopt; 3223 3224 result.normalizedQuads = WTFMove(*normalizedQuads); 3225 return WTFMove(result); 3226 } 3227 3228 #endif // ENABLE(IMAGE_EXTRACTION) && ENABLE(DATA_DETECTION) 3229 3201 3230 } // namespace IPC -
trunk/Source/WebKit/Shared/WebCoreArgumentCoders.h
r277362 r277479 148 148 struct FontAttributes; 149 149 struct FileChooserSettings; 150 struct ImageExtractionDataDetectorInfo; 150 151 struct RawFile; 151 152 struct ShareData; … … 825 826 #endif 826 827 828 #if ENABLE(IMAGE_EXTRACTION) && ENABLE(DATA_DETECTION) 829 830 template<> struct ArgumentCoder<WebCore::ImageExtractionDataDetectorInfo> { 831 static void encode(Encoder&, const WebCore::ImageExtractionDataDetectorInfo&); 832 static WARN_UNUSED_RETURN Optional<WebCore::ImageExtractionDataDetectorInfo> decode(Decoder&); 833 static void encodePlatformData(Encoder&, const WebCore::ImageExtractionDataDetectorInfo&); 834 static WARN_UNUSED_RETURN bool decodePlatformData(Decoder&, WebCore::ImageExtractionDataDetectorInfo&); 835 }; 836 837 #endif // ENABLE(IMAGE_EXTRACTION) && ENABLE(DATA_DETECTION) 838 827 839 } // namespace IPC 828 840
Note:
See TracChangeset
for help on using the changeset viewer.