Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 47 additions & 19 deletions cssom-view-1/Overview.bs
Original file line number Diff line number Diff line change
Expand Up @@ -1861,46 +1861,74 @@ Document includes GeometryUtils;
typedef (Text or Element or CSSPseudoElement or Document) GeometryNode;
</pre>

The <dfn method for=GeometryUtils lt="getBoxQuads(options)|getBoxQuads()">getBoxQuads(<var>options</var>)</dfn> method must run the following steps:

The helper method getCompleteTransform(node, anchestor) must run the following steps:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you should probably add a <dfn> so that you can reference this properly elsewhere.

<ol>
<li class=issue>
DOM order

p1 = top left even in RTL

scale to 0 means divide by zero, return 0x0

cross-frames not allowed, throw WrongDocumentError?

points are flattened (3d transform), z=0. like getClientRect

test block in inline
1. let currentElement be node.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

currentNode, right? I think this should use <var>current</var> and other bikeshed markup to display properly.

2. let transformationMatrix be the current transformation matrix of currentElement (https://www.w3.org/TR/css-transforms-2/#ctm)
3. while currentElement is not null do
<ol>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you really need the <ol>?

1. create a translation matrix from the currentElement offsetLeft and offsetTop
2. multiply the matrix from 4. with the transformationMatrix and store the result in transformationMatrix
3. assign the offsetParent of currentElement to currentElement
4. let parentTransformationMatrix be the current transformation matrix of currentElement (https://www.w3.org/TR/css-transforms-2/#ctm)
5. multiply the parentTransformationMatrix with the transformationMatrix and store in transformationMatrix
6. if currentElement is the anchestor or the anchestor is null return the transformationMatrix
</ol>
</ol>

pseudo-elements before/after are children of the element
The <dfn method for=GeometryUtils lt="getBoxQuads(options)|getBoxQuads()">getBoxQuads(<var>options</var>)</dfn> method must run the following steps:

viewport boxes are all the same
<ol>
1. create an array as result container
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let |result| be an empty [=list=] of [=DOMQuad=] objects. etc, please look at existing bikeshed files to see how to make this work.

2. for each css-fragment of the element run the following steps
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

of what element? Probably of this? Also fragment should link to a definition.

<ol>
1. Create a DOMRect of the Element with the x,y value of 0 and the offsetWith and offsetHeight.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't seem right, offsetWidth rounds to integers to begin with which this code shouldn't do, but also is not defined for non-elements, so this should probably do something like:

  • If this is a Document, then you need to use the layout viewport.
  • If this is an Element or Text node, then you need to iterate over the fragments.

2. Depending on the value of options.box modify the Rect from 1. with the calculated style values of the element.
- 'border': no change
- 'margin': https://drafts.csswg.org/css-box-4/#box-edges - use the margin-box
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should not just drop the urls like this, it should link to the definition. ResizeObserver has very similar functionality, maybe crib from there?

- 'padding': https://drafts.csswg.org/css-box-4/#box-edges - use the padding-box
- 'content': https://drafts.csswg.org/css-box-4/#box-edges - use the content-box
3. create a DomQuad from the rect via DOMQuad.fromRect
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Proper capitalization DOMQuad and linking please.

4. Calculate the resulting transformation matrix between the element and options.realtiveTo (if relativeTo is unset use window.defaultView) via the algorithm defined in getCompleteTransform
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

window.defaultView is not a thing, also s/realtiveTo/relativeTo.

This should be untransforming the rect to the layout viewport if there's no relativeTo.

5. transform every Point of the quad via the matrix calculated in 4. and add the result to the result container
</ol>
3. return the result container
</ol>

The <dfn method for=GeometryUtils lt="convertQuadFromNode(quad, from, options)|convertQuadFromNode(quad, from)">convertQuadFromNode(<var>quad</var>, <var>from</var>, <var>options</var>)</dfn> method
must run the following steps:

<ol>
<li><p class=issue>...
1. transform each point of the DOMQuad via convertPointFromNode
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should link to convertPointFromNode, but also probably should have more precise details like:

 * Let <var>p1</var> be the result of calling [=convertFromFromNode=] with <var>quad</var>.p1, <var>from</var> and <var>options</var>.
 * ...
 * Return a new [=DOMQuad=] with <var>p1</var>...

</ol>

The <dfn method for=GeometryUtils lt="convertRectFromNode(rect, from, options)|convertRectFromNode(rect, from)">convertRectFromNode(<var>rect</var>, <var>from</var>, <var>options</var>)</dfn> method
must run the following steps:

<ol>
<li><p class=issue>...
1. create a DOMQuad from the rect via DOMQuad.fromRect
2. transform each point of the DOMQuad from 1. via convertPointFromNode
</ol>

The <dfn method for=GeometryUtils lt="convertPointFromNode(point, from, options)|convertPointFromNode(point, from)">convertPointFromNode(<var>point</var>, <var>from</var>, <var>options</var>)</dfn>
method must run the following steps:

<ol>
<li><p class=issue>...
1. get the resulting matrix between the node and the document.defaultView via the algorithm defined in getCompleteTransform
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Give these meaningful names like:

 * Let <var>thisTransformToViewport</var> be the result of calling [=getCompleteTransform=] with <var>this</var> and <var>this</var>' [=associated document=].
 * Let <var>fromTransformToViewport</var> be the result of ...
 * Invert <var>fromTransformToViewport</var>.
 * ...

Then reference those.

2. get the resulting matrix between the from and the document.defaultView via the algorithm defined in getCompleteTransform
3. inverse the matrix in 2.
4. Depending on the value of options.fromBox modify the point with the calculated style values of the element.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should use <var>point</var> etc.

- 'border': no change
- 'margin': x - margin.left, y - margin.top
- 'padding': x + border.leftWidth, y + border.topWidth
- 'content': x + border.leftWidth + padding.left, y + border.topWidth + padding.top
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not actually based on the computed style but on the actual used padding box etc. Those boxes are defined already elsewhere and we should reuse the definitions.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't really find where I should link to.
maybe: https://drafts.csswg.org/css2/#Computing_widths_and_margins

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't really find where I should link to. maybe: https://drafts.csswg.org/css2/#Computing_widths_and_margins

Pretty sure those boxes are defined here: https://drafts.csswg.org/css-box-4/#box-edges

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, but I need to link to the Algorythm how they are calculated, or is this enough?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, but I need to link to the Algorythm how they are calculated, or is this enough?

There is no algorithm like that for these. They are defined in English instead. Browsers have algorithms internally that match those descriptions and can call into those when a spec says to do something with one of these boxes, so linking to their definitions is enough to unambiguously tell an implementer what needs to happen.

More modern specs like to define their concepts in terms of algorithms to derive them, because that makes implementation easier and leaves less room for creative (mis-)interpretation of the definition.

TL;DR: You want to link to a concept's definition when using it. Whether that is an algorithm or not doesn't matter.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same, refer to standard terms. It seems ResizeObserver refers to the CSS2 border box area, etc.

5. transform the point from 4. with the matrix in 1.
6. transfrom the point from 5. with the matrix in 2.
7. Depending on the value of options.toBox modify the point from 6. with the calculated style values of the element.
- 'border': no change
- 'margin': x + margin.left, y + margin.top
- 'padding': x - border.leftWidth, y - border.topWidth
- 'content': x - border.leftWidth - padding.left, y - border.topWidth - padding.top
</ol>

<h2 id=visualViewport>VisualViewport</h2>
Expand Down