-
Notifications
You must be signed in to change notification settings - Fork 473
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
8298728: Cells in VirtualFlow jump after resizing #974
Conversation
…r offset to change. Allow to fix the index/offset when doing recalculations. Fix JDK-8298728
👋 Welcome back jvos! A progress list of the required criteria for merging this PR into |
Webrevs
|
I am trying to understand what the behavioral difference is between this branch and the current master. The ticket JDK-8298728 does not seem to specify the exact scenario, so I tried the following code with the large model (3000 lines) with a wrapping Text as graphic node. Resizing both vertically and horizontally produces what I this is identical result where the top visible selected cell scrolls out of the view in both cases. cell factory:
I can attache the whole program to the jira ticket. |
int oldIndex = computeCurrentIndex(); | ||
double cellLength = getOrCreateCellSize(index); | ||
if (index > 0) getOrCreateCellSize(index - 1); | ||
if (index < getCellCount() -1) getOrCreateCellSize(index + 1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's better to keep one statement per line - for stepping through in a debugger, and also if an exception gets thrown it will be easier to see where.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True -- I'll change that.
I added a new test in VirtualFlowTest. It fails without the patch, and succeeds with the patch. The change is that if a cell is shown with some given content, then a cell is resized, and then a scroll operation is performed, the result of this scroll could be unexpected. I added comments in the added test so that the flow should be clear. Does this help? |
I think this might be the case when unit tests are insufficient. |
/reviewers 2 |
@kevinrushforth |
That sounds exactly like something that should be a unit test. |
Add another failing test, and a fix: when the cell that is positioned at the "current index" is resized, we also need to modify the offset (wich is calculated from the top of that cell to the start of the viewport).
|
I can confirm that this fixes every remaining issue related to ListView to my knowledge. My test application (which was an extended version of the test in this ticket: https://bugs.openjdk.org/browse/JDK-8277785) works now 100% correctly. The application at Zeiss works now without any ListView-related workaround. So, on my side - with this fix, all ListView issues known to me are fixed. |
#1: I had a look at that video and I don't think this is a bug. Nowhere in the spec or javadoc it is mentioned that a page-up followed by a page-down should give the same position. This would imho actually be a bad requirement, as in case sizes are changing (which happens to be the case in most real-world scenario's I've seen so far) this would conflict with other requirements. One might argue that "in case the size of individual cells didn't change", the scroll-up/scroll-down should result in a same "offset" as before the operation but that is not a requirement so far. Could be discussed in another issue. #2. I don't see what is missing. It seems to me both the ticket and the new test in the PR show the scenario of what goes wrong before the patch, and what is expected (in the assert). I can copy it here again, but I'm not understanding your question I think. |
Thank you for commenting, Johan. Interesting. Why would sizes change in #1 scenario, since there are no changes in the component width and the scroll bar state? But I might disagree - it's the most natural case when pgup/pgdn results in the same state, as any text editor would demonstrate. In fact, I have a similar problem with "If we want the position of the thumb constant," - I'd rather see the thumb reflecting reality as much as it could, so it is ok for it to jump, as long as the selected cell remains in the same position on screen. It looks like the ticket talks about the "first cell" instead which would be an acceptable replacement. As for #2 - it might be just me, I cannot translate these words into a scenario. Are you saying that, for example, resizing and immediately issuing pgup/pgdn (via click on a scrollbar) would shift the viewport too far/not enough? Or is there another scenario? What are the exact steps that result in erroneous behavior, in human words? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall fix looks good to me.
I have identified two very minor typos.
assertEquals(300, thirdCell.getLayoutY(), 1.); | ||
|
||
|
||
for (int i =0 ; i < heights.length; i++) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor : Need a space after =
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
if (index > 0) { | ||
getOrCreateCellSize(index - 1); | ||
} | ||
if (index < getCellCount() -1) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor : Need a space after -
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
@johanvos This change now passes all automated pre-integration checks. ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details. After integration, the commit message for the final commit will be:
You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed. At the time when this comment was updated there had been 16 new commits pushed to the
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details. ➡️ To integrate this PR with the above commit message to the |
/integrate |
Going to push as commit ca29cc6.
Your commit was automatically rebased without conflicts. |
When recalculating sizes, we often don't want the current index and/or offset to change.
Allow to fix the index/offset when doing recalculations.
Fix JDK-8298728
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jfx pull/974/head:pull/974
$ git checkout pull/974
Update a local copy of the PR:
$ git checkout pull/974
$ git pull https://git.openjdk.org/jfx pull/974/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 974
View PR using the GUI difftool:
$ git pr show -t 974
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jfx/pull/974.diff