On Mon, 10 Jul 2023 19:27:35 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.
>
> Alexey Ivanov has updated the pull request incrementally with one additional 
> commit since the last revision:
> 
>   Add Robot.waitForIdle
>   
>   It ensures getViewportSize in the test is called
>   after AwtScrollPane::_SetSpans completes on the
>   toolkit thread.

Marked as reviewed by serb (Reviewer).

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

PR Review: https://git.openjdk.org/jdk/pull/14815#pullrequestreview-1523200649

Reply via email to