commit | 13b460a482b42cf66bcfd122a84edcd1256f7c35 | [log] [tgz] |
---|---|---|
author | wenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc> | Mon Jan 24 23:47:36 2022 +0000 |
committer | wenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc> | Mon Jan 24 23:47:36 2022 +0000 |
tree | 1765b29f6b277043109e4a571a94a03dccfa5d1f | |
parent | f965b92b098035ee4bd50053df3c9b6d156aec49 [diff] |
[macOS] Update Pasteboard::read to prioritize native representations over TIFF https://bugs.webkit.org/show_bug.cgi?id=190101 rdar://44879244 Reviewed by Ryosuke Niwa. Source/WebCore: Currently on macOS, when pasting image data from the pasteboard into richly editable elements, we attempt to read the image data by checking a hard-coded list of types; in order, these are: TIFF, PDF, PNG, and finally JPEG. Since AppKit automatically provides TIFF as an available type for compatibility when writing non-TIFF image data to the pasteboard, this means that WebKit automatically transcodes all images to TIFF when pasting images in editable areas. This leads to unexpected behavior in Mail compose when using the continuity camera to insert images, since all drawings and photos end up being inserted as (often much larger) TIFF files instead of JPEG and PNG, respectively. To address this, we adjust `Pasteboard::read` to prioritize image formats in the hard-coded list above that were written directly to the pasteboard by the copier (i.e. without transcoding) before reading from the remaining types that were added to the pasteboard by the system (and thus require extra transcoding). In the case where only PNG and JPEG data was written to the pasteboard by the copier, this means we'll read images as PNG and JPEG data directly. If TIFF was explicitly written as an image format to the pasteboard, this patch will preserve existing behavior by reading the image data as TIFF. Note that this existing logic for reading images directly into web content is an existing privacy risk, since AppKit's pasteboard code preserves all metadata properties when transcoding between image formats. In the future, we should add a step here to strip out as much metadata as possible here, with an allow-list of metadata properties that are essential to preserving image fidelity (e.g. orientation). See: <https://webkit.org/b/235534> for more details. Test: WKAttachmentTests.PastingPreservesImageFormat * platform/mac/PasteboardMac.mm: (WebCore::Pasteboard::read): Refactor this logic so that we first try to read any natively written image formats that happen to be one of ("TIFF", "PDF", "PNG", "JPEG"), before trying to read any other types that would otherwise require transcoding. Tools: Add a cross-platform API test to verify that when using the client-side attachments, pasted image data of varying formats (PDF, JPEG, PNG) are read in their original form. See WebCore/ChangeLog for more details. This test currently passes on iOS but fails on macOS, where both the PNG and JPEG images are transcoded and read as TIFF. * TestWebKitAPI/Tests/WebKitCocoa/WKAttachmentTests.mm: (testJPEGFileURL): (testJPEGData): (platformCopyPDF): (platformCopyJPEG): (TestWebKitAPI::TEST): Drive-by fix: also remove a JavaScript evaluation in a nearby test that could only result in an exception (and was probably accidentally left there while writing the test). git-svn-id: http://svn.webkit.org/repository/webkit/trunk@288477 268f45cc-cd09-0410-ab3c-d52691b4dbfc
WebKit is a cross-platform web browser engine. On iOS and macOS, it powers Safari, Mail, iBooks, and many other applications.
Visit WebKit Feature Status page to see which Web API has been implemented, in development, or under consideration.
On macOS, download Safari Technology Preview to test the latest version of WebKit. On Linux, download Epiphany Technology Preview. On Windows, you'll have to build it yourself.
Once your bug is filed, you will receive email when it is updated at each stage in the bug life cycle. After the bug is considered fixed, you may be asked to download the latest nightly and confirm that the fix works for you.
On Windows, follow the instructions on our website.
Run the following command to clone WebKit's Git SVN repository:
git clone git@github.com:WebKit/WebKit.git WebKit
or
git clone https://github.com/WebKit/WebKit.git WebKit
If you want to be able to track Subversion revision from your git checkout, you can run the following command to do so:
Tools/Scripts/git-webkit setup-git-svn
For information about this, and other aspects of using Git with WebKit, read the wiki page.
If you don‘t want to use Git, run the following command to check out WebKit’s Subversion repository:
svn checkout https://svn.webkit.org/repository/webkit/trunk WebKit
Install Xcode and its command line tools if you haven't done so already:
xcode-select --install
Run the following command to build a debug build with debugging symbols and assertions:
Tools/Scripts/build-webkit --debug
For performance testing, and other purposes, use --release
instead.
You can open WebKit.xcworkspace
to build and debug WebKit within Xcode.
If you don't use a custom build location in Xcode preferences, you have to update the workspace settings to use WebKitBuild
directory. In menu bar, choose File > Workspace Settings, then click the Advanced button, select “Custom”, “Relative to Workspace”, and enter WebKitBuild
for both Products and Intermediates.
iOS, tvOS and watchOS are all considered embedded builds. The first time after you install a new Xcode, you will need to run:
sudo Tools/Scripts/configure-xcode-for-embedded-development
Without this step, you will see the error message: “target specifies product type ‘com.apple.product-type.tool’, but there’s no such product type for the ‘iphonesimulator’ platform.
” when building target JSCLLIntOffsetsExtractor
of project JavaScriptCore
.
Run the following command to build a debug build with debugging symbols and assertions for embedded simulators:
Tools/Scripts/build-webkit --debug --<platform>-simulator
or embedded devices:
Tools/Scripts/build-webkit --debug --<platform>-device
where platform
is ios
, tvos
or watchos
.
For production builds:
cmake -DPORT=GTK -DCMAKE_BUILD_TYPE=RelWithDebInfo -GNinja ninja sudo ninja install
For development builds:
Tools/gtk/install-dependencies Tools/Scripts/update-webkitgtk-libs Tools/Scripts/build-webkit --gtk --debug
For more information on building WebKitGTK+, see the wiki page.
For production builds:
cmake -DPORT=WPE -DCMAKE_BUILD_TYPE=RelWithDebInfo -GNinja ninja sudo ninja install
For development builds:
Tools/wpe/install-dependencies Tools/Scripts/update-webkitwpe-libs Tools/Scripts/build-webkit --wpe --debug
For building WebKit on Windows, see the wiki page.
Run the following command to launch Safari with your local build of WebKit:
Tools/Scripts/run-safari --debug
The run-safari
script sets the DYLD_FRAMEWORK_PATH
environment variable to point to your build products, and then launches /Applications/Safari.app
. DYLD_FRAMEWORK_PATH
tells the system loader to prefer your build products over the frameworks installed in /System/Library/Frameworks
.
To run other applications with your local build of WebKit, run the following command:
Tools/Scripts/run-webkit-app <application-path>
Run the following command to launch iOS simulator with your local build of WebKit:
run-safari --debug --ios-simulator
In both cases, if you have built release builds instead, use --release
instead of --debug
.
If you have a development build, you can use the run-minibrowser script, e.g.:
run-minibrowser --debug --wpe
Pass one of --gtk
, --jsc-only
, or --wpe
to indicate the port to use.
Congratulations! You’re up and running. Now you can begin coding in WebKit and contribute your fixes and new features to the project. For details on submitting your code to the project, read Contributing Code.