W3C home > Mailing lists > Public > www-style@w3.org > April 2016

Re: [css-grid] Reduced Subgrid Proposal

From: fantasai <fantasai.lists@inkedblade.net>
Date: Fri, 15 Apr 2016 14:14:55 -0400
To: Sergio Villar Senin <svillar@igalia.com>, www-style@w3.org
Message-ID: <57112F9F.60104@inkedblade.net>
On 04/15/2016 10:12 AM, fantasai wrote:
> On 04/15/2016 06:05 AM, Sergio Villar Senin wrote:
>> First of all I'm quite happy to see this reduced proposal
>>
>> On 15/04/16 00:35, fantasai wrote:
>>>
>>> C. If one of the subgrid's grid items is placed in the
>>>     subgrid's first/last track, it is treated as if it
>>>     had additional margin on that edge equal to the
>>>     subgrid's margin+border+padding on that edge.
>>
>> As mentioned in our report[1] that might become more complicated if we
>> nest subgrids, as any item in the subgrid could be potentially subject
>> those those kind of adjustments (not only the ones on the edges).
>
> Right, so when querying the item for its outer size contribution,
> you need to stack up the "extra margin" effect as you walk up the
> grid tree.
>
> I don't think this should be particularly hard so long as you have
> some way of querying where in its parent a particular item is,
> placement-wise?

Basically you need to do something like

size = item.GetSizeContribution();

adjustment = 0;
at = false;
if item.parent != this
   at.iStart = item.GetRowStart() == 1
   at.iEnd   = item.GetRowEnd() == item.parent.GetLastRowIndex()
   at.bStart = item.GetColStart() == 1
   at.bEnd   = item.GetColEnd() == item.parent.GetLastColIndex()

   parent = item.parent
   while (parent != this) {
     /* subgrid ; add mbp */
     mbp = parent.GetMBP()
     if at.iStart
       adjustment.iStart += mbp.iStart
       at.iStart = parent.GetRowStart() == 1
     if at.iEnd
       adjustment.iEnd += mbp.iEnd
       at.iEnd = parent.GetRowEnd() == parent.parent.GetLastRowIndex()
     if at.bStart
       adjustment.iStart += mbp.bStart
       at.bStart = parent.GetColStart() == 1
     if at.bEnd
       adjustment.iEnd += mbp.bEnd
       at.bEnd = parent.GetColEnd() == parent.parent.GetLastColIndex()
     parent = parent.parent

size += adjustment

~fantasai
Received on Friday, 15 April 2016 18:15:31 UTC

This archive was generated by hypermail 2.4.0 : Friday, 25 March 2022 10:09:02 UTC