Bug 15777 - Height description in 10.6.3 contains various editorial problems
Height description in 10.6.3 contains various editorial problems
Status: NEW
Product: CSS
Classification: Unclassified
Component: CSS Level 2
unspecified
All Windows 3.1
: P2 normal
: ---
Assigned To: Bert Bos
public-css-bugzilla
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2012-01-29 18:15 UTC by Anton P
Modified: 2012-12-04 00:53 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Anton P 2012-01-29 18:15:35 UTC
Reported by Øyvind Stenhaug

10.6.3 contains various editorial problems:

1. Talks about "child box"es even though the formatting structure is  
basically undefined (if interpreted as "child element's box" it's even  
more broken)

2. In the "block-level children" case, defines height as the distance  
between edges of boxes that do not have margins collapsed through it -  
what if there is no such box?

3. What if the "topmost block-level child box" has clearance? This case  
doesn't seem to be considered.

4. The case of no content at all probably requires special mention too

Conversation begins:
Bug description:
http://lists.w3.org/Archives/Public/www-style/2011Feb/0230.html
Comment 1 Anton P 2012-01-29 18:17:44 UTC
I proposed the following solution in http://lists.w3.org/Archives/Public/www-style/2011Feb/0492.html

The top border edge position of the element, and hence the location of the top content edge, is well-defined elsewhere in the spec and needs no explanation in this paragraph.  To determine the height of the element, it's enough to determine the bottom content edge E.

Let Z be the bottommost in-flow block-level child box.  If the bottom margin of Z does not collapse with the element's bottom margin, then E is incident with Z's bottom margin edge.  Otherwise, let Y be the bottommost in-flow block-level child box whose top and bottom margins do not collapse together.  If Y exists then E is incident with the bottom margin edge or the bottom border edge of Y depending on whether the bottom margin of Y does or does not collapse with the element's bottom margin.  Otherwise, or if Z does not exist, the element's height is zero.

[By "bottom margin" of an element X we really mean (due to margin collapsing) the margin lump of which the bottom margin of X is a constituent part.]

That is a non-trivial result, but it follows from other parts of the spec (including complex parts concerning margin collapsing, clearance, etc).  On the other hand, it's also an intuitively obvious result.  No justification for this result needs to be given in 10.6.3; it merely needs to be stated.
Comment 2 Anton P 2012-02-04 12:23:20 UTC
UPDATE:  in fact the spec was actually changed between PR and REC, and now says the following:

  # The element's height is the distance from its top content edge to
  # the first applicable of the following:
  #
  # 1.  the bottom edge of the last line box, if the box establishes
  #     a inline formatting context with one or more lines
  # 2.  the bottom edge of the bottom (possibly collapsed) margin of
  #     its last in-flow child, if the child's bottom margin does not
  #     collapse with the element's bottom margin
  # 3.  the bottom border edge of the last in-flow child whose top
  #     margin doesn't collapse with the element's bottom margin
  # 4.  zero, otherwise 

Unfortunately this isn't quite true.  A parent whose final two in-flow children are a self-collapsing element C with clearance followed by a self-collapsing element without clearance has its bottom content edge incident with the bottom *margin* edge of C not the bottom *border* edge of C, so (3) is wrong.

I maintain that my proposal in Comment 1 is correct.  However, I note that using the criteria "does top margin of child collapse with bottom margin of parent" is a neat idea, and with this my proposal can be further simplified.  Reframing it in the style of the spec text above, the proposal is now to replace (2) and (3) above as follows:

  | 2.  the bottom border edge of the last in-flow child whose
  |     bottom margin but not top margin collapses with the
  |     element's bottom margin
  | 3.  the bottom margin edge of the last in-flow child whose
  |     bottom margin does not collapse with the element's
  |     bottom margin
Comment 3 Anton P 2012-02-04 12:45:34 UTC
Note that the latest spec change was Issue 225.  Note that all the proposals discussed by fantasai and myself in the thread beginning http://lists.w3.org/Archives/Public/www-style/2011Apr/0132.html (which try to reword the proposal described in Comment 1) were in fact incorrect, including the proposal that made its way into the spec. :-(

Issue 225: http://wiki.csswg.org/spec/css2.1#issue-225

Summary
    Auto height calculation rules confused about margin collapsing
URL
    http://lists.w3.org/Archives/Public/www-style/2010Aug/0108.html
Proposal
    http://lists.w3.org/Archives/Public/www-style/2011Apr/0160.html (first part)
Status
    Open. =Bert= Edit. =Anton= Review.
Comment 4 Anton P 2012-02-04 13:05:05 UTC
I've posted my suggestion made in Comment 2 to the public mailing list: http://lists.w3.org/Archives/Public/www-style/2012Feb/0220.html
Comment 5 Anton P 2012-02-04 19:28:12 UTC
Another editorial problem with this section:

10.6.3 says:

  # The element's height is the distance from its top content edge
  # to the first applicable of the following:
  # [...]
  # 4. zero, otherwise

We should replace

  # 4. zero, otherwise

with

  | 4. the element's (incident) bottom content edge (ie the height is
  |    zero)

since there's currently a grammatical mismatch with the sentence 
which introduces the list.

See: http://lists.w3.org/Archives/Public/www-style/2011Apr/0301.html
Comment 6 Anton P 2012-02-04 19:41:40 UTC
Note that the original proposal (see Comment 1) and the alternative proposal (Comment 2) both suffer from analogous issue to that described in Bug 15748, namely that bottom margin edge is not defined when the margin participates in collapsing.