Closed Bug 273857 Opened 20 years ago Closed 20 years ago

Text in table not centered, where table has width="95%" and is inside an align="center" div

Categories

(Core :: Layout: Tables, defect)

x86
All
defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: ali, Assigned: MatsPalmgren_bugz)

Details

(Keywords: testcase)

Attachments

(13 files, 2 obsolete files)

Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8a6) Gecko/20041208
Firefox/1.0+

Text inside a table is left aligned, not centered where <table width="95%"> and
is inside a <div align="center">.

IE6 and Opera 7.54 both agree and place the text in the center.

When the align="center" is removed, Gecko/Opera/IE agree text should be left
aligned. When the width="95%" is removed, they all agree text should be centered.

Will attach testcase shortly.
Attached file Testcase per comment 0
Attaching testcase, as described in comment 0.
Attached file more visible testcase
Attached file div div (obsolete) —
Attached file div div
Attachment #168322 - Attachment is obsolete: true
http://lxr.mozilla.org/seamonkey/source/content/base/src/nsStyleContext.cpp#367
is responsible for this.

patches, thoughts why have this, what IE does under different circumstances are
wellcome

 // Correct tables.
368   const nsStyleDisplay* disp = GetStyleDisplay();
369   if (disp->mDisplay == NS_STYLE_DISPLAY_TABLE) {
370     // -moz-center and -moz-right are used for HTML's alignment
371     // This is covering the <div align="right"><table>...</table></div> case.
372     // In this case, we don't want to inherit the text alignment into the table.
373     const nsStyleText* text = GetStyleText();
374     
375     if (text->mTextAlign == NS_STYLE_TEXT_ALIGN_MOZ_CENTER ||
376         text->mTextAlign == NS_STYLE_TEXT_ALIGN_MOZ_RIGHT)
377     {
378       nsStyleText* uniqueText =
(nsStyleText*)GetUniqueStyleData(eStyleStruct_Text);
379       uniqueText->mTextAlign = NS_STYLE_TEXT_ALIGN_DEFAULT;
380     }
381   }
Attached patch Patch rev. 1 (obsolete) — Splinter Review
Both IE6/win32 and Opera7/linux left-aligns in Quirks mode and centers in
Standars mode. I think this is what was intended originally in bug 40038.
This patch makes us do the same.  (FWIW, NS4 left-aligns).
... and for the DIV/DIV case, IE6, Opera and Mozilla agrees on center aligned
text in both Quirks and Standards mode so that looks OK.
Assignee: nobody → mats.palmgren
OS: Windows XP → All
Attachment #168362 - Flags: superreview?(dbaron)
Attachment #168362 - Flags: review?(bernd_mozilla)
align="left" and align="right" should continue to affect tables even in
standards mode
Comment on attachment 168362 [details] [diff] [review]
Patch rev. 1

A little more context in the diff would have been nice.

This is not what was intended originally, but now that WinIE6 does this in
standards mode we may as well follow.
Attachment #168362 - Flags: superreview?(dbaron) → superreview+
With the patch all three browsers are compatible except for one case;
Opera centers the text for "align=left, Standards mode", where IE6/Mozilla
left aligns it.
Attached file quirks mode more cases
I dont believe that the patch is correct, if one places a break point at
http://lxr.mozilla.org/seamonkey/source/layout/style/nsStyleContext.cpp#378 and
loads attachment 168465 [details], we never hit the break point. This is understandable if
one looks at http://lxr.mozilla.org/seamonkey/source/layout/style/quirk.css#97.
So this patch is equivivalent to a removal. Why do we not remove the fixup? Or
is there a scenario when we need this in quirks mode?
Attached patch Patch rev. 2Splinter Review
Yes, you're right, I think we should remove this block and let quirk.css take
care of the quirk. This will also enable authors to override the quirk by
specifying 'text-align:inherit' (which the 1st patch doesn't allow).
Attachment #168362 - Attachment is obsolete: true
Attachment #169077 - Flags: superreview?(dbaron)
Attachment #169077 - Flags: review?(bernd_mozilla)
Attachment #168362 - Flags: review?(bernd_mozilla)
Attachment #169077 - Flags: review?(bernd_mozilla) → review+
Attachment #169077 - Flags: superreview?(dbaron) → superreview+
Checked in 2004-12-23 14:02 PDT

-> FIXED
Status: NEW → RESOLVED
Closed: 20 years ago
Resolution: --- → FIXED
Thanks Mats, I verify that this patch also fixed the rendering on the page on
which I was originally having the issue. :)
Hmm, the Safari that ships with OSX 10.3.7 renders this differently from
Gecko/IE/Opera. It left aligns the 'foo' in the testcases. Weird, that. Are we
all sure that we've arrived at the right resolution here?
This is a screenshot of the rendering of attachment 168464 [details] by:
Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en) AppleWebKit/125.5.5 (KHTML, like
Gecko) Safari/125.12

(Uploading at request of bernd).
This is a screenshot of the rendering of attachment 168465 [details] by:
Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en) AppleWebKit/125.5.5 (KHTML, like
Gecko) Safari/125.12

(Uploading at request of bernd).
Bug 300374 suggests this patch was wrong.  I agree.  I don't think the change
makes much sense, and I'm really not sure why I granted superreview except for
seeing the claim that it matches WinIE6 in standards mode.
Sorry, bug 300734 (incorrect number in previous comment).
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: