Open Bug 1309427 Opened 8 years ago Updated 4 years ago

Return normal values for 'offsetTop' and 'offsetLeft' instead of 0 on descendant <body> elements

Categories

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

52 Branch
defect

Tracking

()

People

(Reporter: coreyf, Unassigned)

References

()

Details

The point of this issue is to only return 0 for the first <body> element child of the root <html> element, but handle subsequent <body> elements like normal elements. I.e. when calling 'offsetTop' and 'offsetLeft' on *descendant* <body> elements, you should get their offsets returned instead of 0. I've attached the test case of the GitHub issue as data URL. Sebastian
Component: General → DOM: Core & HTML
OS: Unspecified → All
Product: Firefox → Core
Hardware: Unspecified → All
Summary: Firefox should honor "the HTML body element" in `offsetTop` → Return normal values for 'offsetTop' and 'offsetLeft' instead of 0 on descendant <body> elements
Version: unspecified → 52 Branch
How urgent is it that this gets addressed?
Flags: needinfo?(bzbarsky)
Not urgent at all, in my opinion. This situation is not exactly common. Chances are the fix is to change this block in GetOffsetRect: if (content && (content->IsHTMLElement(nsGkAtoms::body) || content == docElement)) { parent = frame; to test content == GetComposedDoc()->GetBodyElement() instead of the IsHTMLElement(nsGkAtoms::body) thing. But note that even if that's done the testcase will still alert 0 for the offsetTop, because the inner <body> in it is not offset vertically from its offsetParent (the outer <body>). It should start alerting a nonzero offsetLeft, though.
Flags: needinfo?(bzbarsky)
Note that there is one other content->IsHTMLElement(nsGkAtoms::body) that should probably become a test against GetComposedDoc()->GetBodyElement(), which should probably get cached in the method on the stack like the GetRootElement() is right now.
Priority: -- → P3

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: P3 → P5
You need to log in before you can comment on or make changes to this bug.