Re: [css-houdini-drafts] [css-typed-om] Provide a way to resolve a CSSUnitValue and CSSMath* to a pixel value

If you have the percent resolution size, you can just do this yourself, no? Just go thru and replace all the %s with an appropriate pixel value.  I suppose this is mostly a convenience method?

I'd also like to be able to resolve `em` and such, which wants to know and about the element and the property. Like, without that info, we can resolve `em` the way MQs work; with an element, we can properly resolve against 'font-size'; with an element and a property, we can correctly handle `em` in font-size vs in other properties.

We already have to `to()` method for converting a value into a specific unit; we can give it some additional powers with an options bag giving resolution details:

```
partial interface CSSNumericValue {
    CSSUnitValue to(USVString unit, CSSUnitResolvingOptions options);
};

dictionary CSSUnitResolvingOptions {
  CSSUnitValue? hundredPercent = null;
  Element? element = null;
  USVString? property = null;
};
```

And it'll succeed if it can use the provided information to resolve everything to your desired type.

-- 
GitHub Notification of comment by tabatkins
Please view or discuss this issue at https://github.com/w3c/css-houdini-drafts/issues/798#issuecomment-415555133 using your GitHub account

Received on Thursday, 23 August 2018 20:09:47 UTC