Closed Bug 1591219 Opened 5 years ago Closed 5 years ago

Chrome and Firefox differ in visual ordering of certain table cells

Categories

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

defect

Tracking

()

RESOLVED FIXED
mozilla72
Webcompat Priority ?
Tracking Status
firefox72 --- fixed

People

(Reporter: twisniewski, Assigned: MatsPalmgren_bugz)

References

Details

(Keywords: testcase)

Attachments

(3 files, 2 obsolete files)

In the attached test-case, Firefox places the first display: table-cell in the markup underneath the second one, while Chrome places it above (keeping them in markup order).

It seems as though the padding on the second cell is treated differently somehow.

This seems to be at least part of the reason for the checkbox mis-alignment seen on Amazon's mobile page as reported at https://webcompat.com/issues/32605

Did you mean to attach a testcase here?

Flags: needinfo?(twisniewski)
Attached file testcase.html (obsolete) —

Um, yes. Good thing I hadn't deleted it yet!

Flags: needinfo?(twisniewski)

That testcase looks the same to me in Firefox Nightly 72 & Chrome 79.0.3938.0 dev ... See screenshot.

Does it look different for you? (Maybe this was a chrome bug that was recently fixed?)

Attachment #9104046 - Attachment description: screenshot (nightly on the left, chrome dev on the right) → screenshot of testcase matching in Firefox vs Chrome on dholbert's machine (Firefox nightly on the left, chrome dev on the right)
Attached file testcase.html

Ugh, I uploaded a version of the testcase without the padding :S

Attachment #9104044 - Attachment is obsolete: true
Attachment #9104046 - Attachment is obsolete: true

So this is about where the baseline is, or whether it gets shared across the table cells, I guess? Does blink actually create a single table or do they create two tables, which would explain the baseline not being shared?

No, it seems it repros with tables too:

data:text/html,<!doctype html><style>* { vertical-align: baseline }</style><table><tr><td style="background: green"><div style="background: red">X</div></td><td style="padding: 1.3rem"></td></tr>

I think this is about where the "baseline" is considered to be for a table cell with no content (<div class="sh-badge-v2-textbox-div">) in the testcase). If you put a character into that div, then the browsers behave similarly, but when it is empty, Firefox treats it as having its baseline at the bottom, while Chrome considers it to be at the top.

(It's not the padding as such that matters; the same effect can be produced by just setting an explicit large height on the second cell.)

but when it is empty, Firefox treats it as having its baseline at the bottom, while Chrome considers it to be at the top.

I'd say both are wrong per spec, if I read it correctly:
https://drafts.csswg.org/css-align-3/#baseline-export
Under tables, "The first/last baseline set of a table box is the first/last baseline set of its first/last row."
Under table rows, "Otherwise, the first/last baseline set of the row is synthesized from the lowest and highest content edges of the cells in the row."
So the baseline of the "X" should be aligned with the end content edge of the empty cell (which is roughly in the center of the cell/table).

CSS2 says:
https://www.w3.org/TR/CSS22/tables.html#height-layout
"The baseline of a cell is the baseline of the first in-flow line box in the cell, or the first in-flow table-row in the cell, whichever comes first. If there is no such line box or table-row, the baseline is the bottom of content edge of the cell box."

which is similar to the text for "block containers" in https://drafts.csswg.org/css-align-3/#baseline-export
I think the intent is that it applies to table cells too since they are treated the same elsewhere in the spec, e.g. https://drafts.csswg.org/css-align-3/#distribution-block

Attached file Testcase #2

Here's a clearer testcase that separates the two cases:

  1. The table on the left has only one cell, which is empty, and thus the row is forced to synthesize a baseline from it.
  2. The table on the right has a [non-empty] cell which participates in baseline alignment so that cell's baseline is the baseline of the row/table. The empty cell in this case doesn't participate in baseline alignment in its alignment context (the row) at all - it effectively has start alignment.

I think Chrome handles case 1 wrong, but 2 correct. Firefox handles both wrong.
(In case 1, "synthesized from the lowest and highest content edges" means we should use the "line-under line", i.e. the end content edge, per https://drafts.csswg.org/css-align-3/#synthesize-baseline)

Assignee: nobody → mats
Severity: normal → minor
Keywords: testcase
OS: Unspecified → All
Priority: -- → P3
Hardware: Unspecified → All
Pushed by mpalmgren@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/fec55267c096
[css-align] Synthesize a baseline from the content edges for empty table cells.  r=dholbert
Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/20214 for changes under testing/web-platform/tests
Upstream web-platform-tests status checks passed, PR will merge once commit reaches central.
Status: NEW → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla72
Upstream PR merged by moz-wptsync-bot
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: