Bug 259419
Summary: | Better type handling in HTMLImageElement resource selection | ||
---|---|---|---|
Product: | WebKit | Reporter: | Ahmad Saleem <ahmad.saleem792> |
Component: | Images | Assignee: | Nobody <webkit-unassigned> |
Status: | NEW | ||
Severity: | Normal | CC: | annevk, bfulgham, karlcow, ntim, sabouhallawa, webkit-bug-importer |
Priority: | P2 | Keywords: | BrowserCompat, InRadar |
Version: | WebKit Nightly Build | ||
Hardware: | Unspecified | ||
OS: | Unspecified |
Ahmad Saleem
Hi Team,
While going through Blink's commit, I came across following commit:
Blink Commit: https://src.chromium.org/viewvc/blink?view=revision&revision=183450
Blink Function (as of today): https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/core/html/html_image_element.cc;l=402?q=isSupportedImagePrefixedMIMEType&ss=chromium
bool HTMLImageElement::SupportedImageType(
const String& type,
const HashSet<String>* disabled_image_types) {
String trimmed_type = ContentType(type).GetType();
// An empty type attribute is implicitly supported.
if (trimmed_type.empty())
return true;
if (disabled_image_types && disabled_image_types->Contains(trimmed_type)) {
return false;
}
return MIMETypeRegistry::IsSupportedImagePrefixedMIMEType(trimmed_type);
}
_______________
WebKit Source: https://searchfox.org/wubkat/source/Source/WebCore/platform/graphics/cg/UTIRegistry.cpp#126
^ If I am not wrong.
_______________
One thing, which is different and for reason, I raised this bug report is that, for 'empty type', Blink is returning 'true', while we are 'false'.
bool isSupportedImageType(const String& imageType)
{
if (imageType.isEmpty())
return false;
return defaultSupportedImageTypes().contains(imageType) || additionalSupportedImageTypes().contains(imageType);
}
__________________
Just wanted to raise, so we can get this sorted and CCed 'Anne' (well-versed in Standards) to get input. Also 'Brent' and 'Tim' - if they have any information.
This was raised on GitHub as following issue: https://github.com/ResponsiveImagesCG/picture-element/issues/238 (Took from Chrome Monorail bug)
__________
Thanks!
Attachments | ||
---|---|---|
Add attachment proposed patch, testcase, etc. |
Ahmad Saleem
Or I am wrong and this is taking care of my question:
https://searchfox.org/wubkat/source/Source/WebCore/html/HTMLImageElement.cpp#268
if (!type.isEmpty() && !MIMETypeRegistry::isSupportedImageVideoOrSVGMIMEType(type))
Anne van Kesteren
I recommend looking for tests in web-platform-tests or writing some to see how the type attribute is handled and whether that's consistent between browsers.
Radar WebKit Bug Importer
<rdar://problem/113084785>
Karl Dubost
Yes probably a couple of tests would help.
And after quickly checking on WPT, I didn't find anything obvious testing the type attribute on the source element.
Probably testing:
# unknown string
<picture>
<source type='unknown_type' srcset="something.png 400w, something2.png 800w">
<img src="working_image.jpg">
</picture>
# unknown string + a known one.
<picture>
<source type='unknown_type' srcset="something.png 400w, something2.png 800w">
<source type='image/jpeg' srcset="something.jpg 400w, something2.jpg 800w">
<img src="working_image.jpg">
</picture>
# empty string
<picture>
<source type='' srcset="something.png 400w, something2.png 800w">
<img src="working_image.jpg">
</picture>
# space string
<picture>
<source type='' srcset="something.png 400w, something2.png 800w">
<img src="working_image.jpg">
</picture>
# different type
<picture>
<source type='image/webp' srcset="something.png 400w, something2.png 800w">
<img src="working_image.jpg">
</picture>
etc.
Karl Dubost
Note that there is
https://wpt.fyi/results/media-source/mediasource-is-type-supported.html
Ahmad Saleem
https://github.com/chromium/chromium/commit/8e02e5b30ddd8b8b4992651e5d8c44131f3c0f92