On Wed, 14 Jun 2023 20:17:32 GMT, Alexey Ivanov <[email protected]> wrote:

> After the size of `ScrollPane` child component changes, it recalculates the 
> size of the scroll bars and hides or shows them as necessary. This situation 
> is handled in `WScrollPanePeer.childResized`:
> 
> https://github.com/openjdk/jdk/blob/ee4ab6709ebaf8a1b1e9f297a7c53205987f3eba/src/java.desktop/windows/classes/sun/awt/windows/WScrollPanePeer.java#L104-L109
> 
> After [JDK-8297923](https://bugs.openjdk.org/browse/JDK-8297923), `setSpans` 
> is run asynchronously on the toolkit thread. Thus, `setInsets` calculates the 
> incorrect values because `setSpans` hasn't updated the sizes yet.
> 
> This is a regression from 
> [JDK-8297923](https://bugs.openjdk.org/browse/JDK-8297923).
> 
> **Fix**
> 
> The insets are updated in the native implementation of `setSpans` directly.
> 
> The native implementation of `setInsets` method is run on the toolkit thread 
> as a synchronous call because the insets are used in 
> [`WScrollPanePeer.initialize`](https://github.com/openjdk/jdk/blob/ee4ab6709ebaf8a1b1e9f297a7c53205987f3eba/src/java.desktop/windows/classes/sun/awt/windows/WScrollPanePeer.java#L62-L67).

Following the same way of thought, I'd like to coalesce `setInsets`, 
`getInsets` followed by `setScrollPosition` in `WScrollPanePeer.initialize` 
into one native call as well. I believe this would be more efficient. I've 
already submitted [JDK-8310056](https://bugs.openjdk.org/browse/JDK-8310056) 
for it.

That change is related to this but I'd rather keep them separate: it's safer to 
make small changes. Moreover they're independent.

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

PR Comment: https://git.openjdk.org/jdk/pull/14478#issuecomment-1593838351

Reply via email to