Expose shrink-wrapping as UIKit support SPI
authortimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 21 Jul 2015 17:14:00 +0000 (17:14 +0000)
committertimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 21 Jul 2015 17:14:00 +0000 (17:14 +0000)
https://bugs.webkit.org/show_bug.cgi?id=147148
<rdar://problem/21920008>

Reviewed by Simon Fraser.

* Misc/WebUIKitSupport.h:
* Misc/WebUIKitSupport.mm:
(WebKitCreatePathWithShrinkWrappedRects):

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

Source/WebKit/ios/ChangeLog
Source/WebKit/ios/Misc/WebUIKitSupport.h
Source/WebKit/ios/Misc/WebUIKitSupport.mm

index da4c5a1..3b062b8 100644 (file)
@@ -1,3 +1,15 @@
+2015-07-21  Tim Horton  <timothy_horton@apple.com>
+
+        Expose shrink-wrapping as UIKit support SPI
+        https://bugs.webkit.org/show_bug.cgi?id=147148
+        <rdar://problem/21920008>
+
+        Reviewed by Simon Fraser.
+
+        * Misc/WebUIKitSupport.h:
+        * Misc/WebUIKitSupport.mm:
+        (WebKitCreatePathWithShrinkWrappedRects):
+
 2015-07-02  Timothy Horton  <timothy_horton@apple.com>
 
         iOS WebKitLegacy should match WebKit2's viewport behavior
index fecea21..32cd4cf 100644 (file)
@@ -61,6 +61,8 @@ int WebKitGetLastLineBreakInBuffer(UChar *characters, int position, int length);
 
 const char *WebKitPlatformSystemRootDirectory(void);
 
+CGPathRef WebKitCreatePathWithShrinkWrappedRects(NSArray* cgRects, CGFloat radius);
+
 #ifdef __cplusplus
 }
 #endif
index 3145875..e6d476e 100644 (file)
 
 #import "WebUIKitSupport.h"
 
-#import <WebCore/break_lines.h>
-#import <WebCore/ResourceRequest.h>
-#import <WebCore/TextBreakIterator.h>
-#import <WebCore/WebCoreSystemInterface.h>
-#import <WebCore/WebCoreThreadSystemInterface.h>
 #import "WebDatabaseManagerInternal.h"
 #import "WebKitSystemInterface.h"
 #import "WebLocalizableStrings.h"
 #import "WebPlatformStrategies.h"
 #import "WebSystemInterface.h"
 #import "WebViewPrivate.h"
-
+#import <WebCore/PathUtilities.h>
+#import <WebCore/ResourceRequest.h>
+#import <WebCore/TextBreakIterator.h>
+#import <WebCore/WebCoreSystemInterface.h>
+#import <WebCore/WebCoreThreadSystemInterface.h>
+#import <WebCore/break_lines.h>
 
 #import <runtime/InitializeThreading.h>
 
@@ -173,4 +173,23 @@ void endBackgroundTask(WebBackgroundTaskIdentifier taskIdentifier)
     endBackgroundTaskBlock(taskIdentifier);
 }
 
+CGPathRef WebKitCreatePathWithShrinkWrappedRects(NSArray* cgRects, CGFloat radius)
+{
+    Vector<FloatRect> rects;
+    rects.reserveInitialCapacity([cgRects count]);
+
+    const char* cgRectEncodedString = @encode(CGRect);
+
+    for (NSValue *rectValue in cgRects) {
+        CGRect cgRect;
+        [rectValue getValue:&cgRect];
+
+        if (strcmp(cgRectEncodedString, rectValue.objCType))
+            return nullptr;
+        rects.append(cgRect);
+    }
+
+    return CGPathRetain(PathUtilities::pathWithShrinkWrappedRects(rects, radius).platformPath());
+}
+
 #endif // PLATFORM(IOS)