Commit de7a28aa authored by Ali Juma's avatar Ali Juma Committed by Commit Bot

Make CRWWebController::webViewScrollViewDidResetContentSize workaround more targetted

webViewScrollViewDidResetContentSize interprets the scroll view's content size's
width being narrower than the frame's width as a sign that WebKit hasn't
properly resized the content, so resets zoom scale to force WebKit to
re-render. However, the zoom scale that makes the content fit exactly within
the width of the frame may not be exactly representable as a float. In this
case, the content size's width can be up to a pixel narrower than the frame
width. There's no benefit to forcing a re-render in this case, and furthermore,
resetting the zoom scale causes the page to scroll, which may trigger the page's
content to spuriously change. In the worst case, this can lead to a never-ending
cycle of resetting the zoom scale, the page scrolling, the page changing,
resetting the zoom scale again, and so on.

This CL makes webViewScrollViewDidResetContentSize ignore cases where the
contentSize's width is up to a pixel narrower than the frame.

Bug: 822697
Change-Id: I93e3e7efb33a6ea3b931c0d7f2b404bf93e80e12
Reviewed-on: https://chromium-review.googlesource.com/c/1348955Reviewed-by: default avatarEugene But <eugenebut@chromium.org>
Reviewed-by: default avatarKurt Horimoto <kkhorimoto@chromium.org>
Commit-Queue: Ali Juma <ajuma@chromium.org>
Cr-Commit-Position: refs/heads/master@{#611104}
parent 5831aa28
...@@ -3528,9 +3528,12 @@ registerLoadRequestForURL:(const GURL&)requestURL ...@@ -3528,9 +3528,12 @@ registerLoadRequestForURL:(const GURL&)requestURL
if (webViewScrollViewProxy.isZooming || _applyingPageState || !currentItem) if (webViewScrollViewProxy.isZooming || _applyingPageState || !currentItem)
return; return;
CGSize contentSize = webViewScrollViewProxy.contentSize; CGSize contentSize = webViewScrollViewProxy.contentSize;
if (contentSize.width < CGRectGetWidth(webViewScrollViewProxy.frame)) { if (contentSize.width + 1 < CGRectGetWidth(webViewScrollViewProxy.frame)) {
// The renderer incorrectly resized the content area. Resetting the scroll // The content area should never be narrower than the frame, but floating
// view's zoom scale will force a re-rendering. rdar://23963992 // point error from non-integer zoom values can cause it to be at most 1
// pixel narrower. If it's any narrower than that, the renderer incorrectly
// resized the content area. Resetting the scroll view's zoom scale will
// force a re-rendering. rdar://23963992
_applyingPageState = YES; _applyingPageState = YES;
web::PageZoomState zoomState = web::PageZoomState zoomState =
currentItem->GetPageDisplayState().zoom_state(); currentItem->GetPageDisplayState().zoom_state();
......
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