Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cherry-pick 0f76043. rdar://106763672
[iOS] Avoid transcoding images on file inputs unless the set of image types is explicitly restricted https://bugs.webkit.org/show_bug.cgi?id=267277 rdar://106763672 Reviewed by Abrar Rahman Protyasha. On iOS, when using an `<input type=file>` that supports images or videos, the user has the option to select content from their photo library. Historically, in WebKit, selected content has always been transcoded to JPEG (for images) and H.264 (for video). However, this can be undesirable for users that want to provide the image in its original form. In particular, this is important for photo editing applications. Furthermore, macOS does not have this general transcoding behavior. This patch changes the behavior on iOS so that transcoding to the compatible format for images is only performed if the `accept` attribute restricts the set of image types. Videos remain exempted from this behavior change due to known compatibility issues. Note that this change does have non-zero compatibility risk. However, it is more correct, and resolves known issues on image editing applications. Sites that want a compatibile representation are expected to use the `accept` attribute to indicate their need. * Source/WTF/Scripts/Preferences/UnifiedWebPreferences.yaml: Introduce a setting so the new behavior can easily be toggled off for testing. * Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm: (-[WKContentView fileUploadPanelPhotoPickerPrefersOriginalImageFormat:]): * Source/WebKit/UIProcess/ios/forms/WKFileUploadPanel.h: * Source/WebKit/UIProcess/ios/forms/WKFileUploadPanel.mm: (-[WKFileUploadPanel _preferredAssetRepresentationMode]): Disable transcoding by the picker if the set of restricted types is empty, or contains all image types. (-[WKFileUploadPanel _showPhotoPicker]): (-[WKFileUploadPanel picker:didFinishPicking:]): Continue to transcode video, when the picker does not perform transcoding, for compatibility. Canonical link: https://commits.webkit.org/275726@main
- Loading branch information