Changeset 228354 in webkit


Ignore:
Timestamp:
Feb 9, 2018 9:43:36 PM (6 years ago)
Author:
jmarcell@apple.com
Message:

Cherry-pick r228253. rdar://problem/37408874

Location:
branches/safari-605-branch
Files:
4 edited
1 moved

Legend:

Unmodified
Added
Removed
  • branches/safari-605-branch/Source/WebKit/ChangeLog

    r228233 r228354  
     12018-02-09  Jason Marcell  <jmarcell@apple.com>
     2
     3        Cherry-pick r228253. rdar://problem/37408874
     4
     5    2018-02-07  Tim Horton  <timothy_horton@apple.com>
     6
     7            Evernote device management web view sometimes displays at the wrong scale
     8            https://bugs.webkit.org/show_bug.cgi?id=182590
     9            <rdar://problem/36633687>
     10
     11            Reviewed by Simon Fraser.
     12
     13            Evernote implements the WKWebView's scroll view's delegate method
     14            viewForZoomingInScrollView: and returns nil. This results in
     15            WKScrollView's zoomScale always returning 1, no matter what the
     16            WKContentView's actual scale is. This will result in us never updating
     17            the WKContentView's scale to 1. When loading a page that has a few
     18            scale changes during load but ends up at scale 1, we get stuck at whatever
     19            intermediate scale immediately preceded settling on 1.
     20
     21            Fix this by not forwarding viewForZoomingInScrollView: to the external
     22            WKScrollView delegate; we are in charge of the contents of the scroll
     23            view (including which view scrollView's zoomScale should track), and
     24            overriding viewForZoomingInScrollView: is only ever going to lead to
     25            a broken WebKit.
     26
     27            * UIProcess/ios/WKScrollView.mm:
     28            (shouldForwardScrollViewDelegateMethodToExternalDelegate):
     29            (-[WKScrollViewDelegateForwarder forwardInvocation:]):
     30            (-[WKScrollViewDelegateForwarder forwardingTargetForSelector:]):
     31
    1322018-02-07  Jason Marcell  <jmarcell@apple.com>
    233
  • branches/safari-605-branch/Source/WebKit/UIProcess/ios/WKScrollView.mm

    r220506 r228354  
    7676}
    7777
     78static BOOL shouldForwardScrollViewDelegateMethodToExternalDelegate(SEL selector)
     79{
     80    // We cannot forward viewForZoomingInScrollView: to the external delegate, because WebKit
     81    // owns the content of the scroll view, and depends on viewForZoomingInScrollView being the
     82    // content view. Any other view returned by the external delegate will break our behavior.
     83    if (sel_isEqual(selector, @selector(viewForZoomingInScrollView:)))
     84        return NO;
     85
     86    return YES;
     87}
     88
    7889- (void)forwardInvocation:(NSInvocation *)anInvocation
    7990{
     
    8192    SEL aSelector = [anInvocation selector];
    8293    BOOL internalDelegateWillRespond = [_internalDelegate respondsToSelector:aSelector];
    83     BOOL externalDelegateWillRespond = [externalDelegate respondsToSelector:aSelector];
     94    BOOL externalDelegateWillRespond = shouldForwardScrollViewDelegateMethodToExternalDelegate(aSelector) && [externalDelegate respondsToSelector:aSelector];
    8495
    8596    if (internalDelegateWillRespond && externalDelegateWillRespond)
     
    101112{
    102113    BOOL internalDelegateWillRespond = [_internalDelegate respondsToSelector:aSelector];
    103     BOOL externalDelegateWillRespond = [_externalDelegate.get() respondsToSelector:aSelector];
     114    BOOL externalDelegateWillRespond = shouldForwardScrollViewDelegateMethodToExternalDelegate(aSelector) && [_externalDelegate.get() respondsToSelector:aSelector];
    104115
    105116    if (internalDelegateWillRespond && !externalDelegateWillRespond)
  • branches/safari-605-branch/Tools/ChangeLog

    r228353 r228354  
     12018-02-09  Jason Marcell  <jmarcell@apple.com>
     2
     3        Cherry-pick r228253. rdar://problem/37408874
     4
     5    2018-02-07  Tim Horton  <timothy_horton@apple.com>
     6
     7            Evernote device management web view sometimes displays at the wrong scale
     8            https://bugs.webkit.org/show_bug.cgi?id=182590
     9            <rdar://problem/36633687>
     10
     11            Reviewed by Simon Fraser.
     12
     13            * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
     14            * TestWebKitAPI/Tests/ios/WKScrollViewDelegate.mm: Renamed from Tools/TestWebKitAPI/Tests/ios/WKScrollViewDelegateCrash.mm.
     15            (-[TestDelegateForScrollView dealloc]):
     16            (TestWebKitAPI::TEST):
     17            (-[WKScrollViewDelegateWithViewForZoomingOverridden viewForZoomingInScrollView:]):
     18            Add a test that failed before the change that ensures that we don't
     19            consult the external delegate for viewForZoomingInScrollView:, and that
     20            we succesfully update the scale even if it matches that of the view
     21            the external delegate returns for viewForZoomingInScrollView:.
     22
    1232018-02-09  Jason Marcell  <jmarcell@apple.com>
    224
  • branches/safari-605-branch/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj

    r227774 r228354  
    264264                5CE354D91E70DA5C00BEFE3B /* WKContentExtensionStore.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5CE354D81E70D9C300BEFE3B /* WKContentExtensionStore.mm */; };
    265265                5CEAB5E11FA939F400A77FAA /* _WKInputDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5CEAB5DF1FA937CB00A77FAA /* _WKInputDelegate.mm */; };
    266                 5E4B1D2E1D404C6100053621 /* WKScrollViewDelegateCrash.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5E4B1D2C1D404C6100053621 /* WKScrollViewDelegateCrash.mm */; };
     266                5E4B1D2E1D404C6100053621 /* WKScrollViewDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5E4B1D2C1D404C6100053621 /* WKScrollViewDelegate.mm */; };
    267267                631EFFF61E7B5E8D00D2EBB8 /* Geolocation.mm in Sources */ = {isa = PBXBuildFile; fileRef = 631EFFF51E7B5E8D00D2EBB8 /* Geolocation.mm */; };
    268268                634910E01E9D3FF300880309 /* CoreLocation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 634910DF1E9D3FF300880309 /* CoreLocation.framework */; };
     
    14311431                5CE354D81E70D9C300BEFE3B /* WKContentExtensionStore.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKContentExtensionStore.mm; sourceTree = "<group>"; };
    14321432                5CEAB5DF1FA937CB00A77FAA /* _WKInputDelegate.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = _WKInputDelegate.mm; sourceTree = "<group>"; };
    1433                 5E4B1D2C1D404C6100053621 /* WKScrollViewDelegateCrash.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = WKScrollViewDelegateCrash.mm; path = ../ios/WKScrollViewDelegateCrash.mm; sourceTree = "<group>"; };
     1433                5E4B1D2C1D404C6100053621 /* WKScrollViewDelegate.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = WKScrollViewDelegate.mm; path = ../ios/WKScrollViewDelegate.mm; sourceTree = "<group>"; };
    14341434                631EFFF51E7B5E8D00D2EBB8 /* Geolocation.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = Geolocation.mm; sourceTree = "<group>"; };
    14351435                634910DF1E9D3FF300880309 /* CoreLocation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreLocation.framework; path = System/Library/Frameworks/CoreLocation.framework; sourceTree = SDKROOT; };
     
    21652165                                2D21FE581F04642800B58E7D /* WKPDFViewStablePresentationUpdateCallback.mm */,
    21662166                                44817A2E1F0486BF00003810 /* WKRequestActivatedElementInfo.mm */,
    2167                                 5E4B1D2C1D404C6100053621 /* WKScrollViewDelegateCrash.mm */,
     2167                                5E4B1D2C1D404C6100053621 /* WKScrollViewDelegate.mm */,
    21682168                                51C683DD1EA134DB00650183 /* WKURLSchemeHandler-1.mm */,
    21692169                                5182C22D1F2BCB410059BA7C /* WKURLSchemeHandler-leaks.mm */,
     
    35023502                                7C83E0B71D0A64B800FEBCF3 /* MenuTypesForMouseEvents.cpp in Sources */,
    35033503                                5C0BF8941DD599C900B00328 /* MenuTypesForMouseEvents.mm in Sources */,
     3504                                5165FE04201EE620009F7EC3 /* MessagePortProviders.mm in Sources */,
    35043505                                A5B149DE1F5A19EA00C6DAFF /* MIMETypeRegistry.cpp in Sources */,
    35053506                                51CD1C6C1B38CE4300142CA5 /* ModalAlerts.mm in Sources */,
     
    35463547                                4647B1261EBA3B850041D7EF /* ProcessDidTerminate.cpp in Sources */,
    35473548                                7C83E0C11D0A652F00FEBCF3 /* ProvisionalURLNotChange.mm in Sources */,
    3548                                 5165FE04201EE620009F7EC3 /* MessagePortProviders.mm in Sources */,
    35493549                                7CCE7EC81A411A7E00447C4C /* PublicSuffix.mm in Sources */,
    35503550                                7C83E0C21D0A653500FEBCF3 /* QuickLook.mm in Sources */,
     
    36663666                                44817A2F1F0486BF00003810 /* WKRequestActivatedElementInfo.mm in Sources */,
    36673667                                7C83E0B51D0A649300FEBCF3 /* WKRetainPtr.cpp in Sources */,
    3668                                 5E4B1D2E1D404C6100053621 /* WKScrollViewDelegateCrash.mm in Sources */,
     3668                                5E4B1D2E1D404C6100053621 /* WKScrollViewDelegate.mm in Sources */,
    36693669                                7CCE7F221A411AE600447C4C /* WKString.cpp in Sources */,
    36703670                                7CCE7F1E1A411AE600447C4C /* WKStringJSString.cpp in Sources */,
  • branches/safari-605-branch/Tools/TestWebKitAPI/Tests/ios/WKScrollViewDelegate.mm

    r228353 r228354  
    11/*
    2  * Copyright (C) 2016 Apple Inc. All rights reserved.
     2 * Copyright (C) 2016-2018 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    3030#import "PlatformUtilities.h"
    3131#import "Test.h"
     32#import "TestWKWebView.h"
    3233#import <WebKit/WKWebView.h>
     34
     35// WKScrollViewDelegateCrash
    3336
    3437static bool delegateIsDeallocated;
     
    6669}
    6770
     71// WKScrollViewDelegateCannotOverrideViewForZooming
     72
     73static BOOL didCallViewForZoomingInScrollView;
     74
     75@interface WKScrollViewDelegateWithViewForZoomingOverridden : NSObject <UIScrollViewDelegate>
     76@property (nonatomic, assign) CGFloat overrideScale;
     77@end
     78
     79@implementation WKScrollViewDelegateWithViewForZoomingOverridden
     80
     81- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView
     82{
     83    didCallViewForZoomingInScrollView = true;
     84
     85    UIView *fakeZoomingView = [[UIView alloc] init];
     86    fakeZoomingView.layer.affineTransform = CGAffineTransformMakeScale(_overrideScale, _overrideScale);
     87    return fakeZoomingView;
     88}
     89
     90@end
     91
     92namespace TestWebKitAPI {
     93
     94TEST(WKWebView, WKScrollViewDelegateCannotOverrideViewForZooming)
     95{
     96    TestWKWebView *webView = [[TestWKWebView alloc] init];
     97    WKScrollViewDelegateWithViewForZoomingOverridden *delegateForScrollView = [[WKScrollViewDelegateWithViewForZoomingOverridden alloc] init];
     98    @autoreleasepool {
     99        webView.scrollView.delegate = delegateForScrollView;
     100    }
     101
     102    [webView synchronouslyLoadHTMLString:@"<meta name='viewport' content='initial-scale=1'>"];
     103    [webView waitForNextPresentationUpdate];
     104
     105    // Have WKScrollView's external delegate return a view with scale=2 from viewForZoomingInScrollView.
     106    delegateForScrollView.overrideScale = 2;
     107
     108    [webView synchronouslyLoadHTMLString:@"<meta name='viewport' content='initial-scale=2'>"];
     109    [webView waitForNextPresentationUpdate];
     110
     111    @autoreleasepool {
     112        webView.scrollView.delegate = nil;
     113    }
     114
     115    EXPECT_FALSE(didCallViewForZoomingInScrollView);
     116    EXPECT_EQ(2, [[webView scrollView] zoomScale]);
     117}
     118
     119}
     120
    68121#endif
Note: See TracChangeset for help on using the changeset viewer.