Re: [CSS21] Is a replaced element allowed to be a table box?

Anton Prowse <> writes:

> On 15/05/2012 00:01, Anton Prowse wrote:
>> 17.2 (The CSS table model) says:
>>    # The following 'display' values assign table formatting rules to an
>>    # arbitrary element:
>>    #
>>    # table [...]
>>    # [...]
>>    #
>>    # Replaced elements with these 'display' values are treated as their
>>    # given display types during layout. For example, an image that is
>>    # set to 'display: table-cell' will fill the available cell space,
>>    # and its dimensions might contribute towards the table sizing
>>    # algorithms, as with an ordinary cell.
>> So what's the deal with
>> <img style="display:table">
>> where presumably an anonymous table wrapper box is generated around the
>> image, but no caption box is present.
>> Similarly, how about
>> <div style="display:table">
>>      <img style="display:table-row">
>> </div>
>> for example?
>> Does table fix-up occur?  Does the image display?  If a table formatting
>> context is established in the first example, does it make sense that the
>> image then displays?
> From what I can tell, Gecko takes a replaced element with
> display:table or display:table-row, gives the replaced element the
> used value display:block and generates a wrapper box with used value
> display:table or display:table-row respectively.  Then it goes and
> does all the table fix-up stuff.
> This seems like a pretty useful heuristic.  Can any other implementers
> comment on what they do?

Replaced elements and 'display:*table*' in Presto:

If the 'display' type is 'table', 'table-row', 'table-row-group',
'table-header-group', 'table-footer-group', 'table-column',
'table-column-group', 'table-caption' or 'table-cell', we force the
computed (!) value of 'display' to become 'block'. If it is
'inline-table', we force it to become 'inline'. Then we perform table
anonymous element fix-up as normally.

I doubt that this is 100% ideal, though. For instance,
'table-column-group' and 'table-column' should probably become 'none'
rather than 'block', I suppose?

And we should ideally modify the _used_ value, not the _computed_ value,
of course.

See below for 'table-cell' and 'table-caption'.

> Also, I was surprised to discover that none of Gecko, Webkit and
> Presto permits a replaced box to be a table-cell box.

I agree that this seems like an unnecessary restriction. Likewise for
table-caption. No reason to disallow replaced elements here (although
some work may be required on the implementation side to allow for
replaced elements to participate in something other than inline or block
formatting context (but flexbox already requires that anyway)).

---- Morten Stenshorne, developer, Opera Software ASA ----
---- Office: +47 23692400 ------ Mobile: +47 93440112 ----
------------------ -----------------

Received on Tuesday, 17 July 2012 13:43:23 UTC