0

Delete CWVScrollView in ios/web_view

No longer used by any client.

Change-Id: I836b27d70191e00746157050de0089723d3f2c1c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2660078
Reviewed-by: Hiroshi Ichikawa <ichikawa@chromium.org>
Commit-Queue: John Wu <jzw@chromium.org>
Cr-Commit-Position: refs/heads/master@{#849190}
This commit is contained in:
John Z Wu
2021-02-01 19:00:22 +00:00
committed by Chromium LUCI CQ
parent 41a7d1cda0
commit c04e5643ed
9 changed files with 2 additions and 424 deletions

@@ -63,8 +63,6 @@ ios_web_view_public_headers = [
"public/cwv_preferences.h",
"public/cwv_preview_element_info.h",
"public/cwv_script_command.h",
"public/cwv_scroll_view.h",
"public/cwv_scroll_view_delegate.h",
"public/cwv_ssl_status.h",
"public/cwv_sync_controller.h",
"public/cwv_sync_controller_data_source.h",
@@ -142,8 +140,6 @@ source_set("web_view_sources") {
"internal/cwv_preview_element_info_internal.h",
"internal/cwv_script_command.mm",
"internal/cwv_script_command_internal.h",
"internal/cwv_scroll_view.mm",
"internal/cwv_scroll_view_internal.h",
"internal/cwv_ssl_status.mm",
"internal/cwv_ssl_status_internal.h",
"internal/cwv_user_content_controller.mm",
@@ -419,7 +415,6 @@ test("ios_web_view_unittests") {
"internal/cwv_html_element_unittest.mm",
"internal/cwv_preferences_unittest.mm",
"internal/cwv_preview_element_info_unittest.mm",
"internal/cwv_scroll_view_unittest.mm",
"internal/cwv_ssl_status_unittest.mm",
"internal/cwv_web_view_configuration_unittest.mm",
"internal/metrics/cwv_metrics_provider_unittest.mm",

@@ -1,205 +0,0 @@
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#import "ios/web_view/public/cwv_scroll_view.h"
#import "ios/web/public/ui/crw_web_view_scroll_view_proxy.h"
#import "ios/web_view/internal/cwv_scroll_view_internal.h"
#import "ios/web_view/public/cwv_scroll_view_delegate.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
@interface CWVScrollView ()<CRWWebViewScrollViewProxyObserver>
// For KVO compliance, redefines the property as readwrite and calls its setter
// when the value changes, instead of defining a getter which directly calls
// _proxy.contentSize.
@property(nonatomic, readwrite) CGSize contentSize;
@end
@implementation CWVScrollView
@synthesize contentSize = _contentSize;
@synthesize contentOffset = _contentOffset;
@synthesize delegate = _delegate;
@synthesize proxy = _proxy;
- (void)setProxy:(nullable CRWWebViewScrollViewProxy*)proxy {
[_proxy removeObserver:self];
_proxy = proxy;
self.contentSize = _proxy.contentSize;
[self updateContentOffset];
[_proxy addObserver:self];
}
- (void)setContentOffset:(CGPoint)contentOffset {
_proxy.contentOffset = contentOffset;
[self updateContentOffset];
}
- (UIEdgeInsets)scrollIndicatorInsets {
return _proxy.scrollIndicatorInsets;
}
- (void)setScrollIndicatorInsets:(UIEdgeInsets)scrollIndicatorInsets {
_proxy.scrollIndicatorInsets = scrollIndicatorInsets;
}
- (CGRect)bounds {
return {_proxy.contentOffset, _proxy.frame.size};
}
- (BOOL)isDecelerating {
return _proxy.decelerating;
}
- (BOOL)isDragging {
return _proxy.dragging;
}
- (BOOL)isTracking {
return _proxy.tracking;
}
- (BOOL)scrollsToTop {
return _proxy.scrollsToTop;
}
- (void)setScrollsToTop:(BOOL)scrollsToTop {
_proxy.scrollsToTop = scrollsToTop;
}
- (BOOL)bounces {
return _proxy.bounces;
}
- (void)setBounces:(BOOL)bounces {
_proxy.bounces = bounces;
}
- (UIScrollViewContentInsetAdjustmentBehavior)contentInsetAdjustmentBehavior
API_AVAILABLE(ios(11.0)) {
return _proxy.contentInsetAdjustmentBehavior;
}
- (void)setContentInsetAdjustmentBehavior:
(UIScrollViewContentInsetAdjustmentBehavior)contentInsetAdjustmentBehavior
API_AVAILABLE(ios(11.0)) {
_proxy.contentInsetAdjustmentBehavior = contentInsetAdjustmentBehavior;
}
- (UIPanGestureRecognizer*)panGestureRecognizer {
return _proxy.panGestureRecognizer;
}
- (NSArray<__kindof UIView*>*)subviews {
return _proxy.subviews;
}
- (UIEdgeInsets)contentInset {
return _proxy.contentInset;
}
- (void)setContentInset:(UIEdgeInsets)contentInset {
_proxy.contentInset = contentInset;
}
- (void)setContentOffset:(CGPoint)contentOffset animated:(BOOL)animated {
[_proxy setContentOffset:contentOffset animated:animated];
[self updateContentOffset];
}
- (void)addGestureRecognizer:(UIGestureRecognizer*)gestureRecognizer {
[_proxy addGestureRecognizer:gestureRecognizer];
}
- (void)removeGestureRecognizer:(UIGestureRecognizer*)gestureRecognizer {
[_proxy removeGestureRecognizer:gestureRecognizer];
}
#pragma mark - NSObject
- (void)dealloc {
// Removes |self| from |_proxy|'s observers. Otherwise |_proxy| will keep a
// dangling pointer to |self| and cause SEGV later.
[_proxy removeObserver:self];
}
#pragma mark - CRWWebViewScrollViewObserver
- (void)webViewScrollViewWillBeginDragging:
(CRWWebViewScrollViewProxy*)webViewScrollViewProxy {
SEL selector = @selector(scrollViewWillBeginDragging:);
if ([_delegate respondsToSelector:selector]) {
[_delegate scrollViewWillBeginDragging:self];
}
}
- (void)webViewScrollViewWillEndDragging:
(CRWWebViewScrollViewProxy*)webViewScrollViewProxy
withVelocity:(CGPoint)velocity
targetContentOffset:(inout CGPoint*)targetContentOffset {
SEL selector =
@selector(scrollViewWillEndDragging:withVelocity:targetContentOffset:);
if ([_delegate respondsToSelector:selector]) {
[_delegate scrollViewWillEndDragging:self
withVelocity:velocity
targetContentOffset:targetContentOffset];
}
}
- (void)webViewScrollViewDidScroll:
(CRWWebViewScrollViewProxy*)webViewScrollViewProxy {
[self updateContentOffset];
SEL selector = @selector(scrollViewDidScroll:);
if ([_delegate respondsToSelector:selector]) {
[_delegate scrollViewDidScroll:self];
}
}
- (void)webViewScrollViewDidEndDecelerating:
(CRWWebViewScrollViewProxy*)webViewScrollViewProxy {
SEL selector = @selector(scrollViewDidEndDecelerating:);
if ([_delegate respondsToSelector:selector]) {
[_delegate scrollViewDidEndDecelerating:self];
}
}
- (void)webViewScrollViewWillBeginZooming:
(CRWWebViewScrollViewProxy*)webViewScrollViewProxy {
SEL selector = @selector(scrollViewWillBeginZooming:);
if ([_delegate respondsToSelector:selector]) {
[_delegate scrollViewWillBeginZooming:self];
}
}
- (BOOL)webViewScrollViewShouldScrollToTop:
(CRWWebViewScrollViewProxy*)webViewScrollViewProxy {
if ([_delegate respondsToSelector:@selector(scrollViewShouldScrollToTop:)]) {
return [_delegate scrollViewShouldScrollToTop:self];
}
return YES;
}
- (void)webViewScrollViewDidResetContentSize:
(CRWWebViewScrollViewProxy*)webViewScrollViewProxy {
self.contentSize = _proxy.contentSize;
}
- (void)updateContentOffset {
[self willChangeValueForKey:@"contentOffset"];
_contentOffset = _proxy.contentOffset;
[self didChangeValueForKey:@"contentOffset"];
}
+ (BOOL)automaticallyNotifiesObserversForKey:(NSString*)key {
if ([key isEqualToString:@"contentOffset"]) {
return NO;
}
return [super automaticallyNotifiesObserversForKey:key];
}
@end

@@ -1,25 +0,0 @@
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef IOS_WEB_VIEW_INTERNAL_CWV_SCROLL_VIEW_INTERNAL_H_
#define IOS_WEB_VIEW_INTERNAL_CWV_SCROLL_VIEW_INTERNAL_H_
#import <Foundation/Foundation.h>
#import "ios/web_view/public/cwv_scroll_view.h"
NS_ASSUME_NONNULL_BEGIN
@class CRWWebViewScrollViewProxy;
@interface CWVScrollView ()
// Operations to this scroll view are delegated to this proxy.
@property(nonatomic, weak, readwrite) CRWWebViewScrollViewProxy* proxy;
@end
NS_ASSUME_NONNULL_END
#endif // IOS_WEB_VIEW_INTERNAL_CWV_SCROLL_VIEW_INTERNAL_H_

@@ -1,71 +0,0 @@
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#import "ios/web_view/internal/cwv_scroll_view_internal.h"
#import <UIKit/UIKit.h>
#import "ios/web/public/ui/crw_web_view_scroll_view_proxy.h"
#import "ios/web_view/public/cwv_scroll_view_delegate.h"
#include "testing/gtest/include/gtest/gtest.h"
#import "testing/gtest_mac.h"
#include "testing/platform_test.h"
#import "third_party/ocmock/OCMock/OCMock.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
namespace ios_web_view {
class CWVScrollViewTest : public PlatformTest {
protected:
CWVScrollViewTest() {
scroll_view_ = [[CWVScrollView alloc] init];
scroll_view_proxy_ = [[CRWWebViewScrollViewProxy alloc] init];
scroll_view_.proxy = scroll_view_proxy_;
ui_scroll_view_ = [[UIScrollView alloc] init];
[scroll_view_proxy_ setScrollView:ui_scroll_view_];
}
CWVScrollView* scroll_view_;
UIScrollView* ui_scroll_view_;
CRWWebViewScrollViewProxy* scroll_view_proxy_;
};
// Tests CWVScrollView delegate callbacks.
TEST_F(CWVScrollViewTest, DelegateCallbacks) {
id delegate = OCMProtocolMock(@protocol(CWVScrollViewDelegate));
scroll_view_.delegate = delegate;
[[delegate expect] scrollViewWillBeginDragging:scroll_view_];
[ui_scroll_view_.delegate scrollViewWillBeginDragging:ui_scroll_view_];
CGPoint targetContentOffset;
[[delegate expect] scrollViewWillEndDragging:scroll_view_
withVelocity:CGPointZero
targetContentOffset:&targetContentOffset];
[ui_scroll_view_.delegate scrollViewWillEndDragging:ui_scroll_view_
withVelocity:CGPointZero
targetContentOffset:&targetContentOffset];
[[delegate expect] scrollViewDidScroll:scroll_view_];
[ui_scroll_view_.delegate scrollViewDidScroll:ui_scroll_view_];
[[delegate expect] scrollViewDidEndDecelerating:scroll_view_];
[ui_scroll_view_.delegate scrollViewDidEndDecelerating:ui_scroll_view_];
[[delegate expect] scrollViewShouldScrollToTop:scroll_view_];
[ui_scroll_view_.delegate scrollViewShouldScrollToTop:ui_scroll_view_];
[[delegate expect] scrollViewWillBeginZooming:scroll_view_];
[ui_scroll_view_.delegate scrollViewWillBeginZooming:ui_scroll_view_
withView:nil];
[delegate verify];
}
} // namespace ios_web_view

@@ -48,7 +48,6 @@
#import "ios/web_view/internal/cwv_html_element_internal.h"
#import "ios/web_view/internal/cwv_navigation_action_internal.h"
#import "ios/web_view/internal/cwv_script_command_internal.h"
#import "ios/web_view/internal/cwv_scroll_view_internal.h"
#import "ios/web_view/internal/cwv_ssl_status_internal.h"
#import "ios/web_view/internal/cwv_web_view_configuration_internal.h"
#import "ios/web_view/internal/language/web_view_url_language_histogram_factory.h"
@@ -177,7 +176,6 @@ BOOL gChromeLongPressAndForceTouchHandlingEnabled = YES;
@synthesize title = _title;
@synthesize translationController = _translationController;
@synthesize UIDelegate = _UIDelegate;
@synthesize legacyScrollView = _legacyScrollView;
@synthesize visibleURL = _visibleURL;
@synthesize visibleSSLStatus = _visibleSSLStatus;
@@ -243,7 +241,6 @@ BOOL gChromeLongPressAndForceTouchHandlingEnabled = YES;
if (self) {
_configuration = configuration;
[_configuration registerWebView:self];
_legacyScrollView = [[CWVScrollView alloc] init];
[self resetWebStateWithSessionStorage:nil
WKConfiguration:wkConfiguration
@@ -820,8 +817,6 @@ BOOL gChromeLongPressAndForceTouchHandlingEnabled = YES;
_webState->GetWebViewProxy().allowsBackForwardNavigationGestures =
allowsBackForwardNavigationGestures;
_legacyScrollView.proxy = _webState.get()->GetWebViewProxy().scrollViewProxy;
if (_translationController) {
id<CWVTranslationControllerDelegate> delegate =
_translationController.delegate;

@@ -1,65 +0,0 @@
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef IOS_WEB_VIEW_PUBLIC_CWV_SCROLL_VIEW_H_
#define IOS_WEB_VIEW_PUBLIC_CWV_SCROLL_VIEW_H_
#import <CoreGraphics/CoreGraphics.h>
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import "cwv_export.h"
NS_ASSUME_NONNULL_BEGIN
@protocol CWVScrollViewDelegate;
// Scroll view inside the web view. This is not a subclass of UIScrollView
// because the underlying //ios/web API only exposes a proxy object of the
// scroll view, not the raw UIScrollView.
//
// These methods are forwarded to the internal UIScrollView. Please see the
// <UIKit/UIScrollView.h> documentation for details about the following methods.
CWV_EXPORT
@interface CWVScrollView : NSObject
// Not KVO compliant.
@property(nonatomic, readonly) CGRect bounds;
@property(nonatomic) UIEdgeInsets scrollIndicatorInsets;
@property(nonatomic, weak) id<CWVScrollViewDelegate> delegate;
@property(nonatomic, readonly, getter=isDecelerating) BOOL decelerating;
@property(nonatomic, readonly, getter=isDragging) BOOL dragging;
@property(nonatomic, readonly, getter=isTracking) BOOL tracking;
@property(nonatomic) BOOL scrollsToTop;
@property(nonatomic) BOOL bounces;
@property(nonatomic)
UIScrollViewContentInsetAdjustmentBehavior contentInsetAdjustmentBehavior
API_AVAILABLE(ios(11.0));
@property(nonatomic, readonly) UIPanGestureRecognizer* panGestureRecognizer;
@property(nonatomic, readonly, copy) NSArray<__kindof UIView*>* subviews;
// KVO compliant.
@property(nonatomic) CGPoint contentOffset;
@property(nonatomic, readonly) CGSize contentSize;
// Be careful when using this property. There's a bug with the
// underlying WKWebView where the web view does not respect contentInsets
// properly when laying out content and calculating innerHeight for Javascript.
// Content is laid out based on the entire height of the web view rather than
// the height between the top and bottom insets.
// https://bugs.webkit.org/show_bug.cgi?id=134230
// rdar://23584409 (not available on Open Radar)
//
// Not KVO compliant.
@property(nonatomic) UIEdgeInsets contentInset;
- (void)setContentOffset:(CGPoint)contentOffset animated:(BOOL)animated;
- (void)addGestureRecognizer:(UIGestureRecognizer*)gestureRecognizer;
- (void)removeGestureRecognizer:(UIGestureRecognizer*)gestureRecognizer;
@end
NS_ASSUME_NONNULL_END
#endif // IOS_WEB_VIEW_PUBLIC_CWV_SCROLL_VIEW_H_

@@ -1,37 +0,0 @@
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef IOS_WEB_VIEW_PUBLIC_CWV_SCROLL_VIEW_DELEGATE_H_
#define IOS_WEB_VIEW_PUBLIC_CWV_SCROLL_VIEW_DELEGATE_H_
#import <CoreGraphics/CoreGraphics.h>
NS_ASSUME_NONNULL_BEGIN
@class CWVScrollView;
// Delegete for CWVScrollView.
//
// These methods are forwarded from the internal UIScrollViewDelegate. Please
// see the <UIKit/UIScrollViewDelegate.h> documentation for details about the
// following methods.
@protocol CWVScrollViewDelegate<NSObject>
@optional
- (void)scrollViewWillBeginDragging:(CWVScrollView*)scrollView;
- (void)scrollViewWillEndDragging:(CWVScrollView*)scrollView
withVelocity:(CGPoint)velocity
targetContentOffset:(inout CGPoint*)targetContentOffset;
- (void)scrollViewDidScroll:(CWVScrollView*)scrollView;
- (void)scrollViewDidEndDecelerating:(CWVScrollView*)scrollView;
- (BOOL)scrollViewShouldScrollToTop:(CWVScrollView*)scrollView;
// The equivalent in UIScrollViewDelegate also takes a parameter (UIView*)view,
// but CWVScrollViewDelegate doesn't expose it for flexibility of future
// implementation.
- (void)scrollViewWillBeginZooming:(CWVScrollView*)webViewScrollViewProxy;
@end
NS_ASSUME_NONNULL_END
#endif // IOS_WEB_VIEW_PUBLIC_CWV_SCROLL_VIEW_DELEGATE_H_

@@ -16,7 +16,6 @@ NS_ASSUME_NONNULL_BEGIN
@class CWVBackForwardList;
@class CWVBackForwardListItem;
@class CWVScriptCommand;
@class CWVScrollView;
@class CWVTranslationController;
@class CWVWebViewConfiguration;
@protocol CWVNavigationDelegate;
@@ -115,14 +114,6 @@ CWV_EXPORT
// 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.
@property(nonatomic) BOOL allowsBackForwardNavigationGestures;

@@ -17,11 +17,11 @@
namespace ios_web_view {
// Tests that the KVO compliant properties of CWVScrollView correctly report
// Tests that the KVO compliant properties of UIScrollView correctly report
// changes.
typedef ios_web_view::WebViewInttestBase ScrollViewKvoTest;
// Tests that CWVScrollView correctly reports |contentOffset| state.
// Tests that UIScrollView correctly reports |contentOffset| state.
TEST_F(ScrollViewKvoTest, contentOffset) {
Observer* offset_observer = [[Observer alloc] init];
[offset_observer setObservedObject:web_view_.scrollView