RFR: 8160597: IllegalArgumentException when we initiate drag on Image
Jose Pereda
jpereda at openjdk.java.net
Mon Nov 15 11:24:59 UTC 2021
This PR fixes an exception that can happen when dragging an image from a WebView on macOS.
Dragging an image that is directly included like `<img src="some image"/>` works fine, without exception. However, there are (at least) two other cases when the IAE is thrown:
- Dragging an image that is part of an hyperlink, like `<a href="some url"><img src="some image"/></a>`.
- Dragging an image encoded as base64.
The IAE happens only on macOS, where a native image is created in `GlassPasteboard.m` from an URL, and in those two cases the generated image has 0x0 dimensions:
`<NSImage 0x... Size={0, 0} ...>`
which leads to `ByteArrayFromPixels` being called with a null byte array.
The included test reproduces the case by directly pushing the `MacPasteboard` content (instead of adding a more complex test with a webView and a drag and drop gesture).
-------------
Commit messages:
- Remove unused imports
- Check if MacPasteboard contains a valid image, including test
Changes: https://git.openjdk.java.net/jfx/pull/668/files
Webrev: https://webrevs.openjdk.java.net/?repo=jfx&pr=668&range=00
Issue: https://bugs.openjdk.java.net/browse/JDK-8160597
Stats: 155 lines in 5 files changed: 154 ins; 0 del; 1 mod
Patch: https://git.openjdk.java.net/jfx/pull/668.diff
Fetch: git fetch https://git.openjdk.java.net/jfx pull/668/head:pull/668
PR: https://git.openjdk.java.net/jfx/pull/668
More information about the openjfx-dev
mailing list