Skip to content

Commit

Permalink
[geometry-1] Define minimum and maximum as preferring NaN
Browse files Browse the repository at this point in the history
Fixes w3c#222.
  • Loading branch information
TimothyGu committed Mar 29, 2020
1 parent 5e63d0b commit b9edab7
Showing 1 changed file with 31 additions and 20 deletions.
51 changes: 31 additions & 20 deletions geometry/Overview.bs
Original file line number Diff line number Diff line change
Expand Up @@ -368,17 +368,21 @@ for=rectangle>height dimension</a> value. For the {{DOMRect}} interface, setting
{{DOMRect/height}} attribute must set the <a for=rectangle>height dimension</a> value to the new
value.

The <dfn><code>top</code></dfn> attribute, on getting, must return min(<a for=rectangle>y
coordinate</a>, <a for=rectangle>y coordinate</a> + <a for=rectangle>height dimension</a>).
The <dfn><code>top</code></dfn> attribute, on getting, must return the <a>NaN-safe minimum</a> of
the <a for=rectangle>y coordinate</a> and the sum of the <a for=rectangle>y coordinate</a> and the
<a for=rectangle>height dimension</a>.

The <dfn><code>right</code></dfn> attribute, on getting, must return max(<a for=rectangle>x
coordinate</a>, <a for=rectangle>x coordinate</a> + <a for=rectangle>width dimension</a>).
The <dfn><code>right</code></dfn> attribute, on getting, must return the <a>NaN-safe maximum</a> of
the <a for=rectangle>x coordinate</a> and the sum of the <a for=rectangle>x coordinate</a> and the
<a for=rectangle>width dimension</a>.

The <dfn><code>bottom</code></dfn> attribute, on getting, must return max(<a for=rectangle>y
coordinate</a>, <a for=rectangle>y coordinate</a> + <a for=rectangle>height dimension</a>).
The <dfn><code>bottom</code></dfn> attribute, on getting, must return the <a>NaN-safe maximum</a>
of the <a for=rectangle>y coordinate</a> and the sum of the <a for=rectangle>y coordinate</a> and
the <a for=rectangle>height dimension</a>.

The <dfn><code>left</code></dfn> attribute, on getting, must return min(<a for=rectangle>x
coordinate</a>, <a for=rectangle>x coordinate</a> + <a for=rectangle>width dimension</a>).
The <dfn><code>left</code></dfn> attribute, on getting, must return the <a>NaN-safe minimum</a> of
the <a for=rectangle>x coordinate</a> and the sum of the <a for=rectangle>x coordinate</a> and the
<a for=rectangle>width dimension</a>.
</div>


Expand Down Expand Up @@ -528,21 +532,21 @@ The <dfn method for=DOMQuad>getBounds()</dfn> method, when invoked, must run the
algorithm:

1. Let <var>bounds</var> be a {{DOMRect}} object.
2. Let <var>left</var> be the minimum of <a for=quadrilateral>point 1</a>'s <a for=point>x
coordinate</a>, <a for=quadrilateral>point 2</a>'s <a for=point>x coordinate</a>, <a
for=quadrilateral>point 3</a>'s <a for=point>x coordinate</a> and <a for=quadrilateral>point
2. Let <var>left</var> be the <a>NaN-safe minimum</a> of <a for=quadrilateral>point 1</a>'s <a
for=point>x coordinate</a>, <a for=quadrilateral>point 2</a>'s <a for=point>x coordinate</a>,
<a for=quadrilateral>point 3</a>'s <a for=point>x coordinate</a> and <a for=quadrilateral>point
4</a>'s <a for=point>x coordinate</a>.
3. Let <var>top</var> be the minimum of <a for=quadrilateral>point 1</a>'s <a for=point>y
coordinate</a>, <a for=quadrilateral>point 2</a>'s <a for=point>y coordinate</a>, <a
for=quadrilateral>point 3</a>'s <a for=point>y coordinate</a> and <a for=quadrilateral>point
3. Let <var>top</var> be the <a>NaN-safe minimum</a> of <a for=quadrilateral>point 1</a>'s <a
for=point>y coordinate</a>, <a for=quadrilateral>point 2</a>'s <a for=point>y coordinate</a>,
<a for=quadrilateral>point 3</a>'s <a for=point>y coordinate</a> and <a for=quadrilateral>point
4</a>'s <a for=point>y coordinate</a>.
4. Let <var>right</var> be the maximum of <a for=quadrilateral>point 1</a>'s <a for=point>x
coordinate</a>, <a for=quadrilateral>point 2</a>'s <a for=point>x coordinate</a>, <a
for=quadrilateral>point 3</a>'s <a for=point>x coordinate</a> and <a for=quadrilateral>point
4. Let <var>right</var> be the <a>NaN-safe maximum</a> of <a for=quadrilateral>point 1</a>'s <a
for=point>x coordinate</a>, <a for=quadrilateral>point 2</a>'s <a for=point>x coordinate</a>,
<a for=quadrilateral>point 3</a>'s <a for=point>x coordinate</a> and <a for=quadrilateral>point
4</a>'s <a for=point>x coordinate</a>.
5. Let <var>bottom</var> be the maximum of <a for=quadrilateral>point 1</a>'s <a for=point>y
coordinate</a>, <a for=quadrilateral>point 2</a>'s <a for=point>y coordinate</a>, <a
for=quadrilateral>point 3</a>'s <a for=point>y coordinate</a> and <a for=quadrilateral>point
5. Let <var>bottom</var> be the <a>NaN-safe maximum</a> of <a for=quadrilateral>point 1</a>'s <a
for=point>y coordinate</a>, <a for=quadrilateral>point 2</a>'s <a for=point>y coordinate</a>,
<a for=quadrilateral>point 3</a>'s <a for=point>y coordinate</a> and <a for=quadrilateral>point
4</a>'s <a for=point>y coordinate</a>.
6. Set <a for=rectangle>x coordinate</a> of <var>bounds</var> to <var>left</var>, <a
for=rectangle>y coordinate</a> of <var>bounds</var> to <var>top</var>, <a for=rectangle>width
Expand Down Expand Up @@ -1787,6 +1791,13 @@ Web. It is defined in this specification as an alias to {{DOMMatrix}}.
Some user agents supported a <code>MSCSSMatrix</code> interface. Implementations conforming to
this specification will not support <code>MSCSSMatrix</code>.

<h2 class="no-num" id="conventions">Document conventions</h2>

The <dfn>NaN-safe minimum</dfn> of a non-empty list of {{unrestricted double}} values is NaN if any
member of the list is NaN, or the minimum of the list otherwise.

Analogously, the <dfn>NaN-safe maximum</dfn> of a non-empty list of {{unrestricted double}} values
is NaN if any member of the list is NaN, or the maximum of the list otherwise.

<h2 class="no-num" id="changes">Changes since last publication</h2>

Expand Down

0 comments on commit b9edab7

Please sign in to comment.