Open Bug 820364 Opened 13 years ago Updated 3 years ago

Reimplement GetOffsetRect using element tree instead of frames

Categories

(Core :: DOM: CSS Object Model, enhancement, P5)

enhancement

Tracking

()

People

(Reporter: singerb.dev, Unassigned)

Details

Followup from bug 803677: :bz says "... think about reimplementing this whole thing in terms of the element tree (which is what the spec requires and is somewhat different from our current behavior)." Currently http://mxr.mozilla.org/mozilla-central/source/content/html/content/src/nsGenericHTMLElement.cpp#386 (GetOffsetRect) is implemented by searching up the tree of frames. However, the spec http://dev.w3.org/csswg/cssom-view/#widl-HTMLElement-offsetParent lists this algorithm in terms of the element tree. Most likely, this is so that we can calculate the rect and the parent in one pass, but the result is that we don't follow the spec well, leading to issues like bug 803677.
I think searching up the frame tree will still be ok, but we'll need to make all the stop conditions be in terms of elements.
Unless we need to fix an important site, I'm reluctant to alter the offset* properties in any way, because 1) offset* has historically behaved very differently across browsers, so the spec simply tries to triangulate something reasonable, which doesn't match what we do and perhaps not what other browsers do either 2) due to #1, a lot of code does UA sniffing and expects different browsers to behave differently, making any attempt to change our behavior perilous 3) due to #1, offset* as specified is a bit crazy 4) most cases where offset* are used are better handled using getBoundingClientRect or getClientRects 5) in the cases where get(Bounding)ClientRect(s) isn't good enough, I'd rather spend energy on a better API, e.g. as discussed in bug 626359. Having said that, if you really want to reimplement offset* to follow the spec and we have a good strategy for detecting and responding to Web site breakage, then we can try it.
(In reply to Boris Zbarsky (:bz) from comment #1) > I think searching up the frame tree will still be ok, but we'll need to make > all the stop conditions be in terms of elements. On further review, the only stop condition that's not strictly in terms of elements is the positioning check (http://mxr.mozilla.org/mozilla-central/source/content/html/content/src/nsGenericHTMLElement.cpp#428), but I imagine that probably has to be that way. Now that bug 803677 is fixed, and given roc's concerns above, there's probably nothing left to do here.
https://bugzilla.mozilla.org/show_bug.cgi?id=1472046 Move all DOM bugs that haven't been updated in more than 3 years and has no one currently assigned to P5. If you have questions, please contact :mdaly.
Priority: -- → P5
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.