Re: [css2.1] Issue 158 and Issue 178 Resolution

On 13/08/2010 01:20, Tab Atkins Jr. wrote:
> All right, try 2.  I'm pretty certain I have a complete and correct
> grasp of margin-collapsing and clearance loaded into my brain right
> now.
> 
> Now, none of these changes are normative changes.  They should all
> only be clarifications or rephrasings to make things easier to
> understand.
> 
> Change 1
> --------
> 
> In 8.3.1, sixth bullet point, second sub-bullet point, add the
> following after the current text:
> "(In other words, for the purpose of positioning the element's top
> border edge, the following siblings of the element do not
> margin-collapse with the element.)"

The idea of introducing an explanatory note mentioning the custom margin
collapsing here is a good one.  But I disagree with this wording.
Following boxes (note, they're not necessarily siblings of the element)
/do/ collapse with the element, but only with its bottom margin.  And
the other part to it is that the element is prevented from collapsing
its bottom margin with its last child.  Trouble is, the only way to
express all that elegantly is to use precisely the device already
employed: the temporary introduction of a non-zero bottom border.

So I don't think that an explanatory is actually possible, beyond just
saying that the purpose of the device is to temporarily restrict certain
margin collapsing behaviour.


> Change 2
> --------
> 
> In 8.3.1, sixth bullet point, after the last paragraph add the
> following example block:
> 
> """
> This rule can sometimes result in margins appearing to collapse in
> strange ways.  The interactions of the rules is very simple in
> practice, though; one must just keep in mind that different sets of
> margins may be considered when determining the position of different
> elements.
> 
> For example, the following diagram illustrates how one element (the
> blue line) positions itself without collapsing its 100px margin-top
> with the following red box's 150px margin-top.  This special case only
> occurs because the blue line has no content, and thus its top and
> bottom margins are self-adjoining.  (Ordinarily you can't detect this
> behavior, because a self-adjoining box has no content, background, or
> border, but the use of outline or border-image can reveal its position
> without changing the behavior of its margins.)
> 
> [[insert picture 1]]
> 
> Note, though, that when calculating the position of the red box, *do*
> collapse its margin with the blur box's margin.  The red box simply
> positions itself as normal, with its 150px margin collapsing with the
> blue box's 100px margin, for a total effective margin of 150px.  Since
> the red box pays no attention to the position of the blue box, this
> distance is measured from the top of the parent.
> 
> This diagram illustrates a slightly different situation.  It is the
> same as before, but now the red box has a margin-top of only 50px.
> While the previous diagram didn't actually require the red box to
> collapse its margin with the blue box's margin, in this case we see
> that the collapse definitely occurs, as the red box positions itself
> using its new effective margin-top of 100px.
> 
> [[insert picture 2]]
> """

To be honest, I don't find these examples enlightening, and I dislike
the tone of the first paragraph and the majority of the wording of the
others (particularly concerning "positions itself"); although this is
subjective, of course.  Also, I don't understand the last sentence of
the last paragraph.


> Change 3
> --------
> 
> In section 9.5.2, at the end of the paragraph starting "Computing the
> clearance of an element...", delete the last sentence of the paragraph.
> 
> Replace it with:
> 
> """
> To determine the hypothetical position, collapse the top
> margin of the clearing element with preceding adjoining margins per the
> margin-collapsing rules in section 8.3.1, as if the element does not
> have clearance. (Note: Only use the *preceding* adjoining margins - in
> particular, for the purpose of determining the hypothetical position,the
> top margin of the clearing element does not collapse with the margins of
> its children or its own bottom margin.)  Call the resultant margin the
> "hypothetical top margin".
> """

The clause "as if the element does not have clearance" is unnecessary,
because we don't yet know whether it has clearance.  I think you mean to
say to assume clear:none.

The whole paragraph is basically saying that the hypothetical top border
edge position really is the position of a hypothetical non-zero top
border, right?  Then can't we just actually say that (which would also
avoid the problem I raised in the first half of [1]), and leave it at
that?  Why is further/round-about explanation necessary?

(Note that, in this clear:none phase, the position of the hypothetical
top border edge is not necessarily the same as the /actual/ top border
edge position as calculated in 8.3.1.6.2.  I still don't have insight
into whether that's relevant; superficially it isn't since the latter
has no bearing on margin collapsing or clearance.)


> Change 4
> --------
> 
> In section 9.5.2, replace the second step of the clearance algorithm with:
> 
> """
> 2. The size of the clearing element's top margin (possibly collapsed
> with other margins, as detailed earlier in this section) minus the sum
> of:
>  * the margins collapsing above the clearance
>  * if the block's own margins collapse together: the block's top
> margin, by itself
>  * if the blocks' own margins do not collapse together: the margins
> collapsing below the clearance
> """


Did you mean to use your term "hypothetical top margin" here?

Just to make sure I understand what's being proposed: in calculations 1
and 2, we're assuming that clearance has been introduced and hence that
some margin collapsing is disrupted, as per 8.3.1.  (All we're doing by
the time we've reached this stage is figuring out how much to "stretch"
the clearance.)  The value calculated in the second calculation is:

value = hypothetical top margin
             - margin lump above clearance
                - element's top margin OR margin lump below clearance(*)

(*) to which the element's top margin was a contributer


I need to revisit Bruno's example, but I think we desperately need to
add an explanation of why clearance calculation 2 is necessary, ie what
the relationship is between the quantities involved.  This is a
different issue from Issue 158 though.


Note that this proposal doesn't address the other issue from this
thread, of what "border edge" means in clearance calculation 1.


> Change 5
> --------
> 
> In section 9.5.2, after the paragraph starting "Clearance is
> introduced...", add the following example block:
> 
> """
> Note: Clearance, once introduced, takes up permanent space on the
> page.  In particular, elements other than the cleared element may have
> their position directly affected by it.  For example, if the clearing
> element is empty and has self-adjoining margins, a following sibling's
> margin may collapse through it.  The sibling will then also use the
> clearance to position itself, as the following diagram illustrates:
> 
> [[insert picture 3]]
> """

Although I don't like the wording, I do agree that this note is
worthwhile, since the phrase "Clearance is introduced as spacing above
the margin-top of an element" is not accurate.  There *is* no margin top
if that margin is involved in collapsing; there's only a faceless margin
lump.  What your diagram helps to show – although I strongly dislike the
representation of the two top margins as distinct entities rather than
as one entity with ruler distances marked – is that clearance is
introduced as "spacing" which prevents the lump that results from the
collapsing of the margins preceding the element from then going ahead
and itself collapsing with the lump that results from the collapsing of
subsequent margins.  It's as if, when the clearing element is first
encountered, the canvas is cut horizontally after the first margin lump,
and an elastic strip sewn in. Then margin-collapsing life carries on as
normal except that margins aren't allowed to collapse upwards across the
strip.  Then the strip is stretched by the calculated clearance amount.

I think the note should just try and say that, rather than talk about
specific elements having their positions affected.  Clearance is just
interruption of margin collapsing; it's nothing mysterious.


[1] http://lists.w3.org/Archives/Public/www-style/2010Aug/0098.html

Cheers,
Anton Prowse
http://dev.moonhenge.net

Received on Friday, 13 August 2010 14:01:44 UTC