Closed Bug 60365 Opened 24 years ago Closed 23 years ago

Table caption does not center when TABLE's ALIGN attribute is set to 'center'

Categories

(Core :: Layout: Tables, defect, P3)

defect

Tracking

()

RESOLVED FIXED
mozilla0.9.7

People

(Reporter: bono_chris, Assigned: karnaze)

References

Details

(Keywords: testcase, Whiteboard: [awd:tbl] PATCH)

Attachments

(9 files, 2 obsolete files)

A TABLE that is centered via the ALIGN="CENTER" attribute does not have a centered caption. The text inside the CAPTION tag is aligned left and cannot be centered by use of another ALIGN attribute or even with a STYLE attribute.
confirm using mozilla trunk 2000-11-20-20 / win2k that <title align="center"><caption>stuff</caption>...</title> does not center the caption. Marking New.
Status: UNCONFIRMED → NEW
Ever confirmed: true
Please see bug 3166. Are captions supposed to be centered using title tags?
Sorry. My earlier comment said 'TITLE' when it should have said 'TABLE'. My excuse is "brain seizure" and I'm sticking to it. bz's attached test case shows the example with <TABLE ALIGN="CENTER"><CAPTION>...</CAPTION>...</TABLE> Looking at the HTML 4.01 Spec, I think the CAPTION should be rendered as part of the table and that it should act like a cell. See HTML 4.01 B.5.2 Recommended Layout ALgorithms. So, it would seem that if the entire table is ALIGNed with respect to the BODY, then the CAPTION should be aligned in the same way with respect to the BODY. This bug is about CAPTION not being rendered as part of the TABLE while bug 3166 is about the ALIGN attribute of CAPTION not working. I think these are two separate issues even though the underlying problem may be the same.
QA Contact: chrisd → amar
QA contact update
Caption is treated separately from table as per specificattion. It can be centered by means of CSS. align= property for caption applies to caption alignment to table I believe (top, bottom, left, right), not to it's allignment on the document. But I'm not sure if allign= property for table should affect caption in Transitional HTML. adding qawanted keyword.
Keywords: qawanted
According to www.w3c.org specification " The table captions should behave like cells and Each caption is a cell that spans all of the table's columns if at the top or bottom of the table, and rows if at the left or right side of the table." and also if we load the testcase on Netscape 4.7 the caption is center aligned. since we support the quirks mode it is a valid bug.. Adding "testcase" keyword
Keywords: testcase
steeling the bug --> patch to come after regression testing
Assignee: karnaze → bernd.mielke
Attached patch patch (obsolete) — Splinter Review
The only testcase where the regression tests indicated a difference was bug10140.html. IMHO the rendering is more correct with the patch then before. The patch takes into account the horizontal table position as indicated by InnerMargin. Please note that we already take into account the InnerMargin for vertical alignment, so it seems natural to me to do this also for the horizontal case.
Keywords: patch, review
Looks right to me: sr=attinasi (pending karnaze's review)
Attached file nested testcase
please ignore my first patch, the problem here is not that caption is not centered, the problem is that the caption is too short! If we center the table the captions left and right margin are 0 by default and as consequence it should stretch from the left to right edge of the containing block. (Please look at the CSS2 picture with the collapsed vertical margin.) If we do so, as a result of the text-align:center in the html.css file the caption text will center by default. In order to get the caption length correct I had to remove the innerMarginNoAuto from the width calculation for the caption and to fix an obvious typo inside the width calculation. With that patch we happily break bug10140.html. But now I think we implement the correct thing for the last tables in that testcase.
r=karnaze
sr=attinasi
Blocks: 83989
a= asa@mozilla.org for checkin to the trunk. (on behalf of drivers)
According to CSS2, http://www.w3.org/TR/REC-CSS2/tables.html#q6 , captions above and below a table should be treated as block boxes adjacent to the table. So I don't see why this should be a fix in the core layout. Shouldn't this instead be done in attribute mapping code? (I admit that the recommendation in B.5.2 of HTML4 slightly disagrees with this, but that's only a recommendation. Perhaps we should raise this issue with the CSS working group?)
Attached image screenshot of 1704b
The patch does not change the picture in testcase 170401. I do not agree with Davids statement above tables 13-16 in this testcase. I think we are rendering fine, and the testcase is wrong. The patch clearly improves the picture for testcase bug10140.html. 1704b exhibits a different problem the containing block for a absolute positioned table is assumed to have the complete width furthermore it triggers also without the patch the following assertion: ###!!! ASSERTION: next frame in reflow command is null: 'nextFrame', file C:\moz _sour\mozilla\mozilla\layout\html\table\src\nsTableOuterFrame.cpp, line 1024 I filed bug 84140 about it. I agree that the CSS2 and HTML spec describe a different box and rendering model for table captions. My personal impression is that the TableOuterFrame is a good place for handling the inner table frame and caption frame relationship, because I see them more like equal partners that negotiate the joint rendering e.g. reflow.
I won't object, since I don't have time to get involved in the issues.
David is right, removing dependency.
No longer blocks: 83989
we should do the same thing we do for the table itself in http://lxr.mozilla.org/mozilla/source/content/html/content/src/nsHTMLTableElement.cpp#1268 also for the caption.
Bernd, I don't think you can implement this as a regular attribute-mapping function. The function would need to access the parent table's 'align' attribute, which AFAICT, it can't do. The MapAttributeIntoRule function is only given the attribute data and the rule data, which isn't enough to find the parent. I see three ways to fix this bug. One is to render captions with 'auto' width per CSS2: "A caption that is above or below a table box also behaves like a block box for width calculations; the width is computed with respect to the width of the table box's containing block." We're not doing this right now, even for an explicitly specified "width: auto". Another is to default the caption's margins to the same computed value as the inner table's for HTML documents. CSS widths/margins would override this. I tried inheriting the margins in html.css to test this, but that didn't work. The last way I can think of is to place the align="center" handling code-- table[align="center] > caption {margin-left: auto; margin-right: auto;} --in html.css (where, being a non-CSS presentational hint, it doesn't really belong). I'd prefer implementing "width: auto" properly and setting the horizontal margins to "inherit". This would not only be CSS2 compliant, but seem to follow HTML4's recommendation as well. It would depend on "width: auto" working, 'inherit' working, and caption margins working. (They have problems right now.)
OS: Windows 2000 → All
Hardware: PC → All
*** Bug 91026 has been marked as a duplicate of this bug. ***
I dont think that the inheritance way will work, especially if one considers caption-side left and right. So my feeling is that we should dependent on caption-side lookup the margins from the table. Because this will use table margins, caption-side and caption-margins nsOuterTableFrame.cpp may be a good point to deal with all of it.
Chris, I give this bug back to you. I had patches even with a sr, that would at least ease the pain. This bug requires knowledge of the style system. I dont have it and I did not got it. I asked several style people for help and did not got the help. Probably it is more difficult to get style people to surrender some information, than to get the Taliban to surrender bin Laden. (If you are on doubt about this look for bug 915 which would be fixed for ages if there would be some piece of documentation for the style system) The fix here would be the following: the style system should attach the auto-width to the outer table frame, then it would take part in the normal block reflow. The same issue is with the numerous abs pos bugs for tables, the position parameters should go to the outertable frame and not the inner one. I am dissappointed
Assignee: bernd.mielke → karnaze
The problem has nothing to do with information about how the style system works. The problem with this bug (and even more so with bug 915) is that nobody has described the theory explaining how these changes should coexist with CSS2, since they are fundamentally incompatible with CSS. It has nothing at all to do with implementation.
cc:ing Bernd again so he can read my previous comment.
(Oh, and regarding the abs. pos. bugs for tables, the issue with tables having two frames is an issue to be handled in frame construction and table code, not style system code.)
David, your argumentation convinces me to take my hands of this class of bugs, the only thing that still bothers me, is that all browsers I know handle this correctly
Whiteboard: [awd:tbl]
Attachment #35417 - Attachment is obsolete: true
Attachment #36312 - Attachment is obsolete: true
Status: NEW → ASSIGNED
Keywords: patch, review
Whiteboard: [awd:tbl] → [awd:tbl] PATCH
Target Milestone: --- → mozilla0.9.7
Comment on attachment 61271 [details] [diff] [review] patch to allow caption to inherit margin-left, margin-right, align=center from table Please change the selector: +table[align="center"] caption to: +table[align="center"] > caption because child selectors are more efficient than decendant selectors. sr=attinasi
Attachment #61271 - Flags: superreview+
Attached patch revised patchSplinter Review
Comment on attachment 61275 [details] [diff] [review] revised patch r= alexsavulov
Attachment #61275 - Flags: review+
The patch is in. Amar, can you please file new bugs for any remaining test cases that are not fixed by this, keeping in mind bug 114734 (which I just opened). The original problem is now fixed.
Status: ASSIGNED → RESOLVED
Closed: 23 years ago
Resolution: --- → FIXED
Keywords: qawanted
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: