Commit 253eacc4 authored by Hiroshi Ichikawa's avatar Hiroshi Ichikawa Committed by Commit Bot

Let CWVWebView.scrollView be typed UIScrollView.

It is now implemented as a proxy object (CRWWebViewScrollViewProxy)
which pretends itself to be a UIScrollView, instead of CWVScrollView.

Define CWVWebView.legacyScrollView to allow to fall back to the original
implementation in runtime temporarily.

Change-Id: I2993ab2ccf78de09412c9f607a74165fea8eae2f
Bug: 1023250
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2137201
Commit-Queue: Hiroshi Ichikawa <ichikawa@chromium.org>
Auto-Submit: Hiroshi Ichikawa <ichikawa@chromium.org>
Reviewed-by: default avatarJohn Wu <jzw@chromium.org>
Cr-Commit-Position: refs/heads/master@{#762718}
parent 6517fa74
...@@ -177,7 +177,7 @@ BOOL gChromeLongPressAndForceTouchHandlingEnabled = YES; ...@@ -177,7 +177,7 @@ BOOL gChromeLongPressAndForceTouchHandlingEnabled = YES;
@synthesize title = _title; @synthesize title = _title;
@synthesize translationController = _translationController; @synthesize translationController = _translationController;
@synthesize UIDelegate = _UIDelegate; @synthesize UIDelegate = _UIDelegate;
@synthesize scrollView = _scrollView; @synthesize legacyScrollView = _legacyScrollView;
@synthesize visibleURL = _visibleURL; @synthesize visibleURL = _visibleURL;
@synthesize visibleSSLStatus = _visibleSSLStatus; @synthesize visibleSSLStatus = _visibleSSLStatus;
...@@ -243,7 +243,7 @@ BOOL gChromeLongPressAndForceTouchHandlingEnabled = YES; ...@@ -243,7 +243,7 @@ BOOL gChromeLongPressAndForceTouchHandlingEnabled = YES;
if (self) { if (self) {
_configuration = configuration; _configuration = configuration;
[_configuration registerWebView:self]; [_configuration registerWebView:self];
_scrollView = [[CWVScrollView alloc] init]; _legacyScrollView = [[CWVScrollView alloc] init];
[self resetWebStateWithSessionStorage:nil [self resetWebStateWithSessionStorage:nil
WKConfiguration:wkConfiguration WKConfiguration:wkConfiguration
...@@ -252,6 +252,10 @@ BOOL gChromeLongPressAndForceTouchHandlingEnabled = YES; ...@@ -252,6 +252,10 @@ BOOL gChromeLongPressAndForceTouchHandlingEnabled = YES;
return self; return self;
} }
- (UIScrollView*)scrollView {
return [_webState->GetWebViewProxy().scrollViewProxy asUIScrollView];
}
- (BOOL)allowsBackForwardNavigationGestures { - (BOOL)allowsBackForwardNavigationGestures {
return _webState->GetWebViewProxy().allowsBackForwardNavigationGestures; return _webState->GetWebViewProxy().allowsBackForwardNavigationGestures;
} }
...@@ -809,7 +813,7 @@ BOOL gChromeLongPressAndForceTouchHandlingEnabled = YES; ...@@ -809,7 +813,7 @@ BOOL gChromeLongPressAndForceTouchHandlingEnabled = YES;
_webState->GetWebViewProxy().allowsBackForwardNavigationGestures = _webState->GetWebViewProxy().allowsBackForwardNavigationGestures =
allowsBackForwardNavigationGestures; allowsBackForwardNavigationGestures;
_scrollView.proxy = _webState.get()->GetWebViewProxy().scrollViewProxy; _legacyScrollView.proxy = _webState.get()->GetWebViewProxy().scrollViewProxy;
if (_translationController) { if (_translationController) {
id<CWVTranslationControllerDelegate> delegate = id<CWVTranslationControllerDelegate> delegate =
......
...@@ -111,7 +111,17 @@ CWV_EXPORT ...@@ -111,7 +111,17 @@ CWV_EXPORT
@property(nonatomic, readonly) double estimatedProgress; @property(nonatomic, readonly) double estimatedProgress;
// The scroll view associated with the web view. // The scroll view associated with the web view.
@property(nonatomic, readonly) CWVScrollView* scrollView; //
// It is reset on state restoration.
@property(nonatomic, readonly) UIScrollView* scrollView;
// DEPRECATED: Use |scrollView| instead.
//
// The old implementation of the scroll view associated with the web view.
//
// TODO(crbug.com/1023250): Delete this once clients migrate to the new
// |scrollView|.
@property(nonatomic, readonly) CWVScrollView* legacyScrollView;
// A Boolean value indicating whether horizontal swipe gestures will trigger // A Boolean value indicating whether horizontal swipe gestures will trigger
// back-forward list navigations. // back-forward list navigations.
......
...@@ -21,12 +21,13 @@ NSString* const kWebViewShellAddressFieldAccessibilityLabel = @"Address field"; ...@@ -21,12 +21,13 @@ NSString* const kWebViewShellAddressFieldAccessibilityLabel = @"Address field";
NSString* const kWebViewShellJavaScriptDialogTextFieldAccessibilityIdentifier = NSString* const kWebViewShellJavaScriptDialogTextFieldAccessibilityIdentifier =
@"WebViewShellJavaScriptDialogTextFieldAccessibilityIdentifier"; @"WebViewShellJavaScriptDialogTextFieldAccessibilityIdentifier";
@interface ShellViewController ()<CWVDownloadTaskDelegate, @interface ShellViewController () <CWVDownloadTaskDelegate,
CWVNavigationDelegate, CWVNavigationDelegate,
CWVUIDelegate, CWVUIDelegate,
CWVScriptCommandHandler, CWVScriptCommandHandler,
CWVSyncControllerDelegate, CWVSyncControllerDelegate,
UITextFieldDelegate> UIScrollViewDelegate,
UITextFieldDelegate>
// Header containing navigation buttons and |field|. // Header containing navigation buttons and |field|.
@property(nonatomic, strong) UIView* headerBackgroundView; @property(nonatomic, strong) UIView* headerBackgroundView;
// Header containing navigation buttons and |field|. // Header containing navigation buttons and |field|.
...@@ -268,6 +269,14 @@ NSString* const kWebViewShellJavaScriptDialogTextFieldAccessibilityIdentifier = ...@@ -268,6 +269,14 @@ NSString* const kWebViewShellJavaScriptDialogTextFieldAccessibilityIdentifier =
self.webView = [self createWebViewWithConfiguration:configuration]; self.webView = [self createWebViewWithConfiguration:configuration];
} }
- (void)applicationFinishedRestoringState {
[super applicationFinishedRestoringState];
// The scroll view is reset on state restoration. So the delegate must be
// reassigned.
self.webView.scrollView.delegate = self;
}
- (UIStatusBarStyle)preferredStatusBarStyle { - (UIStatusBarStyle)preferredStatusBarStyle {
return UIStatusBarStyleLightContent; return UIStatusBarStyleLightContent;
} }
...@@ -682,6 +691,7 @@ NSString* const kWebViewShellJavaScriptDialogTextFieldAccessibilityIdentifier = ...@@ -682,6 +691,7 @@ NSString* const kWebViewShellJavaScriptDialogTextFieldAccessibilityIdentifier =
webView.translationController.delegate = _translationDelegate; webView.translationController.delegate = _translationDelegate;
_autofillDelegate = [[ShellAutofillDelegate alloc] init]; _autofillDelegate = [[ShellAutofillDelegate alloc] init];
webView.autofillController.delegate = _autofillDelegate; webView.autofillController.delegate = _autofillDelegate;
webView.scrollView.delegate = self;
// Constraints. // Constraints.
webView.translatesAutoresizingMaskIntoConstraints = NO; webView.translatesAutoresizingMaskIntoConstraints = NO;
...@@ -1125,4 +1135,10 @@ NSString* const kWebViewShellJavaScriptDialogTextFieldAccessibilityIdentifier = ...@@ -1125,4 +1135,10 @@ NSString* const kWebViewShellJavaScriptDialogTextFieldAccessibilityIdentifier =
NSLog(@"%@", NSStringFromSelector(_cmd)); NSLog(@"%@", NSStringFromSelector(_cmd));
} }
#pragma mark UIScrollViewDelegate
- (void)scrollViewWillBeginDragging:(UIScrollView*)scrollView {
NSLog(@"%@", NSStringFromSelector(_cmd));
}
@end @end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment