Closed Bug 576976 Opened 14 years ago Closed 6 years ago

Element.scrollHeight: DOES NOT include padding for text area's, DOES include border for div's?

Categories

(Core :: Layout: Form Controls, defect)

defect
Not set
normal

Tracking

()

RESOLVED WORKSFORME

People

(Reporter: u283834, Unassigned)

References

Details

Attachments

(2 files)

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 6.1; en-GB; rv:1.9.2.6) Gecko/20100625 Firefox/3.6.6
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-GB; rv:1.9.2.6) Gecko/20100625 Firefox/3.6.6

The property element.scrollHeight does not include padding of a text area, but for a div it includes both padding AND border. This is not according to the documentation at https://developer.mozilla.org/en/DOM/element.scrollHeight

Reproducible: Always

Steps to Reproduce:
1. Use a text area with padding.
2. Compute the scroll height.
Actual Results:  
Scroll height = height, but not including padding.

Expected Results:  
Scroll height should be height including padding.

For a div, the situation is again different: border seems to be included there as well.
Click the text area / div to view computed scroll height values.
I can see the same behaviour. scrollHeight includes height + padding + border.
clientHeight includes heigth + padding.

So, clientHeight is not the same as scrollHeight for non scrollable elements.

Opera behaves the same way as firefox, while webkit behaves the same way as described in the documentation.
I'll attach another testcase
Version: unspecified → 3.6 Branch
This behaviour also makes it impossible to ascertain whether or not overflow has occurred in a div, because even an empty div with a fixed height of, say, 123px will report a clientHeight of 123px but a scrollHeight of 123 + border-top + border-bottom, which is the only way to test whether or not overflow has occurred.

problem touches on what was filed at http://code.google.com/p/chromium/issues/detail?id=74999
Boris, could that be related to bug 157846?
Severity: major → normal
Status: UNCONFIRMED → NEW
Component: General → Layout: Form Controls
Ever confirmed: true
OS: Windows 7 → All
Product: Firefox → Core
QA Contact: general → layout.form-controls
Hardware: x86 → All
Version: 3.6 Branch → Trunk
Better if I CC him...

Boris, could you look at comment 6? :)
Seems plausible, yes.  We really need a spec for form controls....
Depends on: 157846
See related: bug 735646. It has patches that change scrollHeight to not include the border. That should fix half of this bug (the div half, not the textarea half).
Oops, I meant bug 755971. That has landed on inbound now, but I'll leave this open since I'm not sure if there are other unresolved issues here.
does this bug need to still be open after 5 years of nothing happening? =)
Yes, because we still need to get a spec written for this stuff.
Flags: needinfo?(zcorpan)
Hm, that sounds like it would be more valuable to start a new bug for working on fleshing out a spec, with a bug title appropriate to that work, while closing (or blocking) this very specific bug that isn't going to get "fixed" until an adopted spec exists.
The spec bug needs to go in <https://github.com/w3c/csswg-drafts/labels/cssom-view-1>.

As for this bug, I'm not sure what we gain by closing it.  At least this way we're aware there's a problem that needs resolving here, instead of sweeping it under the rug.
Flags: needinfo?(zcorpan) → needinfo?(emilio)
I'm technically not an editor of cssom-view, but I can take a look and help out.
That being said this bug is working for me. It's just that <textarea> uses box-sizing: border-box. This works the same way in WebKit and Blink too, afaict.
Status: NEW → RESOLVED
Closed: 6 years ago
Flags: needinfo?(emilio)
Resolution: --- → WORKSFORME
Relevant spec is https://drafts.csswg.org/cssom-view/#scrolling-area, which looks roughly ok to me, though need to look closer.
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: