[webkit-changes] [WebKit/WebKit] 0f7604: [iOS] Avoid transcoding images on file inputs unle...

Aditya Keerthi noreply at github.com
Tue Mar 5 21:18:27 PST 2024


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 0f76043f78527099a8af73cff7e76c489fd79568
      https://github.com/WebKit/WebKit/commit/0f76043f78527099a8af73cff7e76c489fd79568
  Author: Aditya Keerthi <akeerthi at apple.com>
  Date:   2024-03-05 (Tue, 05 Mar 2024)

  Changed paths:
    M Source/WTF/Scripts/Preferences/UnifiedWebPreferences.yaml
    M Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm
    M Source/WebKit/UIProcess/ios/forms/WKFileUploadPanel.h
    M Source/WebKit/UIProcess/ios/forms/WKFileUploadPanel.mm

  Log Message:
  -----------
  [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



To unsubscribe from these emails, change your notification settings at https://github.com/WebKit/WebKit/settings/notifications


More information about the webkit-changes mailing list