Title: [232362] trunk/Source/WebCore
Revision
232362
Author
ddkil...@apple.com
Date
2018-05-31 12:33:38 -0700 (Thu, 31 May 2018)

Log Message

Implement checked cast for DDResultRef once DDResultGetCFTypeID() is available
<https://webkit.org/b/184554>
<rdar://problem/36241894>

Reviewed by Brent Fulgham.

* editing/cocoa/DataDetection.mm:
(WebCore::detectItemAtPositionWithRange): Implement checked cast
for DDResultRef.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (232361 => 232362)


--- trunk/Source/WebCore/ChangeLog	2018-05-31 19:15:30 UTC (rev 232361)
+++ trunk/Source/WebCore/ChangeLog	2018-05-31 19:33:38 UTC (rev 232362)
@@ -1,3 +1,15 @@
+2018-05-31  David Kilzer  <ddkil...@apple.com>
+
+        Implement checked cast for DDResultRef once DDResultGetCFTypeID() is available
+        <https://webkit.org/b/184554>
+        <rdar://problem/36241894>
+
+        Reviewed by Brent Fulgham.
+
+        * editing/cocoa/DataDetection.mm:
+        (WebCore::detectItemAtPositionWithRange): Implement checked cast
+        for DDResultRef.
+
 2018-05-31  Alex Christensen  <achristen...@webkit.org>
 
         Fix Windows build after r232246.

Modified: trunk/Source/WebCore/editing/cocoa/DataDetection.mm (232361 => 232362)


--- trunk/Source/WebCore/editing/cocoa/DataDetection.mm	2018-05-31 19:15:30 UTC (rev 232361)
+++ trunk/Source/WebCore/editing/cocoa/DataDetection.mm	2018-05-31 19:33:38 UTC (rev 232362)
@@ -50,10 +50,18 @@
 #import "VisibleUnits.h"
 #import <pal/spi/ios/DataDetectorsUISPI.h>
 #import <pal/spi/mac/DataDetectorsSPI.h>
+#import <wtf/cf/TypeCastsCF.h>
 #import <wtf/text/StringBuilder.h>
 
 #import "DataDetectorsCoreSoftLink.h"
 
+#if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101400
+template <>
+struct WTF::CFTypeTrait<DDResultRef> {
+    static inline CFTypeID typeID(void) { return DDResultGetCFTypeID(); }
+};
+#endif
+
 namespace WebCore {
 
 using namespace HTMLNames;
@@ -78,8 +86,11 @@
     RefPtr<Range> mainResultRange;
     CFIndex resultCount = CFArrayGetCount(results.get());
     for (CFIndex i = 0; i < resultCount; i++) {
-        // FIXME: <rdar://problem/36241894> Implement checked cast for DDResultRef once DDResultGetTypeID() is available
+#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101400
+        DDResultRef result = checked_cf_cast<DDResultRef>(CFArrayGetValueAtIndex(results.get(), i));
+#else
         DDResultRef result = static_cast<DDResultRef>(const_cast<CF_BRIDGED_TYPE(id) void*>(CFArrayGetValueAtIndex(results.get(), i)));
+#endif
         CFRange resultRangeInContext = DDResultGetRange(result);
         if (hitLocation >= resultRangeInContext.location && (hitLocation - resultRangeInContext.location) < resultRangeInContext.length) {
             mainResult = result;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to