Closed Bug 186516 Opened 22 years ago Closed 20 years ago

offsetWidth,clientWidth and scrollWidth properties return incorrect values with empty block elements

Categories

(Core :: DOM: Core & HTML, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla1.8beta1

People

(Reporter: tfriesen, Assigned: bzbarsky)

References

Details

(Keywords: testcase)

Attachments

(3 files, 1 obsolete file)

These IE compatible properties seem to return incorrect values when there is no
content in a block element.

In the following testcase,the document.body contains a empty DIV element named
"div1",no styling is applied to the document.

offsetWidth,clientWidth and scrollWidth all return zero for div1,
but using getComputedStyle() for the width property gives a value.
These properties should be returning the same width values as the document.body
since the width values are "auto".
clientWidth also returns zero in IE6 for some reason.

offWidth also returns zero for the document.body.
clientWidth and scrollWidth both give a value.
These values are both greater then the computed width of the document.body,so 
that does'nt seem right.

Is the computed width of document.body suppose to be less than the width of the
root element?

The testcase should work in IE as well
Keywords: testcase
Mass-reassigning bugs to dom_bugs@netscape.com
Assignee: jst → dom_bugs
*** Bug 198999 has been marked as a duplicate of this bug. ***
The problem here is that the offset rect is computed by starting with an empty
rect and unioning it with every rect of the element (continuations, etc).

But in this case the element rect is 0 height, so empty.  Thus we fall into the
"both rects empty case" in UnionRect().

I'm guessing the best fix here is to copy the relevant code out of UnionRect and
do the union by hand.... roc, any better ideas?
Attached patch Patch (obsolete) — Splinter Review
Attachment #149701 - Flags: superreview?(roc)
Attachment #149701 - Flags: review?(roc)
Actually, I wonder if the right thing to do here is to special-case the empty
rect and if it is empty, set it to (first-in-flow.x, first-in-flow.y, 0, 0).
You mean if the result is empty once we're done with the loop?
Yeah. So if during the loop we find a non-empty rect, we use that.
Comment on attachment 149701 [details] [diff] [review]
Patch

minusing while we wait for bz to come back and respond
Attachment #149701 - Flags: superreview?(roc)
Attachment #149701 - Flags: superreview-
Attachment #149701 - Flags: review?(roc)
Attachment #149701 - Flags: review-
Attachment #149701 - Attachment is obsolete: true
Attachment #153125 - Flags: superreview?(roc)
Attachment #153125 - Flags: review?(roc)
Attachment #153125 - Flags: superreview?(roc)
Attachment #153125 - Flags: superreview+
Attachment #153125 - Flags: review?(roc)
Attachment #153125 - Flags: review+
Assignee: general → bzbarsky
Checked in.
Status: NEW → RESOLVED
Closed: 20 years ago
OS: Windows ME → All
Hardware: PC → All
Resolution: --- → FIXED
Target Milestone: --- → mozilla1.8beta
Component: DOM: Mozilla Extensions → DOM
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: