Closed Bug 414190 Opened 18 years ago Closed 18 years ago

getBoundingClientRect is broken for tables

Categories

(Core :: DOM: CSS Object Model, defect, P1)

defect

Tracking

()

RESOLVED FIXED

People

(Reporter: roc, Assigned: roc)

References

Details

Attachments

(1 file)

getBoundingClientRect currently uses the table outer frame to get geometry, which is wrong because it includes margins. IE basically seems to return the union of the caption and inner table border boxes, so for compatibility we should do that too. For getClientRects() we could return one rect that's the union of those two border boxes, for compatibility with IE, or for more precise geometry we could return two rectangles, one for the main table and one for the caption if any. I'm not so sure about that but I think I'll go for returning two rects with the table rect as the first one ... cases where the getClientRects incompatibility matters would be rather obscure.
Flags: blocking1.9?
Would this be HTMLTableElement specific or apply to all elements with display:table (and maybe inline-table?)?
All elements with display:table I guess. The underlying problem is that the drawn border of a display:table element doesn't enclose its display:table-caption child (if any). So we have similar issues as in bug 363183 (getComputedStyle for tables), except they're easier to solve here because we're dealing with border-box metrics instead of content-box metrics, so it's not absurd to add the height of the inner table to the height of the caption.
BTW our offset* property implementation ignores the caption and returns values only for the inner table. I haven't tested what IE does. But we've always done that so I don't plan to change it now. Right now I'm more concerned about getting the shiny new API right.
Having getClientRects return separate rects for the inner table and caption could actually be important ... otherwise there would be no easy way to compute the rect for the inner table. In pagination situations my current implementation will return all the rectangles for the table pieces followed by all the rectangles for the caption pieces.
Attached patch fixSplinter Review
This does what I suggested.
Attachment #299582 - Flags: superreview?(mats.palmgren)
Attachment #299582 - Flags: review?(mats.palmgren)
Whiteboard: [needs review]
^
Flags: blocking1.9? → blocking1.9+
Priority: -- → P1
Comment on attachment 299582 [details] [diff] [review] fix In AddRectanglesForFrames(): >+ if (!TryGetSVGBoundingRect(aFrame, &r)) { s/aFrame/f/ >+ r = nsRect(GetOffsetFromInitialContainingBlock(f), f->GetSize()); r.SetRect(GetOffsetFromInitialContainingBlock(f), f->GetSize()) is better? r+sr=mats with the first nit fixed.
Attachment #299582 - Flags: superreview?(mats.palmgren)
Attachment #299582 - Flags: superreview+
Attachment #299582 - Flags: review?(mats.palmgren)
Attachment #299582 - Flags: review+
Whiteboard: [needs review]
Those rect operations should compile to the same code. I slightly prefer the first one. Checked in.
Status: NEW → RESOLVED
Closed: 18 years ago
Flags: in-testsuite+
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: