RFR: 8311689: Wrong visible amount in Adjustable of ScrollPane

Alexey Ivanov aivanov at openjdk.org
Mon Jul 10 17:34:22 UTC 2023


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.

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

Commit messages:
 - Remove debug prints
 - 8311689: Wrong visible amount in Adjustable of ScrollPane

Changes: https://git.openjdk.org/jdk/pull/14815/files
 Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=14815&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8311689
  Stats: 95 lines in 2 files changed: 93 ins; 1 del; 1 mod
  Patch: https://git.openjdk.org/jdk/pull/14815.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/14815/head:pull/14815

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



More information about the client-libs-dev mailing list