Title: [211914] trunk
Revision
211914
Author
[email protected]
Date
2017-02-08 17:56:26 -0800 (Wed, 08 Feb 2017)

Log Message

[Cocoa] WKRemoteObjectCoder doesn’t handle CGSize
https://bugs.webkit.org/show_bug.cgi?id=168031

Reviewed by Tim Horton.

Source/WebKit2:

* Shared/API/Cocoa/WKRemoteObjectCoder.mm:
(encodeInvocationArguments): Encode CGSize by encoding two NSNumbers. Somewhat sadly,
  +[NSValue valueWithCGSize:] is not available in macOS.
(decodeInvocationArguments): Decode wrapped numbers.

Tools:

* TestWebKitAPI/Tests/WebKit2Cocoa/RemoteObjectRegistry.h:
* TestWebKitAPI/Tests/WebKit2Cocoa/RemoteObjectRegistry.mm:
(TEST):
* TestWebKitAPI/Tests/WebKit2Cocoa/RemoteObjectRegistryPlugIn.mm:
(-[RemoteObjectRegistryPlugIn takeSize:completionHandler:]):

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (211913 => 211914)


--- trunk/Source/WebKit2/ChangeLog	2017-02-09 01:42:55 UTC (rev 211913)
+++ trunk/Source/WebKit2/ChangeLog	2017-02-09 01:56:26 UTC (rev 211914)
@@ -1,5 +1,17 @@
 2017-02-08  Dan Bernstein  <[email protected]>
 
+        [Cocoa] WKRemoteObjectCoder doesn’t handle CGSize
+        https://bugs.webkit.org/show_bug.cgi?id=168031
+
+        Reviewed by Tim Horton.
+
+        * Shared/API/Cocoa/WKRemoteObjectCoder.mm:
+        (encodeInvocationArguments): Encode CGSize by encoding two NSNumbers. Somewhat sadly,
+          +[NSValue valueWithCGSize:] is not available in macOS.
+        (decodeInvocationArguments): Decode wrapped numbers.
+
+2017-02-08  Dan Bernstein  <[email protected]>
+
         Tried to fix the build after r211897.
 
         * UIProcess/ios/WKContentViewInteraction.h:

Modified: trunk/Source/WebKit2/Shared/API/Cocoa/WKRemoteObjectCoder.mm (211913 => 211914)


--- trunk/Source/WebKit2/Shared/API/Cocoa/WKRemoteObjectCoder.mm	2017-02-09 01:42:55 UTC (rev 211913)
+++ trunk/Source/WebKit2/Shared/API/Cocoa/WKRemoteObjectCoder.mm	2017-02-09 01:56:26 UTC (rev 211914)
@@ -213,6 +213,13 @@
 
                 encodeToObjectStream(encoder, [NSValue valueWithRange:value]);
                 break;
+            } else if (!strcmp(type, @encode(CGSize))) {
+                CGSize value;
+                [invocation getArgument:&value atIndex:i];
+
+                encodeToObjectStream(encoder, @(value.width));
+                encodeToObjectStream(encoder, @(value.height));
+                break;
             }
             FALLTHROUGH;
 
@@ -555,6 +562,12 @@
                 NSRange value = [decodeObjectFromObjectStream(decoder, { [NSValue class] }) rangeValue];
                 [invocation setArgument:&value atIndex:i];
                 break;
+            } else if (!strcmp(type, @encode(CGSize))) {
+                CGSize value;
+                value.width = [decodeObjectFromObjectStream(decoder, { [NSNumber class] }) doubleValue];
+                value.height = [decodeObjectFromObjectStream(decoder, { [NSNumber class] }) doubleValue];
+                [invocation setArgument:&value atIndex:i];
+                break;
             }
             FALLTHROUGH;
 

Modified: trunk/Tools/ChangeLog (211913 => 211914)


--- trunk/Tools/ChangeLog	2017-02-09 01:42:55 UTC (rev 211913)
+++ trunk/Tools/ChangeLog	2017-02-09 01:56:26 UTC (rev 211914)
@@ -1,3 +1,16 @@
+2017-02-08  Dan Bernstein  <[email protected]>
+
+        [Cocoa] WKRemoteObjectCoder doesn’t handle CGSize
+        https://bugs.webkit.org/show_bug.cgi?id=168031
+
+        Reviewed by Tim Horton.
+
+        * TestWebKitAPI/Tests/WebKit2Cocoa/RemoteObjectRegistry.h:
+        * TestWebKitAPI/Tests/WebKit2Cocoa/RemoteObjectRegistry.mm:
+        (TEST):
+        * TestWebKitAPI/Tests/WebKit2Cocoa/RemoteObjectRegistryPlugIn.mm:
+        (-[RemoteObjectRegistryPlugIn takeSize:completionHandler:]):
+
 2017-02-08  Chris Dumez  <[email protected]>
 
         Use smaller tiles in windows that are not active to facilitate App Napping

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/RemoteObjectRegistry.h (211913 => 211914)


--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/RemoteObjectRegistry.h	2017-02-09 01:42:55 UTC (rev 211913)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/RemoteObjectRegistry.h	2017-02-09 01:56:26 UTC (rev 211914)
@@ -35,6 +35,7 @@
 - (void)sayHello:(NSString *)hello completionHandler:(void (^)(NSString *))completionHandler;
 - (void)selectionAndClickInformationForClickAtPoint:(NSValue *)pointValue completionHandler:(void (^)(NSDictionary *))completionHandler;
 - (void)takeRange:(NSRange)range completionHandler:(void (^)(NSUInteger location, NSUInteger length))completionHandler;
+- (void)takeSize:(CGSize)size completionHandler:(void (^)(CGFloat width, CGFloat height))completionHandler;
 - (void)doNotCallCompletionHandler:(void (^)())completionHandler;
 
 @end

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/RemoteObjectRegistry.mm (211913 => 211914)


--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/RemoteObjectRegistry.mm	2017-02-09 01:42:55 UTC (rev 211913)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/RemoteObjectRegistry.mm	2017-02-09 01:56:26 UTC (rev 211914)
@@ -85,7 +85,15 @@
         TestWebKitAPI::Util::run(&isDone);
 
         isDone = false;
+        [object takeSize:CGSizeMake(123.45, 678.91) completionHandler:^(CGFloat width, CGFloat height) {
+            EXPECT_EQ(123.45, width);
+            EXPECT_EQ(678.91, height);
+            isDone = true;
+        }];
+        TestWebKitAPI::Util::run(&isDone);
 
+        isDone = false;
+
         class DoneWhenDestroyed : public RefCounted<DoneWhenDestroyed> {
         public:
             ~DoneWhenDestroyed() { isDone = true; }

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/RemoteObjectRegistryPlugIn.mm (211913 => 211914)


--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/RemoteObjectRegistryPlugIn.mm	2017-02-09 01:42:55 UTC (rev 211913)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/RemoteObjectRegistryPlugIn.mm	2017-02-09 01:56:26 UTC (rev 211914)
@@ -81,6 +81,11 @@
     completionHandler(range.location, range.length);
 }
 
+- (void)takeSize:(CGSize)size completionHandler:(void (^)(CGFloat width, CGFloat height))completionHandler
+{
+    completionHandler(size.width, size.height);
+}
+
 - (void)doNotCallCompletionHandler:(void (^)())completionHandler
 {
 }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to