RE: [css3-regions] offsetParent for element collected inside a named flow

offset(Top|Left|Parent) refer strictly to how the objects visually seem to be positioned relative to one another. From the DOM/semantic point of view, offsetTop|Left have no meaning. So offsetLeft means visualOffsetLeft.

When a node is visually located in a fragmentainer (multi-columns, regions etc) I expect offsetLeft and offsetTop to indicate to that fragmentainer (column, region) where it looks to be located in.

When an inline content is located in a div's nth fragment (over n columns/regions), I expect offsetTop to point to where that div fragment begins. If we're talking about regions that have padding, there's also an offset from the div's fragment to the border of the region.
Calling offsetTop on the div's fragment will point to the column|region's top coordinate.
Calling offsetTop on the column will point to the div that has columns-count.

Mihai


-----Original Message-----
From: Alan Stearns [mailto:stearns@adobe.com] 
Sent: Monday, March 25, 2013 18:45
To: Andrei Bucur; Mihnea-Vlad Ovidenie; www-style@w3.org
Subject: Re: [css3-regions] offsetParent for element collected inside a named flow

(hopefully fixing the top-posting correctly)

>On 3/25/13 7:53 AM, "Andrei Bucur" <abucur@adobe.com> wrote:
>
>>On Mar 23, 2013, at 1:12 AM, Alan Stearns <stearns@adobe.com> wrote:
>>
>>>On 3/22/13 6:32 AM, "Mihnea-Vlad Ovidenie" <mihnea@adobe.com> wrote:
>>>Hi,
>>>CSSRegions spec [1] has a paragraph describing the computation of
>>>offset*
>>>attributes for elements laid out in a named flow. However, it does 
>>>not mention explicitly if/how collecting an element inside a named 
>>>flow affects the way *offsetParent* [2] is determined.
>>>For instance, in the case of the following markup:
>>><div id="contentNode" style="flow-into: flow"> </div> What should 
>>>*document.getElementById("contentNode").offsetParent*
>>>return?
>>>In my opinion, it should return *null*, meaning that the algorithm of 
>>>determining the closest positioned containing element for an element 
>>>collected in a named flow should stop at the named flow level (and 
>>>return null in this case).
>>>Thoughts?
>>>[1] http://dev.w3.org/csswg/css3-regions/#cssomview-offset-attributes
>>>[2]
>>>http://dev.w3.org/csswg/cssom-view/#extensions-to-the-htmlelement-int
>>>erf
>>>ac
>>>e
>>
>>I do not think it should return null. But I don't think that following 
>>the algorithm defined in cssom-view for fragmented content is 
>>necessarily the right thing to do either. That algorithm doesn't take 
>>fragmentation contexts into account. Since the various offset 
>>properties are concerned with the edges of the CSS layout box, it 
>>makes much more sense to me to update the algorithm to accommodate 
>>fragment containers.
>>Instead of only considering ancestor elements in step 2 of the 
>>offsetParent algorithm, I think it should walk the ancestor chain up 
>>to the nearest fragment boundary, then hop to the fragment container 
>>and walk its ancestry (repeating for as many fragmentation contexts as 
>>are nested).
>>Thus the result could be the region containing the element, or a 
>>positioned ancestor of that region.
>>If and when columns or overflow:fragment boxes can be positioned, this 
>>will be an issue for those fragmentation contexts as well. And in a 
>>paginated view case, I think it will be much more useful to return the 
>>page containing the element.
>>Thanks,
>>Alan
>
>With regions, this is more complicated because an element gets to 
>occupy a certain space inside the viewport because of both the flow 
>layout and region layout. I can imagine there are situations when 
>developers want to access the offsetParent relative to the flow in some 
>contexts and the visual offsetParent relative to the regions in other 
>contexts.
>
>If we go with the approach of changing this to follow only the visual 
>ancestor path there will be no easy way to compute the flow offset* 
>properties. I don't have hard data but I think there are JS libraries 
>that use the offset* properties to make adjustment to the position of 
>elements after layout.
>If we take the elements using those hypothetical libraries and flow 
>them inside regions their layout will break because they expect 
>offsetParent to point inside the flow, not the regions.
>
>Maybe we can create a new API on the CSSOM (like visualOffset*) that 
>can behave the way you described for regions, overflow fragments etc. 
>and follow the visual ancestor path.


I think named flows and insertion points/shadow dom [1][2] are already breaking assumptions that scripts might have about offsetParent. We should be looking at what this API is meant to do, and see what makes sense in fragmentation contexts with positionable containers. My take is that the offsetParent should be the nearest display box for which you can get relevant offset values. Take this example:

#relative-parent {
  position: relative;
}
#relative-child {
  position: relative;
  flow-into: named-flow;
}
#region {

  position: relative;
  flow-from: named-flow;
}

<div id="relative-parent">
  <div id="relative-child"></div>
</div>
<div id="region"></div>

The current algorithm says that relative-child.offsetParent is relative-parent, when it's actually being positioned relative to the region. I don't think it's useful to return offsetTop, etc. values calculated from these disconnected boxes.

Thanks,

Alan

[1] http://lists.w3.org/Archives/Public/public-webapps/2013JanMar/0881.html
[2] http://lists.w3.org/Archives/Public/public-webapps/2013JanMar/0948.html

Received on Tuesday, 26 March 2013 09:05:36 UTC