On Mon, 5 Oct 2026 17:04:58 GMT, Andy Goryachev <[email protected]> wrote:

>> Enables importing of images from the clipboard into the RichTextModel by 
>> adding a data format handler for the DataFormat.IMAGE mime type.
>> 
>> This change includes new utility added by 
>> [JDK-8390345](https://bugs.openjdk.org/browse/JDK-8390345).
>> 
>> Note: the banana slug image is a public domain added with author's 
>> permission [0].
>> 
>> ## References
>> 
>> [0] https://en.wikipedia.org/wiki/Banana_slug
>> 
>> 
>> 
>> ---------
>> - [x] I confirm that I make this contribution in accordance with the 
>> [OpenJDK Interim AI Policy](https://openjdk.org/legal/ai).
>
> Andy Goryachev has updated the pull request with a new target base due to a 
> merge or a rebase. The pull request now contains 14 commits:
> 
>  - Merge branch 'master' into 8388276.import.images
>  - Merge branch 'master' into 8388276.import.images
>  - spelling
>  - Merge branch 'master' into 8388276.import.images
>  - copied from swing fx utils
>  - Merge branch 'master' into 8388276.import.images
>  - images
>  - lossless
>  - Merge branch 'master' into 8388276.import.images
>  - whitespace
>  - ... and 4 more: https://git.openjdk.org/jfx/compare/eab83a4b...b4c734c2

I left a couple inline comments and will go over the implementation and tests 
next.

modules/jfx.incubator.richtext/src/main/java/jfx/incubator/scene/control/richtext/model/ImageFormatHandler.java
 line 70:

> 68:     @Override
> 69:     public StyledInput createStyledInput(Object input, StyleAttributeMap 
> attr) throws IOException {
> 70:         Image im = (Image)input;

`RichTextModel` registers an instance of this class as a `DataFormatHandler` 
for images. That means it will show up in the list of supported data formats. 
If one were to pass an image format to `StyledTextModel.read(StyleResolver, 
DataFormat, InputStream)`, it will cause a CCE because input will be a `String 
`. This might or might not be a problem in practice given that it is not an 
exportable format and thus wouldn't be copied onto the clipboard or written to 
a file.

modules/jfx.incubator.richtext/src/main/java/jfx/incubator/scene/control/richtext/model/StyledTextModel.java
 line 456:

> 454:             li.onContentChange(ch);
> 455:         }
> 456:         markers.update(start, end, charsTop, linesAdded, charsBottom);

A listener that reads the marker will now see the old value rather than the 
new. This is a behavioral change that goes beyond image import. Is this a 
necessary part of adding support for importing images? If not, it should be 
reverted. If it is, it should be called out in the CSR.

-------------

PR Review: https://git.openjdk.org/jfx/pull/2224#pullrequestreview-5449314260
PR Review Comment: https://git.openjdk.org/jfx/pull/2224#discussion_r4212960727
PR Review Comment: https://git.openjdk.org/jfx/pull/2224#discussion_r4212785320

Reply via email to