- From: Tab Atkins Jr. via GitHub <sysbot+gh@w3.org>
- Date: Thu, 06 Apr 2023 22:42:14 +0000
- To: public-houdini-archive@w3.org
Draft proposal: Add a .resolveUnits() method to CSSNumericValue, CSSTransformValue, and CSSTransformComponent. (Maybe CSSColorValue as well?) Defined as:
```webidl
partial interface CSSNumericValue {
CSSUnitValue resolveUnits(CSSUnitResolvingOptions options);
};
/* etc for the other interfaces */
dictionary CSSUnitResolvingOptions {
CSSUnitValue? hundredPercent = null;
Element? element = null;
USVString? property = null;
};
```
* If `hundredPercent` is specified, all percentages resolve against that.
* If `element` is specified, all non-percent relative units resolve against that element, in a generic fashion. (So 'em' uses the 'font-size' on the element, rather than the special behavior that 'em' has in 'font-size' itself.)
* If `element` *and* `property` is specified, all relative units resolve against that element *in the context of that property*. Need to define this generically in some way.
* For the transform types (and other specific types), `element` (and `property`, if needed) will resolve %s as appropriate, too, if you're not overriding it with `hundredPercent`. So you can `el.styleMap.get('transform').resolveUnits(el)` and get it fully resolved correctly, with the x and y values using the correct length to resolve %s automatically.
--
GitHub Notification of comment by tabatkins
Please view or discuss this issue at https://github.com/w3c/css-houdini-drafts/issues/798#issuecomment-1499717954 using your GitHub account
--
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config
Received on Thursday, 6 April 2023 22:42:16 UTC