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;
@synthesize title = _title;
@synthesize translationController = _translationController;
@synthesize UIDelegate = _UIDelegate;
@synthesize scrollView = _scrollView;
@synthesize legacyScrollView = _legacyScrollView;
@synthesize visibleURL = _visibleURL;
@synthesize visibleSSLStatus = _visibleSSLStatus;
......@@ -243,7 +243,7 @@ BOOL gChromeLongPressAndForceTouchHandlingEnabled = YES;
if (self) {
_configuration = configuration;
[_configuration registerWebView:self];
_scrollView = [[CWVScrollView alloc] init];
_legacyScrollView = [[CWVScrollView alloc] init];
[self resetWebStateWithSessionStorage:nil
WKConfiguration:wkConfiguration
......@@ -252,6 +252,10 @@ BOOL gChromeLongPressAndForceTouchHandlingEnabled = YES;
return self;
}
- (UIScrollView*)scrollView {
return [_webState->GetWebViewProxy().scrollViewProxy asUIScrollView];
}
- (BOOL)allowsBackForwardNavigationGestures {
return _webState->GetWebViewProxy().allowsBackForwardNavigationGestures;
}
......@@ -809,7 +813,7 @@ BOOL gChromeLongPressAndForceTouchHandlingEnabled = YES;
_webState->GetWebViewProxy().allowsBackForwardNavigationGestures =
allowsBackForwardNavigationGestures;
_scrollView.proxy = _webState.get()->GetWebViewProxy().scrollViewProxy;
_legacyScrollView.proxy = _webState.get()->GetWebViewProxy().scrollViewProxy;
if (_translationController) {
id<CWVTranslationControllerDelegate> delegate =
......
......@@ -111,7 +111,17 @@ CWV_EXPORT
@property(nonatomic, readonly) double estimatedProgress;
// 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
// back-forward list navigations.
......
......@@ -21,12 +21,13 @@ NSString* const kWebViewShellAddressFieldAccessibilityLabel = @"Address field";
NSString* const kWebViewShellJavaScriptDialogTextFieldAccessibilityIdentifier =
@"WebViewShellJavaScriptDialogTextFieldAccessibilityIdentifier";
@interface ShellViewController ()<CWVDownloadTaskDelegate,
CWVNavigationDelegate,
CWVUIDelegate,
CWVScriptCommandHandler,
CWVSyncControllerDelegate,
UITextFieldDelegate>
@interface ShellViewController () <CWVDownloadTaskDelegate,
CWVNavigationDelegate,
CWVUIDelegate,
CWVScriptCommandHandler,
CWVSyncControllerDelegate,
UIScrollViewDelegate,
UITextFieldDelegate>
// Header containing navigation buttons and |field|.
@property(nonatomic, strong) UIView* headerBackgroundView;
// Header containing navigation buttons and |field|.
......@@ -268,6 +269,14 @@ NSString* const kWebViewShellJavaScriptDialogTextFieldAccessibilityIdentifier =
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 {
return UIStatusBarStyleLightContent;
}
......@@ -682,6 +691,7 @@ NSString* const kWebViewShellJavaScriptDialogTextFieldAccessibilityIdentifier =
webView.translationController.delegate = _translationDelegate;
_autofillDelegate = [[ShellAutofillDelegate alloc] init];
webView.autofillController.delegate = _autofillDelegate;
webView.scrollView.delegate = self;
// Constraints.
webView.translatesAutoresizingMaskIntoConstraints = NO;
......@@ -1125,4 +1135,10 @@ NSString* const kWebViewShellJavaScriptDialogTextFieldAccessibilityIdentifier =
NSLog(@"%@", NSStringFromSelector(_cmd));
}
#pragma mark UIScrollViewDelegate
- (void)scrollViewWillBeginDragging:(UIScrollView*)scrollView {
NSLog(@"%@", NSStringFromSelector(_cmd));
}
@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