Open Bug 1247608 Opened 10 years ago Updated 4 years ago

clientHeight and scrollHeight are different

Categories

(Core :: Layout, defect)

44 Branch
defect

Tracking

()

UNCONFIRMED

People

(Reporter: jeanalain.re, Unassigned)

Details

(Keywords: testcase, Whiteboard: dom-triaged)

Attachments

(3 files, 1 obsolete file)

Attached image screenshot.png (obsolete) —
User Agent: Mozilla/5.0 (X11; Linux x86_64; rv:43.0) Gecko/20100101 Firefox/43.0 Build ID: 20160122155412 Steps to reproduce: This jsfiddle to reproduce this issue: https://jsfiddle.net/pd3a816f/2/ Actual results: I set a font-size at 18.73px and a line-height at 1.2em; In my case, the clientHeight and the scrollHeight are different. (respectively 22px/23px) Expected results: I expected me that the clientHeight and the scrollHeight are identical. On chrome, IE11. they are identical.
Keywords: testcase
Product: Firefox → Core
"clientHeight: 22 scrollHeight: 22" for me with FF44 on Win7.
Component: Untriaged → DOM
The clientHeight and scrollHeight don't have to be the same. Fonts can be drawn at different pixel sizes on different systems so you can't assume a font-size specified in pixels and a line-height specified in em to be the same pixel size across browsers.
Whiteboard: dom-triaged
Attached image screenshot.png —
replace by a good screenshot
Attachment #8718334 - Attachment is obsolete: true
Certainly, The fonts rendreding is complex, but in my case, I don't understand why the box model has a different scrollHeight. There isn't any reason Firefox tells me that the element needs scrolls. The clientHeight and the scrollHeight needs be identical.
Component: DOM → DOM: Core & HTML
Component: DOM: Core & HTML → Layout

I've encountered the same bug, but I'm unable to isolate it. It doesn't happen in Chrome. Confirmed by several people (same result on their end: broken in FF, works in Chrome).

With this bug present, I'm unable to reliably detect if element is scrollable, which is breaking my code atm.

I've encountered the bug on this page: https://github.com/npm/registry/blob/master/docs/responses/package-metadata.md
The element in question is document.querySelector('.repository-content .Box.mt-3.position-relative').

Attached image scrollHeight.png —

You can see that the element is not scrollable (scrollTop can't be set above 0), yet the scrollHeight for some reason equals offsetHeight and not clientHeight.

Attached image computed_layout.png —

I'm aware that the provided link above might be temporary until github touches their layout styles, but since I'm unable to isolate, here is at a least screenshot of the element's layout and computed styles.

It seems the issue is related to negative margins of container children. If container has border, and children have negative top/bottom margins, it produces weird values. But that doesn't explain why they are not consistent with chrome.

Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: