On Mon, 10 Jul 2023 17:23:22 GMT, Alexey Ivanov <[email protected]> wrote:

> It proved that `ScrollPane.layout` depends on the result of 
> `WScrollPanePeer.childResized`, specifically on `setSpans` which recalculates 
> the spans and sets the insets.
> 
> https://github.com/openjdk/jdk/blob/b285ed72aebe2d802fa9c071372cea6c09870b9a/src/java.desktop/share/classes/java/awt/ScrollPane.java#L514-L521
> 
> After the fix for [JDK-8297923](https://bugs.openjdk.org/browse/JDK-8297923), 
> `setSpans` that is called in `childResized` is run asynchronously on the 
> toolkit thread. Therefore `getViewportSize` uses the wrong insets which don't 
> take into account the size of the scroll bar. Because of it, the 
> `visibleAmount` field of adjustables is also wrong, and the scroll pane 
> cannot display a portion of its child component.
> 
> I overlooked this dependency even when I was fixing the first regression, 
> [JDK-8310054](https://bugs.openjdk.org/browse/JDK-8310054). Had I followed 
> Harshitha's advice in #14478, I would've fixed this problem too. Similarly, 
> Phil's intuition was right: `setSpans` should be synchronous. @honkar-jdk 
> @prrace
> 
> **Fix**
> 
> The fix is to run `AwtScrollPane::_SetSpans` synchronously using 
> `AwtToolkit::InvokeFunction`.
> 
> I also addressed [Sergey's 
> concern](https://github.com/openjdk/jdk/pull/14478#discussion_r1239049983): 
> `VerifyState` is now called after `SetInsets`. @mrserb
> 
> Client tests are green.

This pull request has now been integrated.

Changeset: b3f34039
Author:    Alexey Ivanov <[email protected]>
URL:       
https://git.openjdk.org/jdk/commit/b3f34039fedd3c49404783ec880e1885dceb296b
Stats:     98 lines in 2 files changed: 96 ins; 1 del; 1 mod

8311689: Wrong visible amount in Adjustable of ScrollPane

Reviewed-by: prr, honkar, serb

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

PR: https://git.openjdk.org/jdk/pull/14815

Reply via email to