Open fantasai opened 7 years ago
A hearty +1 to treating an invalid mask as no mask at all.
Test case for filter: https://codepen.io/krit/pen/pVYabE?editors=1000 In order of the test case:
Behavior of <filter> on element |
Edge | Gecko | Blink | WebKit |
---|---|---|---|---|
no content | disappears | disappears | disappears | disappears |
grouped content followed by valid content | applies1 | applies1 | applies1 | applies1 |
invalid, followed by valid content | applies2 | applies2 | applies2 | applies2 |
missing reference | disappears | disappears | disappears | disappears |
1) Grouped content gets ignored, valid content applies. 2) Invalid content gets ignored, valid content applies.
Test case for clipping: https://codepen.io/krit/pen/NMJyXr?editors=1000 In order of the test case:
Behavior of <clipPath> on element |
Edge | Gecko | Blink | WebKit |
---|---|---|---|---|
no content | disappears | disappears | disappears | disappears |
grouped content | disappears | disappears | disappears | disappears |
invalid, followed by valid content | clipped1 | disappears | clipped1 | clipped1 |
missing reference | no clipping | no clipping | no clipping | no clipping |
circular dependency | clipped2 | disappears | clipped2 | clipped2 |
<use> referencing <g> w/ content |
clipped3 | disappears | clipped1 | clipped1 |
1) Clipped by valid (by spec) content. 2) Clipped by content, circular dependencies get removed. 3) Clipped by combination of use and valid content.
Test case for masking: https://codepen.io/krit/pen/derdaE?editors=1000 In order of the test case:
Behavior of <mask> on element |
Edge | Gecko | Blink | WebKit |
---|---|---|---|---|
no content | disappears | disappears | disappears | disappears |
grouped content followed by valid content | applies1 | applies1 | applies1 | applies1 |
invalid, followed by valid content | applies2 | applies2 | applies2 | applies2 |
missing reference | no masking | no masking | no masking | no masking |
circular dependency | applies3 | disappears | applies3 | applies3 |
1) Grouped content gets ignored, valid content applies. 2) Invalid content gets ignored, valid content applies. 3) Masking applies, circular dependencies get removed.
Interesting for #17: Blink and WebKit do not take <use>
referenced elements for clipping into account that do not match the <clipPath>
content model. Edge does, which means an inconsistency in its own model. Gecko ignores the entire clipping resource.
Any decision on this? I discovered this issue with missing objects and undefined mask reference in a small number of our SVGs and we need to decide between wait Firefox to fix it or inspect and re-generate thousands of SVGs.
See this example: https://codepen.io/anon/pen/WKPwJr?editors=1000
The Working Group just discussed Issue Make the behavior of an invalid mask be consistent with clip-path and filter
.
The SVG Working Group just discussed make the behavior of an invalid mask be consistent with clip-path and filter
, and agreed to the following:
RESOLVED: For clipping and masking, we follow the behavior of Edge, WebKit, and Blink in the https://github.com/w3c/fxtf-drafts/issues/130#issuecomment-390981529 table
RESOLVED: If a referenced filter is missing or invalid, the side effects like stacking context are still preserved.
Dirk asked for an async resolution on the public mailing list: https://lists.w3.org/Archives/Public/www-style/2019Sep/0013.html
I agree that we can use async resolution for this.
Unless I hear here or on the mailing list that someone wants to go over this issue on a call, or objects to the resolution, the rules above will be resolved by the CSS WG on October 14th.
Chiming in with one remark about mask-border vs mask discrepancy seen in current spec, one amusing remark about real-world outcome of it, and simple testcase/exhibit of this phenomenon.
mask-image
: A mask reference that […] fails to download […] still counts as an image layer of transparent black.
mask-border-source
: An image that […] fails to download […] still counts as an mask border image but does not mask the element.
Emphasis mine {*1}. That "but does not mask the element" postscript for the border would definitely make sense for the regular mask as well.
Google Fonts include "Font Effects" beta feature (apparently from it's beginning) that adds some class along font declaration with some extra styling and some of them use masks (when their browser sniffing decides there is a chance UA that made the request could support them).
Currently they are serving CSS from fonts.googleapis.com
, font files from fonts.gstatic.com
and mask images from themes.googleusercontent.com
. For example https://fonts.googleapis.com/css?family=Rancho&effect=brick-sign
currently responds to Chromium-based browsers with:
/* latin */
@font-face {
font-family: 'Rancho';
font-style: normal;
font-weight: 400;
src: url(https://fonts.gstatic.com/s/rancho/v17/46kulbzmXjLaqZRVam_h.woff2) format('woff2');
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
.font-effect-brick-sign {
-webkit-mask-image: url(//themes.googleusercontent.com/static/patterns/brick-sign.png);
color: #600;
}
Thing is, the last domain serving mask (raster) images currently does not sent permissive CORS headers, preventing them to load in (any) cross-domain context, so the result is present even at their own API docs (https://developers.google.com/fonts/docs/getting_started#enabling_font_effects_beta):
This is how it looks when it works, thanks Internet Archive WayBack Machine snapshot of that page from the year 2019 that contains all mirrored resources and servers them from single origin:
data:text/html;charset=utf-8,<!doctype html><html lang="en"><title>
mask-image failing and not-failing image test</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>b { font: 3rem Impact; text-transform: uppercase}</style>
<p>Hello, <b style="-webkit-mask-image: url()">failing</b> <code>mask-image</code>.
<p>Hello, <b style="-webkit-mask-image: url('data:image/svg+xml;charset=utf-8,<svg xmlns=%2527http://www.w3.org/2000/svg%2527 viewBox=%25273,-15,16,19%2527><text>🦄</text></svg>');">not-failing</b> <code>mask-image</code>.
in accordance with current spec draft produces:
{*1} Sorry for not using mark
element but as it seems GitHub does not support that.
Since bug 1765202 has landed, Firefox should behave more like Chrome/Safari.
But does it really make sense for the spec to order that
data:text/html;charset=utf-8,☞︎ <b style="mask-image: url(ERROR)">HELLO??</b> ☜
must render:
☞ ☜
not:
☞ HELLO?? ☜
just like does with case of bogus mask-border-source
, though?
(I thought that this was the main issue here(?).)
I'm also surprised that the effect of a css mask-image
that fails to load is to hide the element the property applies to. Especially when a core css design principle is that "content should be viewable and accessible by default".
Maybe we need safe
and unsafe
keywords to allow authors to control this behavior?
mask-image: safe url(ERR);
From @CJKu on February 2, 2017 3:14
According to css-masking spec,[1]:
Transparent black means the masked object disappeared. The way we handle invalid mask is apparently not the same with clip-path and filter. Both clip-path[2] and filter[3] keep the target element visible. I wonder why only masking has different behavior and think it would be better to keep the consistent.
[1] css-masking positioned-mask https://drafts.fxtf.org/css-masking-1/#the-mask-image
[2] css-masking clip-path https://drafts.fxtf.org/css-masking-1/#the-clip-path
[3] css filter https://drafts.fxtf.org/filters/#FilterProperty
Copied from original issue: w3c/csswg-drafts#997