Commit 53d66de7 authored by Hiroshi Ichikawa's avatar Hiroshi Ichikawa Committed by Commit Bot

Complete the list of preserved properties in CRWWebViewScrollViewProxy.

Bug: 1023250
Change-Id: I9105894e5f3544cb52ef686b1abb8753455b3e6c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2022023Reviewed-by: default avatarEugene But <eugenebut@chromium.org>
Commit-Queue: Hiroshi Ichikawa <ichikawa@chromium.org>
Cr-Commit-Position: refs/heads/master@{#736210}
parent f8160da7
...@@ -114,28 +114,16 @@ ...@@ -114,28 +114,16 @@
CRWPropertiesStore* _propertiesStore; CRWPropertiesStore* _propertiesStore;
} }
- (instancetype)init { // Returns a new instance of CRWPropertiesStore used in this class.
self = [super init]; + (CRWPropertiesStore*)propertiesStore {
if (self) { CRWPropertiesStore* store = [[CRWPropertiesStore alloc] init];
Protocol* protocol = @protocol(CRWWebViewScrollViewProxyObserver);
_observers =
static_cast<CRBProtocolObservers<CRWWebViewScrollViewProxyObserver>*>(
[CRBProtocolObservers observersWithProtocol:protocol]);
_delegateProxy = [[CRWWebViewScrollViewDelegateProxy alloc]
initWithScrollViewProxy:self];
_keyValueObserverForwarders = [[NSMutableDictionary alloc] init];
if (base::FeatureList::IsEnabled(
web::features::kPreserveScrollViewProperties)) {
_propertiesStore = [[CRWPropertiesStore alloc] init];
// A list of properties preserved on resetting the underlying scroll view. // A list of properties preserved on resetting the underlying scroll view.
// //
// The underlying scroll view can be nil or can be reassigned. Properties // The underlying scroll view can be nil or can be reassigned. Properties
// of the underlying scroll view are usually not preserved when the scroll // of the underlying scroll view are usually not preserved when the scroll
// view is reassigned. Properties listed here will be preserved i.e.: // view is reassigned. Properties listed here will be preserved i.e.:
// - If the property is assigned while the underlying scroll view is // - If the property is assigned while the underlying scroll view is nil,
// nil,
// the assignment is applied when the underlying scroll view is // the assignment is applied when the underlying scroll view is
// assigned. // assigned.
// - The property is preserved when the underlying scroll view is // - The property is preserved when the underlying scroll view is
...@@ -149,21 +137,119 @@ ...@@ -149,21 +137,119 @@
// view of a web view. e.g., |frame| and |subviews| do not meet this // view of a web view. e.g., |frame| and |subviews| do not meet this
// condition because they are managed by the web view. // condition because they are managed by the web view.
// //
// TODO(crbug.com/1023250): Make this list comprehensive. // Properties not explicitly declared in CRWWebViewScrollViewProxy can still
[_propertiesStore // be accessed via -asUIScrollView, so they should be preserved as well.
registerNonObjectPropertyWithGetter:@selector
(isDirectionalLockEnabled) // UIScrollView properties.
[store registerNonObjectPropertyWithGetter:@selector(isScrollEnabled)
setter:@selector(setScrollEnabled:)
type:@encode(BOOL)];
[store
registerNonObjectPropertyWithGetter:@selector(isDirectionalLockEnabled)
setter:@selector(setDirectionalLockEnabled:)
type:@encode(BOOL)];
[store registerNonObjectPropertyWithGetter:@selector(isPagingEnabled)
setter:@selector(setPagingEnabled:)
type:@encode(BOOL)];
[store registerNonObjectPropertyWithGetter:@selector(scrollsToTop)
setter:@selector(setScrollsToTop:)
type:@encode(BOOL)];
[store registerNonObjectPropertyWithGetter:@selector(bounces)
setter:@selector(setBounces:)
type:@encode(BOOL)];
[store registerNonObjectPropertyWithGetter:@selector(alwaysBounceVertical)
setter:@selector(setAlwaysBounceVertical:)
type:@encode(BOOL)];
[store
registerNonObjectPropertyWithGetter:@selector(alwaysBounceHorizontal)
setter:@selector(setAlwaysBounceHorizontal:)
type:@encode(BOOL)];
[store registerNonObjectPropertyWithGetter:@selector
(showsHorizontalScrollIndicator)
setter:@selector setter:@selector
(setDirectionalLockEnabled:) (setShowsHorizontalScrollIndicator:)
type:@encode(BOOL)]; type:@encode(BOOL)];
[_propertiesStore [store registerNonObjectPropertyWithGetter:@selector
registerObjectPropertyWithGetter:@selector(tintColor) (showsVerticalScrollIndicator)
setter:@selector(setTintColor:) setter:@selector
attribute:CRWStoredPropertyAttributeStrong]; (setShowsVerticalScrollIndicator:)
[_propertiesStore type:@encode(BOOL)];
registerObjectPropertyWithGetter:@selector(backgroundColor) [store
registerNonObjectPropertyWithGetter:@selector(canCancelContentTouches)
setter:@selector(setCanCancelContentTouches:)
type:@encode(BOOL)];
[store registerNonObjectPropertyWithGetter:@selector(delaysContentTouches)
setter:@selector(setDelaysContentTouches:)
type:@encode(BOOL)];
[store
registerNonObjectPropertyWithGetter:@selector(keyboardDismissMode)
setter:@selector(setKeyboardDismissMode:)
type:@encode(
UIScrollViewKeyboardDismissMode)];
[store registerNonObjectPropertyWithGetter:@selector(indexDisplayMode)
setter:@selector(setIndexDisplayMode:)
type:@encode(
UIScrollViewIndexDisplayMode)];
[store
registerNonObjectPropertyWithGetter:@selector(indicatorStyle)
setter:@selector(setIndicatorStyle:)
type:@encode(UIScrollViewIndicatorStyle)];
// UIView properties.
[store registerObjectPropertyWithGetter:@selector(backgroundColor)
setter:@selector(setBackgroundColor:) setter:@selector(setBackgroundColor:)
attribute:CRWStoredPropertyAttributeCopy]; attribute:CRWStoredPropertyAttributeCopy];
[store registerNonObjectPropertyWithGetter:@selector(isHidden)
setter:@selector(setHidden:)
type:@encode(BOOL)];
[store registerNonObjectPropertyWithGetter:@selector(alpha)
setter:@selector(setAlpha:)
type:@encode(CGFloat)];
[store registerNonObjectPropertyWithGetter:@selector(isOpaque)
setter:@selector(setOpaque:)
type:@encode(BOOL)];
[store registerObjectPropertyWithGetter:@selector(tintColor)
setter:@selector(setTintColor:)
attribute:CRWStoredPropertyAttributeStrong];
[store registerNonObjectPropertyWithGetter:@selector(tintAdjustmentMode)
setter:@selector(setTintAdjustmentMode:)
type:@encode(UIViewTintAdjustmentMode)];
[store
registerNonObjectPropertyWithGetter:@selector(clearsContextBeforeDrawing)
setter:@selector
(setClearsContextBeforeDrawing:)
type:@encode(BOOL)];
[store registerObjectPropertyWithGetter:@selector(maskView)
setter:@selector(setMaskView:)
attribute:CRWStoredPropertyAttributeStrong];
[store
registerNonObjectPropertyWithGetter:@selector(isUserInteractionEnabled)
setter:@selector(setUserInteractionEnabled:)
type:@encode(BOOL)];
[store registerNonObjectPropertyWithGetter:@selector(isMultipleTouchEnabled)
setter:@selector(setMultipleTouchEnabled:)
type:@encode(BOOL)];
[store registerNonObjectPropertyWithGetter:@selector(isExclusiveTouch)
setter:@selector(setExclusiveTouch:)
type:@encode(BOOL)];
return store;
}
- (instancetype)init {
self = [super init];
if (self) {
Protocol* protocol = @protocol(CRWWebViewScrollViewProxyObserver);
_observers =
static_cast<CRBProtocolObservers<CRWWebViewScrollViewProxyObserver>*>(
[CRBProtocolObservers observersWithProtocol:protocol]);
_delegateProxy = [[CRWWebViewScrollViewDelegateProxy alloc]
initWithScrollViewProxy:self];
_keyValueObserverForwarders = [[NSMutableDictionary alloc] init];
if (base::FeatureList::IsEnabled(
web::features::kPreserveScrollViewProperties)) {
_propertiesStore = [self.class propertiesStore];
} }
} }
return self; return self;
...@@ -211,6 +297,8 @@ ...@@ -211,6 +297,8 @@
self.underlyingScrollView = scrollView; self.underlyingScrollView = scrollView;
// TODO(crbug.com/1023250): Restore these using CRWPropertiesStore once the
// feature flag kPreserveScrollViewProperties is removed.
if (_storedClipsToBounds) { if (_storedClipsToBounds) {
scrollView.clipsToBounds = *_storedClipsToBounds; scrollView.clipsToBounds = *_storedClipsToBounds;
} }
......
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