[csswg-drafts] [css-filter-effects-1] Missing definition of a reference for percentage values if filterUnits="userSpaceOnUse" (#10563)

ccprog has just created a new issue for https://github.com/w3c/csswg-drafts:

== [css-filter-effects-1] Missing definition of a reference for percentage values if filterUnits="userSpaceOnUse" ==
Consider a SVG `<filter>` element with the following attributes:

    <filter id="myFilter" filterUnits="userSpaceOnUse">

It would be expanded according to the initial values defined in [§ 8](https://drafts.fxtf.org/filter-effects-1/#FilterEffectsRegion) to

    <filter id="myFilter" filterUnits="userSpaceOnUse" x="-10%" y="-10%" width="120%" height="120%">

[§ 7](https://drafts.fxtf.org/filter-effects-1/#FilterElement) defines the unit of the `x, y, width, height` values as [&lt;length-percentage&gt;](https://www.w3.org/TR/css-values-4/#typedef-length-percentage) as defined in CSS Values and Units Level 4.

This spec notes about [percentages](https://drafts.csswg.org/css-values-4/#percentage-value):

> Percentage values are always relative to another quantity, for example a length. Each property that allows percentages also defines the quantity to which the percentage refers.

Such a reference is missing. The text currently only says

> If [filterUnits](https://drafts.fxtf.org/filter-effects-1/#element-attrdef-filter-filterunits) is equal to [userSpaceOnUse](https://drafts.fxtf.org/filter-effects-1/#attr-valuedef-filterunits-userspaceonuse), [x](https://drafts.fxtf.org/filter-effects-1/#element-attrdef-filter-x), [y](https://drafts.fxtf.org/filter-effects-1/#element-attrdef-filter-y), [width](https://drafts.fxtf.org/filter-effects-1/#element-attrdef-filter-width), [height](https://drafts.fxtf.org/filter-effects-1/#element-attrdef-filter-height) represent values in the current user coordinate system in place at the time when the [filter](https://drafts.fxtf.org/filter-effects-1/#elementdef-filter) element is referenced (i.e., the user coordinate system for the element referencing the filter element via a [filter](https://drafts.fxtf.org/filter-effects-1/#propdef-filter) property).

-----

Current browser implementations seem to have filled the gap by falling back to the following rule in the [SVG 1.1 spec](https://www.w3.org/TR/SVG11/coords.html#Units):

> For percentage values that are defined to be relative to the size of viewport:
>
>   - For any x-coordinate value or width value expressed as a percentage of the viewport, the value to use is the specified percentage of the actual-width in user units for the nearest containing viewport, where actual-width is the width dimension of the viewport element within the user coordinate system for the viewport element.
>   - For any y-coordinate value or height value expressed as a percentage of the viewport, the value to use is the specified percentage of the actual-height in user units for the nearest containing viewport, where actual-height is the height dimension of the viewport element within the user coordinate system for the viewport element.

To me that seems to be a bit arbitrary, since there is no mention of "the size of the viewport" in the context of filter units. Also, this fallback is no longer applicable from the CSS Filter Effects module.

And finally, if the viewport is used as reference, it can have [unexpected results](https://stackoverflow.com/questions/78738393/why-dont-svg-filters-take-into-account-the-position-of-the-svgs-viewbox-since).

Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/10563 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Friday, 12 July 2024 13:41:23 UTC