Commit 130703ac authored by Gauthier Ambard's avatar Gauthier Ambard Committed by Commit Bot

[iOS] Don't always compensate fullscreen resizing

This CL changes the way the fullscreen resizer is compensating the frame
changes by updating the content offset of the scroll view.
When the WebState is set up the first time, the content offset shouldn't
be updated.

Bug: 849206
Cq-Include-Trybots: luci.chromium.try:ios-simulator-cronet;luci.chromium.try:ios-simulator-full-configs
Change-Id: Ibface28fd9d0459c411aa74de6bb3075c62eb004
Reviewed-on: https://chromium-review.googlesource.com/1225981
Commit-Queue: Gauthier Ambard <gambard@chromium.org>
Reviewed-by: default avatarKurt Horimoto <kkhorimoto@chromium.org>
Cr-Commit-Position: refs/heads/master@{#592350}
parent ae0aa265
......@@ -20,10 +20,13 @@
// The fullscreen model, used to get the information about the state of
// fullscreen.
@property(nonatomic, assign) FullscreenModel* model;
// Whether the content offset should be matching the frame changes.
@property(nonatomic, assign) BOOL compensateFrameChangeByOffset;
@end
@implementation FullscreenWebViewResizer
@synthesize compensateFrameChangeByOffset = _compensateFrameChangeByOffset;
@synthesize model = _model;
@synthesize webState = _webState;
......@@ -35,6 +38,7 @@
self = [super init];
if (self) {
_model = model;
_compensateFrameChangeByOffset = YES;
}
return self;
}
......@@ -57,7 +61,9 @@
if (webState) {
[self observeWebStateViewFrame:webState];
self.compensateFrameChangeByOffset = NO;
[self updateForCurrentState];
self.compensateFrameChangeByOffset = YES;
}
}
......@@ -119,7 +125,9 @@
CGFloat currentTopInset = webView.frame.origin.y;
CGPoint newContentOffset = scrollViewProxy.contentOffset;
newContentOffset.y += insets.top - currentTopInset;
scrollViewProxy.contentOffset = newContentOffset;
if (self.compensateFrameChangeByOffset) {
scrollViewProxy.contentOffset = newContentOffset;
}
webView.frame = newFrame;
......@@ -127,7 +135,8 @@
// back to the initial value if necessary.
// TODO(crbug.com/645857): Remove this workaround once WebKit bug is
// fixed.
if ([scrollViewProxy contentOffset].y != newContentOffset.y) {
if (self.compensateFrameChangeByOffset &&
[scrollViewProxy contentOffset].y != newContentOffset.y) {
[scrollViewProxy setContentOffset:newContentOffset];
}
}
......
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