Open Bug 306428 Opened 19 years ago Updated 4 years ago

incorrect offsetHeight

Categories

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

x86
Windows XP
defect

Tracking

()

People

(Reporter: dmitrysv, Unassigned)

References

()

Details

(Keywords: testcase)

Attachments

(5 files)

User-Agent:       Mozilla/4.0 (compatible; MSIE 7.0b; Windows NT 5.1; .NET CLR 1.1.4322)
Build Identifier: 

Mozilla reports incorrect offsetHeight for both links
on the following page:
http://www.accelware.com/browsers-bugs/offset_height_nn_bug.html

Ie 6 reports correct values

Reproducible: Always
Component: General → Layout
Keywords: testcase
Product: Firefox → Core
Version: unspecified → Trunk
The markup code of the testcase is malformed. 
I get the expected results with

<p><font size="8"><a href="http://www.unitconversion.org">Huge Height Link
1</a></font></p>

<h1><a href="http://www.unitconversion.org">Huge Height Link 2</a></h1>

Note that size="8" in transitional DTD is not valid either since size only takes
an integer between 1 and 7.

If <font> is nested inside the link, then you get different values between IE 6
and Mozilla. This differential result is probably due to IE 6 buggy
implementation of overflow: visible.
I believe this is a bug, since offsetWidth remains correct in both cases.

> If <font> is nested inside the link

Yes, not only a font, but an <img> also, for example. Looks like every
element nested inside the link trashes offsetHeight, while leaving offsetWidth 
_correct_.

Oh, I'am sure this is a bug:

Opera 7
1 case - INCORRECT! (zero height)
2 case - CORRECT as IE

Opera 8
1 case - CORRECT as IE!
2 case - CORRECT as IE
Attached file Testcase
The first link in this testcase is probably the same as bug 258531.
But I think the offsetHeight in the second link is wrong. It should be much
higher. It seems as if the offsetHeight is only computed for the box it
encounters. IE6 returns 262 as offsetHeight for the second link (57 for the
first link).
Assignee: nobody → general
Status: UNCONFIRMED → NEW
Component: Layout → DOM: Level 0
Ever confirmed: true
QA Contact: general → ian
So we _could_ "fix" offsetHeight to deal with {ib} splits.  The question is whether that's really what IE does...
Definitely seems like that is what IE does. In the IE DOM the <h1> is a child of the <a>.
So we'd need to replace the GetNextInFlow() call in nsGenericHTMLElement::GetOffsetRect with something more like GetNifOrSpecialSibling() (which currently lives in nsCSSFrameConstructor.cpp).

What's the offsetWidth IE reports in this case?  We'd end up reporting the width of the parent block (so the body) if we did this.
Attached file Testcase2
Firefox:
1 link: offsetHeight: 21, offsetWidth: 389
2 link: offsetHeight: 41, offsetWidth: 182

IE 6:
1 link: offsetHeight: 57, offsetWidth: 389
2 link: offsetHeight: 262, offsetWidth: 198
Attached image Screenshot
Don't know if necessary, but anyway...
What happens in IE if you don't set a width on the div in that testcase?  What happens if the div has no width style and the <h1> contains no text?
With IE6, I get for this (without a style width set for the surrounding div):
2 link: offsetHeight: 114, offsetWidth: 622
This gives the following value for IE6:
2 link: offsetHeight: 59, offsetWidth: 622
I assume 622 is the width of your browser window, right?

In that case, we might want to move the special sibling stuff to nsLayoutUtils so we can use it in nsGenericHTMLElement.  I guess I can do it when I get back if someone reminds me...
(In reply to comment #12)
> I assume 622 is the width of your browser window, right?
No, it's the width of the second link, caused by the second line of the link.

So the offsetWidth of the link is narrower than the offsetWidth of the block child of the link?
Yes.
In that case just adding up the sizes of the special siblings is no going to work.  Sounds like we need a clear spec of what IE actually does -- eg it counts the block child in the height, but not in the width... how come?
Apparently, IE6 looks in horizontal direction only for the width of the widest text line or something like that.
If we really care about something like that we _might_ be able to get partway there with GetMinWidth() and GetPrefWidth().  Maybe...
I don't think we need to blindly follow IE whatever it does. It needs to be something that we can document and that either is

A. Useful to a lot of developers
or
B. Breaks sites that affect a lot of users.
What Internet Explorer does depends on hasLayout: http://www.satzansatz.de/cssd/onhavinglayout.html I would very much encourage not to follow that.

I'm trying to standardize these and other layout attributes in: http://dev.w3.org/cvsweb/~checkout~/csswg/cssom/Overview.html?content-type=text/html;%20charset=utf-8
Assignee: general → nobody
QA Contact: ian → general

Bulk-downgrade of unassigned, >=3 years untouched DOM/Storage bug's priority.

If you have reason to believe this is wrong, please write a comment and ni :jstutte.

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

Attachment

General

Created:
Updated:
Size: