Bug 184694 - document.body.scrollHeight is different after resizing the window down and up
Summary: document.body.scrollHeight is different after resizing the window down and up
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: Layout and Rendering (show other bugs)
Version: Safari 11
Hardware: Unspecified Unspecified
: P2 Major
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2018-04-17 08:19 PDT by Tobi Reif
Modified: 2019-09-25 01:27 PDT (History)
6 users (show)

See Also:


Attachments
the page (281.45 KB, application/zip)
2018-04-17 08:41 PDT, Tobi Reif
no flags Details
Test reduction (207 bytes, text/html)
2018-05-04 16:28 PDT, zalan
no flags Details
Test reduction (474 bytes, text/html)
2018-05-04 16:33 PDT, zalan
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Tobi Reif 2018-04-17 08:19:02 PDT
In a full-size window load https://tobireif.com/demos/ .
Note that the page is short.
Resize the window to be narrow, and back.
Note that the same page at the same full width as before now is much longer than before.
The issue does not occur in Chrome, Firefox, and Opera.

The related code probably is "function setCanvasSize()" -> "document.body.scrollHeight".

I hope you can ensure that it will work as in Chrome & Firefox & Opera where the reported height is the same after downsize-upsize.
Comment 1 Tobi Reif 2018-04-17 08:21:01 PDT
(Please set the correct Component, it might be Layout instead of DOM.)
Comment 2 Tobi Reif 2018-04-17 08:41:03 PDT
Created attachment 338118 [details]
the page
Comment 3 Radar WebKit Bug Importer 2018-04-20 23:34:04 PDT
<rdar://problem/39618561>
Comment 4 Tobi Reif 2018-05-03 01:33:54 PDT
I hope you can update this ticket as soon as <rdar://problem/39618561> got set to fixed, so that I can check the fix in the latest Safari (in addition to your tests).
Comment 5 zalan 2018-05-04 16:28:04 PDT
Created attachment 339609 [details]
Test reduction
Comment 6 zalan 2018-05-04 16:29:52 PDT
Interestingly both FF and Chrome behave the same as Safari in quirks mode.
Comment 7 zalan 2018-05-04 16:31:47 PDT
Test reduction -> 
1. resize the page until all boxes wrap
2. resize it back until all boxes are on the same line
-> check for scrolling.
Comment 8 zalan 2018-05-04 16:33:20 PDT
Created attachment 339610 [details]
Test reduction
Comment 9 Simon Fraser (smfr) 2018-05-07 14:11:42 PDT
So this bug is about the value of scrollHeight during the resize handler?
Comment 10 Tobi Reif 2018-05-08 00:45:22 PDT
> So this bug is about the value of scrollHeight during the resize handler?

Yep - when you insert "console.log(document.body.scrollHeight);" into "function setCanvasSize()", then open the page in eg Chrome, you always get ~ the same value after you downsize upsize the window. In Safari you'll get very different much larger values after downsize upsize.
Comment 11 Simon Fraser (smfr) 2018-05-18 21:19:07 PDT
document.body.scrollHeight seems incompatible between Safari and Chrome/Firefox. In Safari, it's max(view height, contents height), but in other browsers it's just contents height.

This is odd, since scrollHeight is max(box height, contents height) for an overflow scroll div.
Comment 12 Simon Fraser (smfr) 2018-05-18 21:27:27 PDT
scrollHeight on the body comes from the ScrollView contentsSize, and that is computed via RenderView::unscaledDocumentRect() which uses layoutOverflowRect(). If not overflowing, we use height and width of the RenderView (which is not the body!).
Comment 14 Tobi Reif 2018-05-19 05:47:32 PDT
Thanks for investigating!
Comment 15 Tobi Reif 2018-06-19 04:00:40 PDT
I hope this can get fixed
Comment 16 Tobi Reif 2018-11-09 01:06:14 PST
The issue still exists in Safari 12.0.1 (14606.2.104.1.1) and in Safari Technology Preview Release 69 (Safari 12.1, WebKit 14607.1.12) :

After sizing the window to be narrow and back, the page is longer than before == longer than it should be.
Comment 17 Tobi Reif 2019-06-25 09:27:07 PDT
It would be great if this could get fixed :)
Comment 18 Tobi Reif 2019-09-25 01:27:44 PDT
It would be great if this could get fixed :)