New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 825895 link

Starred by 8 users

Issue metadata

Status: Available
Owner: ----
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Linux , Android , Windows , Chrome , Mac
Pri: 3
Type: Feature



Sign in to add a comment

Implement CSS Values Level 4 Mathematical Functions

Project Member Reported by domfarolino@gmail.com, Mar 26 2018

Issue description

<b>Chrome Version       : <Copy from: 'about:version'></b>
URLs (if applicable) : https://github.com/whatwg/html/pull/3084
Other browsers tested:
  Apple is implementing presently, according to Tab

Currently Chromium supports `calc()` as a CSS mathematical function. The CSS Values and Units Level 4 Specification describes a list of math functions [1] consisting of `calc()` in addition to `min()` and `max()`. Apple has started implementing this.

This motivation for opening this bug is the recent reference to the aforementioned mathematical functions in the HTML Standard [2], which supports the appearance of mathematical functions in the `sizes` attribute on <img> elements.

[1]: https://drafts.csswg.org/css-values/#math-function
[2]: https://github.com/whatwg/html/pull/3084 & https://github.com/w3c/web-platform-tests/pull/10167
 
Components: -Blink>Image
Images will fall out of CSS changes. There's no special CSS length handling in the image code.
Ok, makes sense; that's what I was thinking but wasn't sure the best way to allocate the components.

Comment 3 by 594man...@gmail.com, Mar 27 2018

https://developers.google.com/web/updates/2018/03/cssom#CSSUnitValue

CSS Typed Object Model support `min()` and `max()` ?


>> new CSSMathMax(CSS.percent(80), CSS.px(12)).toString(); // "max(80%, 12px)"

Hmm, if I understand you correctly, that's not what my intention was with this issue. My intention was to file a bug to catalyze the implementation of `min()` and `max()` mathematical functions described in the spec; for example:

`div { width: min(100%, 800px); }`

Or better yet (and the motivation behind this issue):

`<img srcset="..." sizes="max(40%, 300px)"`.

Hopefully that makes sense.

Comment 5 by e...@chromium.org, Apr 4 2018

Labels: -Type-Bug Type-Feature
Status: Available (was: Untriaged)
Of course 594mantou@gmail.com, that should indeed translate to the typed OM you mention, but I'm assuming the underlying CSS functions (that eventually get exposed to the typed OM) will need implemented and that's the primary purpose of this issue.
Mobile safari has min() and max() and webkit's example page for dealing with notches uses it: 

https://webkit.org/blog/7929/designing-websites-for-iphone-x/

...only to find that chrome hasn't gotten around to it yet, so I have to try to find some other solution. I can't seem to get the values of css custom properties from javascript when they're inside shadowRoots either :/ (I was hoping to be able to use Math.max(), but no joy).
Can I suggest that this issue should have a higher priority?

I am struggling to find a way to do something like this:

padding-left: max(env(safe-area-inset-left), var(--padding-left));

It's also stopping me from using max() for iPhone too, though I should probably use the method in the above blog:

@supports(padding: max(0px)) {

Is there some way of doing this on Chrome that I'm missing?
Cc: tabatkins@chromium.org
+tabatkins@, as I'm not exactly sure who this might fall under implementation-wise, and what the priority of it should be.

Sign in to add a comment