Bug 259419

Summary: Better type handling in HTMLImageElement resource selection
Product: WebKit Reporter: Ahmad Saleem <ahmad.saleem792>
Component: ImagesAssignee: 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
Reported 2023-07-22 13:08:22 PDT
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
Ahmad Saleem
Comment 1 2023-07-22 13:11:12 PDT
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
Comment 2 2023-07-23 05:32:07 PDT
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
Comment 3 2023-07-29 13:09:15 PDT
Karl Dubost
Comment 4 2023-08-20 20:00:50 PDT
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
Comment 5 2023-08-20 20:02:39 PDT
Note You need to log in before you can comment on or make changes to this bug.