Closed
Bug 414190
Opened 18 years ago
Closed 18 years ago
getBoundingClientRect is broken for tables
Categories
(Core :: DOM: CSS Object Model, defect, P1)
Core
DOM: CSS Object Model
Tracking
()
RESOLVED
FIXED
People
(Reporter: roc, Assigned: roc)
References
Details
Attachments
(1 file)
|
9.17 KB,
patch
|
MatsPalmgren_bugz
:
review+
MatsPalmgren_bugz
:
superreview+
|
Details | Diff | Splinter Review |
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?
Comment 2•18 years ago
|
||
Would this be HTMLTableElement specific or apply to all elements with display:table (and maybe inline-table?)?
| Assignee | ||
Comment 3•18 years ago
|
||
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.
| Assignee | ||
Comment 4•18 years ago
|
||
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.
| Assignee | ||
Comment 5•18 years ago
|
||
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.
| Assignee | ||
Comment 6•18 years ago
|
||
This does what I suggested.
Attachment #299582 -
Flags: superreview?(mats.palmgren)
Attachment #299582 -
Flags: review?(mats.palmgren)
| Assignee | ||
Updated•18 years ago
|
Whiteboard: [needs review]
Comment 8•18 years ago
|
||
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+
Updated•18 years ago
|
Whiteboard: [needs review]
| Assignee | ||
Comment 9•18 years ago
|
||
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.
Description
•