Changeset 211914 in webkit


Ignore:
Timestamp:
Feb 8, 2017 5:56:26 PM (7 years ago)
Author:
mitz@apple.com
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:]):

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r211898 r211914  
     12017-02-08  Dan Bernstein  <mitz@apple.com>
     2
     3        [Cocoa] WKRemoteObjectCoder doesn’t handle CGSize
     4        https://bugs.webkit.org/show_bug.cgi?id=168031
     5
     6        Reviewed by Tim Horton.
     7
     8        * Shared/API/Cocoa/WKRemoteObjectCoder.mm:
     9        (encodeInvocationArguments): Encode CGSize by encoding two NSNumbers. Somewhat sadly,
     10          +[NSValue valueWithCGSize:] is not available in macOS.
     11        (decodeInvocationArguments): Decode wrapped numbers.
     12
    1132017-02-08  Dan Bernstein  <mitz@apple.com>
    214
  • trunk/Source/WebKit2/Shared/API/Cocoa/WKRemoteObjectCoder.mm

    r208841 r211914  
    214214                encodeToObjectStream(encoder, [NSValue valueWithRange:value]);
    215215                break;
     216            } else if (!strcmp(type, @encode(CGSize))) {
     217                CGSize value;
     218                [invocation getArgument:&value atIndex:i];
     219
     220                encodeToObjectStream(encoder, @(value.width));
     221                encodeToObjectStream(encoder, @(value.height));
     222                break;
    216223            }
    217224            FALLTHROUGH;
     
    554561            if (!strcmp(type, @encode(NSRange))) {
    555562                NSRange value = [decodeObjectFromObjectStream(decoder, { [NSValue class] }) rangeValue];
     563                [invocation setArgument:&value atIndex:i];
     564                break;
     565            } else if (!strcmp(type, @encode(CGSize))) {
     566                CGSize value;
     567                value.width = [decodeObjectFromObjectStream(decoder, { [NSNumber class] }) doubleValue];
     568                value.height = [decodeObjectFromObjectStream(decoder, { [NSNumber class] }) doubleValue];
    556569                [invocation setArgument:&value atIndex:i];
    557570                break;
  • trunk/Tools/ChangeLog

    r211910 r211914  
     12017-02-08  Dan Bernstein  <mitz@apple.com>
     2
     3        [Cocoa] WKRemoteObjectCoder doesn’t handle CGSize
     4        https://bugs.webkit.org/show_bug.cgi?id=168031
     5
     6        Reviewed by Tim Horton.
     7
     8        * TestWebKitAPI/Tests/WebKit2Cocoa/RemoteObjectRegistry.h:
     9        * TestWebKitAPI/Tests/WebKit2Cocoa/RemoteObjectRegistry.mm:
     10        (TEST):
     11        * TestWebKitAPI/Tests/WebKit2Cocoa/RemoteObjectRegistryPlugIn.mm:
     12        (-[RemoteObjectRegistryPlugIn takeSize:completionHandler:]):
     13
    1142017-02-08  Chris Dumez  <cdumez@apple.com>
    215
  • trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/RemoteObjectRegistry.h

    r204245 r211914  
    3636- (void)selectionAndClickInformationForClickAtPoint:(NSValue *)pointValue completionHandler:(void (^)(NSDictionary *))completionHandler;
    3737- (void)takeRange:(NSRange)range completionHandler:(void (^)(NSUInteger location, NSUInteger length))completionHandler;
     38- (void)takeSize:(CGSize)size completionHandler:(void (^)(CGFloat width, CGFloat height))completionHandler;
    3839- (void)doNotCallCompletionHandler:(void (^)())completionHandler;
    3940
  • trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/RemoteObjectRegistry.mm

    r204245 r211914  
    8686
    8787        isDone = false;
     88        [object takeSize:CGSizeMake(123.45, 678.91) completionHandler:^(CGFloat width, CGFloat height) {
     89            EXPECT_EQ(123.45, width);
     90            EXPECT_EQ(678.91, height);
     91            isDone = true;
     92        }];
     93        TestWebKitAPI::Util::run(&isDone);
     94
     95        isDone = false;
    8896
    8997        class DoneWhenDestroyed : public RefCounted<DoneWhenDestroyed> {
  • trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/RemoteObjectRegistryPlugIn.mm

    r204245 r211914  
    8282}
    8383
     84- (void)takeSize:(CGSize)size completionHandler:(void (^)(CGFloat width, CGFloat height))completionHandler
     85{
     86    completionHandler(size.width, size.height);
     87}
     88
    8489- (void)doNotCallCompletionHandler:(void (^)())completionHandler
    8590{
Note: See TracChangeset for help on using the changeset viewer.