RESOLVED FIXED 175235
Layout viewport rect is too wide after window resize
https://bugs.webkit.org/show_bug.cgi?id=175235
Summary Layout viewport rect is too wide after window resize
Ali Juma
Reported 2017-08-04 19:13:11 PDT
When using non-overlay scrollbars, ScrollView::updateScrollbars can reach its cMaxUpdateScrollbarsPass recursion limit, leaving layout in a state that's inconsistent wrt the presence of scrollbars. For example, starting with a page that's vertically scrollable, resize the window to reduce its width. Here's what happens in updateScrollbars: 1) The totalContentsSize() is wider than the visibleWidth(), so a horizontal scrollbar is added. This triggers another layout and a recursive call into updateScrollbars. 2) Layout changes the totalContentsSize() so that is no longer wider than the visible width. So the horizontal scrollbar needs to be removed. But updateScrollbars always removes both scrollbars when one needs to be removed, so the vertical scrollbar is removed as well. Another layout and recursive call into updateScrollbars happens. 3) Layout changes the width of totalContentsSize() under the assumption that there's no vertical scrollbar. But totalContentsSize() is still taller than visibleHeight(), so the vertical scrollbar is added back. We need to trigger another layout to account for this, but we can't since m_updateScrollbarsPass is already 2 (that is, cMaxUpdateScrollbarsPass). So we're left with the layout that was done under the assumption of no vertical scrollbar, even though we do have a vertical scrollbar. And that means the layout viewport is wider than it should be, by the width of the scrollbar. It does get the right size the next time something triggers layout. One way to fix this is to not remove the vertical scrollbar in step 2. Then there won't be any scrollbar change in step 3. Alternatively, we could increase cMaxUpdateScrollbarsPass.
Attachments
Patch (6.18 KB, patch)
2017-08-04 19:25 PDT, Ali Juma
no flags
Patch (6.11 KB, patch)
2017-08-18 12:17 PDT, Ali Juma
no flags
Patch for landing (6.15 KB, patch)
2017-10-31 13:02 PDT, Ali Juma
no flags
Formatting fix (1.60 KB, patch)
2017-11-03 10:33 PDT, Ali Juma
no flags
Ali Juma
Comment 1 2017-08-04 19:25:14 PDT Comment hidden (obsolete)
Ali Juma
Comment 2 2017-08-18 12:17:41 PDT
Created attachment 318526 [details] Patch Rebased
Frédéric Wang (:fredw)
Comment 3 2017-10-12 10:31:56 PDT
I'm not really familiar with this code but that lgtm. I'm not sure what was the rationale for the "always disable the other bar when removing one bar", maybe someone involved in https://trac.webkit.org/changeset/42334 should confirm it's too strong.
Simon Fraser (smfr)
Comment 4 2017-10-12 10:35:07 PDT
This is "highly tuned" code and I suspect that the current logic is there for a good reason. Please talk to Dave Hyatt about this.
Dave Hyatt
Comment 5 2017-10-31 11:24:33 PDT
This should be ok.
WebKit Commit Bot
Comment 6 2017-10-31 11:26:28 PDT
Comment on attachment 318526 [details] Patch Rejecting attachment 318526 [details] from commit-queue. Failed to run "['/Volumes/Data/EWS/WebKit/Tools/Scripts/webkit-patch', '--status-host=webkit-queues.webkit.org', '--bot-id=webkit-cq-01', 'apply-attachment', '--no-update', '--non-interactive', 318526, '--port=mac']" exit_code: 2 cwd: /Volumes/Data/EWS/WebKit Last 500 characters of output: 3. patching file LayoutTests/fast/dom/Window/window-resize-update-scrollbars-expected.txt patching file LayoutTests/fast/dom/Window/window-resize-update-scrollbars.html patching file LayoutTests/platform/ios/TestExpectations Hunk #1 FAILED at 1896. 1 out of 1 hunk FAILED -- saving rejects to file LayoutTests/platform/ios/TestExpectations.rej Failed to run "[u'/Volumes/Data/EWS/WebKit/Tools/Scripts/svn-apply', '--force', '--reviewer', u'David Hyatt']" exit_code: 1 cwd: /Volumes/Data/EWS/WebKit Full output: http://webkit-queues.webkit.org/results/5052531
Ali Juma
Comment 7 2017-10-31 13:02:22 PDT
Created attachment 325478 [details] Patch for landing Rebased.
WebKit Commit Bot
Comment 8 2017-10-31 13:27:22 PDT
Comment on attachment 325478 [details] Patch for landing Clearing flags on attachment: 325478 Committed r224241: <https://trac.webkit.org/changeset/224241>
WebKit Commit Bot
Comment 9 2017-10-31 13:27:23 PDT
All reviewed patches have been landed. Closing bug.
Darin Adler
Comment 10 2017-11-03 09:15:47 PDT
Comment on attachment 325478 [details] Patch for landing View in context: https://bugs.webkit.org/attachment.cgi?id=325478&action=review > Source/WebCore/platform/ScrollView.cpp:618 > + if (!newHasHorizontalScrollbar && hasHorizontalScrollbar && vScroll != ScrollbarAlwaysOn &&!hasVerticalScrollbar) { Formatting mistake, missing space after "&&".
Ali Juma
Comment 11 2017-11-03 10:33:05 PDT
Reopening to attach new patch.
Ali Juma
Comment 12 2017-11-03 10:33:06 PDT
Created attachment 325913 [details] Formatting fix Oops, here's a fix for the missing space.
WebKit Commit Bot
Comment 13 2017-11-03 11:32:22 PDT
Comment on attachment 325913 [details] Formatting fix Clearing flags on attachment: 325913 Committed r224409: <https://trac.webkit.org/changeset/224409>
WebKit Commit Bot
Comment 14 2017-11-03 11:32:24 PDT
All reviewed patches have been landed. Closing bug.
Radar WebKit Bug Importer
Comment 15 2017-11-15 13:13:17 PST
Note You need to log in before you can comment on or make changes to this bug.