-
Notifications
You must be signed in to change notification settings - Fork 719
[css-content] Does content: url()
apply to images?
#2831
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
cc @lilles |
Dynamic changes are handled correctly because content property changes already cause a reframe. This implements the same bits as Blink / WebKit do (single content item which is an image, otherwise gets ignored), except for the edge cases where you use this on an image. In order to handle the edge cases right, we completely isolate the nsImageLoadingContent usage based on `mKind`. Blink's and WebKit's behavior there makes no sense and it's erratic, what I implemented is consistent (we apply to images as long as they don't generate a box, and we don't look at alt text or broken icons), though I'll update to whatever the WG decides in w3c/csswg-drafts#2831 / w3c/csswg-drafts#2832. I don't think it matters in terms of web compat in any case. MozReview-Commit-ID: JUurhC60hWr
Dynamic changes are handled correctly because content property changes already cause a reframe. This implements the same bits as Blink / WebKit do (single content item which is an image, otherwise gets ignored), except for the edge cases where you use this on an image. In order to handle the edge cases right, we completely isolate the nsImageLoadingContent usage based on `mKind`. Blink's and WebKit's behavior there makes no sense and it's erratic, what I implemented is consistent (we apply to images as long as they don't generate a box, and we don't look at alt text or broken icons), though I'll update to whatever the WG decides in w3c/csswg-drafts#2831 / w3c/csswg-drafts#2832. I don't think it matters in terms of web compat in any case. bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=215083 gecko-commit: 2ca43c308ce1c5063fd1f2be7984dc781ab70c0c gecko-integration-branch: mozilla-inbound gecko-reviewers: tnikkel, dholbert
Dynamic changes are handled correctly because content property changes already cause a reframe. This implements the same bits as Blink / WebKit do (single content item which is an image, otherwise gets ignored), except for the edge cases where you use this on an image. In order to handle the edge cases right, we completely isolate the nsImageLoadingContent usage based on `mKind`. Blink's and WebKit's behavior there makes no sense and it's erratic, what I implemented is consistent (we apply to images as long as they don't generate a box, and we don't look at alt text or broken icons), though I'll update to whatever the WG decides in w3c/csswg-drafts#2831 / w3c/csswg-drafts#2832. I don't think it matters in terms of web compat in any case. bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=215083 gecko-commit: 2ca43c308ce1c5063fd1f2be7984dc781ab70c0c gecko-integration-branch: mozilla-inbound gecko-reviewers: tnikkel, dholbert
Dynamic changes are handled correctly because content property changes already cause a reframe. This implements the same bits as Blink / WebKit do (single content item which is an image, otherwise gets ignored), except for the edge cases where you use this on an image. In order to handle the edge cases right, we completely isolate the nsImageLoadingContent usage based on `mKind`. Blink's and WebKit's behavior there makes no sense and it's erratic, what I implemented is consistent (we apply to images as long as they don't generate a box, and we don't look at alt text or broken icons), though I'll update to whatever the WG decides in w3c/csswg-drafts#2831 / w3c/csswg-drafts#2832. I don't think it matters in terms of web compat in any case. MozReview-Commit-ID: JUurhC60hWr
Edited on 2018-08-22 with a better screenshot. Tested with http://la-grange.net/2018/07/31/content/ in
|
'content' should definitely work on Now, what to do when the 'content' URL is broken, but a 'src' url exists, is an interesting question. It seems like it makes the most sense to have 'content' fully win, so that if it's specified but the URL is broken, you just get the "0x0 transparent image" that's specified in the spec? This appears to be what falls out of the definitions, at least. We could instead specify that there's some notion of an "intrinsic image" coming from the element that it can fall back if possible, but that seems like complexity for complexity's sake; if we want to do fallback, we should just implement Notably, tho, Assuming that, ignoring the relayout bugs, Safari's behavior would be correct (showing a broken image, since no alt was provided in |
I changed the screenshot in #2831 (comment) as Chrome and Safari seem to be consistent. |
Well, image is a replaced element, and |
Slightly related: #729 (edit: wrong issue) |
Take this as my assertion that |
Dynamic changes are handled correctly because content property changes already cause a reframe. This implements the same bits as Blink / WebKit do (single content item which is an image, otherwise gets ignored), except for the edge cases where you use this on an image. In order to handle the edge cases right, we completely isolate the nsImageLoadingContent usage based on `mKind`. Blink's and WebKit's behavior there makes no sense and it's erratic, what I implemented is consistent (we apply to images as long as they don't generate a box, and we don't look at alt text or broken icons), though I'll update to whatever the WG decides in w3c/csswg-drafts#2831 / w3c/csswg-drafts#2832. I don't think it matters in terms of web compat in any case. MozReview-Commit-ID: JUurhC60hWr UltraBlame original commit: 2ca43c308ce1c5063fd1f2be7984dc781ab70c0c
Dynamic changes are handled correctly because content property changes already cause a reframe. This implements the same bits as Blink / WebKit do (single content item which is an image, otherwise gets ignored), except for the edge cases where you use this on an image. In order to handle the edge cases right, we completely isolate the nsImageLoadingContent usage based on `mKind`. Blink's and WebKit's behavior there makes no sense and it's erratic, what I implemented is consistent (we apply to images as long as they don't generate a box, and we don't look at alt text or broken icons), though I'll update to whatever the WG decides in w3c/csswg-drafts#2831 / w3c/csswg-drafts#2832. I don't think it matters in terms of web compat in any case. MozReview-Commit-ID: JUurhC60hWr UltraBlame original commit: 2ca43c308ce1c5063fd1f2be7984dc781ab70c0c
Dynamic changes are handled correctly because content property changes already cause a reframe. This implements the same bits as Blink / WebKit do (single content item which is an image, otherwise gets ignored), except for the edge cases where you use this on an image. In order to handle the edge cases right, we completely isolate the nsImageLoadingContent usage based on `mKind`. Blink's and WebKit's behavior there makes no sense and it's erratic, what I implemented is consistent (we apply to images as long as they don't generate a box, and we don't look at alt text or broken icons), though I'll update to whatever the WG decides in w3c/csswg-drafts#2831 / w3c/csswg-drafts#2832. I don't think it matters in terms of web compat in any case. MozReview-Commit-ID: JUurhC60hWr UltraBlame original commit: 2ca43c308ce1c5063fd1f2be7984dc781ab70c0c
Uh oh!
There was an error while loading. Please reload this page.
Blink and WebKit implement
content: url()
allowing to replace an element with an image.However the behavior differs and doesn't look quite intentional, and WebKit's behavior looks different if the image is already loaded or not (the second image would display alt text after a relayout, wat).
Consider this test-case:
How should this render? Should) it just doesn't render?
content: url()
apply or not? If it does, should it display thealt
text? Why only for![]()
(if the image is broken in aAlso, note that in Blink at least, if the image is already loaded for the second
![]()
, or if you toggledisplay
manually, suddenly it displays the image instead of thealt
text.The text was updated successfully, but these errors were encountered: