RFR: 8160597: IllegalArgumentException when we initiate drag on Image
Kevin Rushforth
kcr at openjdk.java.net
Wed Nov 24 16:58:13 UTC 2021
On Mon, 15 Nov 2021 11:19:13 GMT, Jose Pereda <jpereda at openjdk.org> wrote:
> 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).
The fix looks good. The test looks good with one minor comment.
tests/system/src/test/java/test/com/sun/glass/ui/mac/MacPasteboardTest.java line 56:
> 54: public static void setup() throws Exception {
> 55: Platform.startup(() -> {
> 56: if (PlatformUtil.isMac()) {
Minor: it might be cleaner to wrap the entire body of the `setup` and `teardown` methods in `if (PlatformUtil.isMac())` so that we don't even start FX on platforms other than macOS.
-------------
PR: https://git.openjdk.java.net/jfx/pull/668
More information about the openjfx-dev
mailing list