W3C home > Mailing lists > Public > www-style@w3.org > May 2013

Re: [css3-multicol] updated editor's draft

From: Morten Stenshorne <mstensho@opera.com>
Date: Wed, 15 May 2013 16:57:47 +0200
To: Håkon Wium Lie <howcome@opera.com>
Cc: www-style@w3.org
Message-ID: <87a9nw2sus.fsf@aeneas.oslo.osa>
Håkon Wium Lie <howcome@opera.com> writes:

> The multicol ED has been updated:
>
>   http://dev.w3.org/csswg/css-multicol/
>
> [...]
>
> Revised the pseudo-algorithm, as per;
>
>   http://lists.w3.org/Archives/Public/www-style/2013Apr/0347.html
>   http://lists.w3.org/Archives/Public/www-style/2013Apr/att-0225/tmp.html

(reading Editor's Draft 10 May 2013)

There's really no difference between the expressions
"(U - ((N - 1) * column_gap)) / N" on line 05
and:
"((U + column_gap) / N) - column-gap" on line 09 and 14

I suggest that one of them be picked and used consistently. The first
one is probably slightly more human-friendly (one can see clearly what's
going on; the total width of all columns is the block width minus gaps,
and the column width is that number divided by the number of columns),
while the second is reduced and more CPU-friendly. :) I think I vote for
the second one, since a similar construct also can be found on current
line 08 (where we resolve the count from width).

I think the pseudo algorithm from line 03 can be simplified to something
like this:

(03) if (column-width = auto)
(04)   N := column-count;
(05) else
(06)   N := floor((U + column-gap) / (column-width + column-gap))
(07)   if (column-count != auto)
(08)     N := min(column-count, N)
(09)   endif
(10)   N := max(1, N)
(11) endif
(12) W := max(0, (U + column-gap) / N - column-gap)

This should give the exact same results, with no code duplication.

> I've kept:
>
>   - the 'exit' statements

I had to change that in my suggestion above.

>   - these assumptions:
>
>       -- that the block direction is unconstrained
>       -- that no column breaks are added through style sheets

The used value of column-width isn't affected by breaks or block
direction restrictions, but used column-count may be, but that depends
on what "used" means in this case. The column-count property has the
following phases:

- Specified/computed (whatever the stylesheet or style attributes says)

- After running the pseudo algorithm

- Actual layout

Consider this example:

<body style="width:600px;">
  <div style="column-width:200px; column-gap:0; height:2em; line-height:1em;">
     line<br>
     line<br>
     line<br>
     line<br>
     line<br>
     line<br>
     line<br>
   </div>
</body>

The computed value of column-count is auto.
The pseudo algorithm resolves column-count to 3.
Layout ends up with 4 columns, due to restricted height.

What if we define it so that *used* column-count in the example above is
3, while *actual* column-count is 4 [1]? If we do that, you can remove
the assumptions.

[1] http://www.w3.org/TR/CSS21/cascade.html#value-stages

Also, it should be mentioned that the pseudo algorithm needs to be run
separately on each column row, since the available width in different
rows may vary (different page sizes, regions, what not).

-- 
---- Morten Stenshorne, developer, Opera Software ASA ----
---- Office: +47 23692400 ------ Mobile: +47 93440112 ----
------------------ http://www.opera.com/ -----------------
Received on Wednesday, 15 May 2013 14:58:17 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 15 May 2013 14:58:18 UTC