RFR: 8328977 : JEditorPane.setPage not thread-safe, pageLoader not cancelled [v3]

Alexey Ivanov aivanov at openjdk.org
Mon Apr 22 15:06:30 UTC 2024


On Mon, 22 Apr 2024 08:41:13 GMT, Tejesh R <tr at openjdk.org> wrote:

>> src/java.desktop/share/classes/javax/swing/JEditorPane.java line 483:
>> 
>>> 481:             // The same page with different reference
>>> 482:             if (reference != null) {
>>> 483:                 scrollToReference(reference);
>> 
>> Do we need to move ` scrollToReference(reference);` to swingUtil ? If not any reason for invoking it in swingUtil at line 547 and not here?
>
> Is it because of same page which is already loaded and no reloading is required?

Yes, the page is already loaded, it's rendered, so the location to scroll to can be calculated right away.

Below, there's a comment:
https://github.com/openjdk/jdk/blob/be168e9d331ead58503ac3a01dae0bd98ae42d5e/src/java.desktop/share/classes/javax/swing/JEditorPane.java#L544-L549

This piece of code is unchanged. The new document is just loaded. To calculate the location to scroll to, the view hierarchy needs to be created and laid out; this is why `invokeLater` is used — to delay calculating the position.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/18670#discussion_r1574917367


More information about the client-libs-dev mailing list