Skip to content
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

8218745: TableView: visual glitch at borders on horizontal scrolling #1330

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Maran23
Copy link
Member

@Maran23 Maran23 commented Jan 10, 2024

This PR fixes the border glitch/gap as explained in both linked tickets.

I noted that the ScrollPane control does not suffer from this problem, although the code is mostly the same as in VirtualFlow. The ScrollPane snaps the content correctly, no matter which scale. I carefully checked the code and it seems that the container structure in ScrollPane was explicitly written to handle this perfectly. There was definitely some thought on that.

So to finally fix this issue, I rewrote the VirtualFlow container/scrolling code to be exactly the same as in ScrollPane(Skin).
And this also fixes the issue, while behaving the same as before.

In the future it may makes sense to try to somewhat unify the code from ScrollPane and VirtualFlow. I already have some ideas.

Unfortunately though, one more container is introduced to VirtualFlow, so the css needs to be changed since it is very strictly written in the first place:
Before: .list-view:focused > .virtual-flow > .clipped-container > .sheet > .list-cell
After: .list-view:focused > .virtual-flow > .viewport > .clipped-container > .sheet > .list-cell

To better understand this, the container structure (tree) is shown below:

  • ScrollPane
    • viewRect -> setClip -> clipRect (viewContent size)
      • viewContent -> setLayoutX
        • Content
    • vsb
    • hsb
    • corner

  • VirtualFlow
    • viewRect (->NEW IN THIS PR<-) -> setClip -> clipRect (clippedContainer size)
      • clippedContainer/clipView -> setLayoutX (when scrolling)
        • sheet
          • Cell
    • vsb
    • hsb
    • corner

/issue add JDK-8146406


Progress

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change requires a CSR request matching fixVersion jfx23 to be approved (needs to be created)
  • Change must be properly reviewed (2 reviews required, with at least 1 Reviewer, 1 Author)

Issues

  • JDK-8218745: TableView: visual glitch at borders on horizontal scrolling (Bug - P4)
  • JDK-8146406: Unexplainable gap between TableCell inside a TableView (Bug - P4)

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jfx.git pull/1330/head:pull/1330
$ git checkout pull/1330

Update a local copy of the PR:
$ git checkout pull/1330
$ git pull https://git.openjdk.org/jfx.git pull/1330/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 1330

View PR using the GUI difftool:
$ git pr show -t 1330

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jfx/pull/1330.diff

Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Jan 10, 2024

👋 Welcome back mhanl! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk openjdk bot added the rfr Ready for review label Jan 10, 2024
@openjdk
Copy link

openjdk bot commented Jan 10, 2024

@Maran23
Adding additional issue to issue list: 8146406: Unexplainable gap between TableCell inside a TableView.

@mlbridge
Copy link

mlbridge bot commented Jan 10, 2024

Webrevs

@kevinrushforth
Copy link
Member

This will need careful review and testing.

/reviewers 2

@openjdk
Copy link

openjdk bot commented Jan 10, 2024

@kevinrushforth
The total number of required reviews for this PR (including the jcheck configuration and the last /reviewers command) is now set to 2 (with at least 1 Reviewer, 1 Author).

@kevinrushforth
Copy link
Member

@johanvos : I presume you will want to review this?

@@ -1505,32 +1505,32 @@
-fx-background-color: derive(-fx-control-inner-background,-5%);
}

.list-view:focused > .virtual-flow > .clipped-container > .sheet > .list-cell:focused {
.list-view:focused > .virtual-flow > .viewport > .clipped-container > .sheet > .list-cell:focused {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might require a CSR as it might break custom stylesheets that modify list/tree/table/views.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably. Was not sure since this is a very specific case which we never had before (as far as I can tell).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I think a CSR would be in order. Thanks for bringing this up @andy-goryachev-oracle

@andy-goryachev-oracle
Copy link
Contributor

The scrolling works correctly with the fix (tested TableView on macOS (scale=1 and 2) and win11 (scale=200%, 225%). I'll continue testing tomorrow.

It might be a dumb question: would it be possible to avoid creating an intermediate container and keep the existing .css files?

@Maran23
Copy link
Member Author

Maran23 commented Jan 11, 2024

It might be a dumb question: would it be possible to avoid creating an intermediate container and keep the existing .css files?

Not a dumb question, that is what I tried at first. See also my old PR: #630. I tried multiple things with the container and snapping, but never managed to fix all the issues with all scales.
So I didn't found a way to fix this issue other than having the same container structure as ScrollPane, which works very well and looks like it was structured like that on purpose.
And ScrollPane works with whatever you put into it -> reliable, so I think it is not a bad thing (other than the css changed 😐)

Copy link
Contributor

@andy-goryachev-oracle andy-goryachev-oracle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good, tested list/tree/table views on macOS 14.1.2 in light mode

@kevinrushforth
Copy link
Member

/csr needed

@openjdk openjdk bot added the csr Need approved CSR to integrate pull request label Jan 12, 2024
@openjdk
Copy link

openjdk bot commented Jan 12, 2024

@kevinrushforth has indicated that a compatibility and specification (CSR) request is needed for this pull request.

@Maran23 please create a CSR request, with the correct fix version, for at least one of the issues associated with this pull request. This pull request cannot be integrated until all the CSR request are approved.

@bridgekeeper
Copy link

bridgekeeper bot commented Feb 9, 2024

@Maran23 This pull request has been inactive for more than 4 weeks and will be automatically closed if another 4 weeks passes without any activity. To avoid this, simply add a new comment to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration!

@bridgekeeper
Copy link

bridgekeeper bot commented Mar 8, 2024

@Maran23 This pull request has been inactive for more than 8 weeks and will now be automatically closed. If you would like to continue working on this pull request in the future, feel free to reopen it! This can be done using the /open pull request command.

@bridgekeeper bridgekeeper bot closed this Mar 8, 2024
@Maran23
Copy link
Member Author

Maran23 commented Mar 8, 2024

/open

@openjdk openjdk bot reopened this Mar 8, 2024
@openjdk
Copy link

openjdk bot commented Mar 8, 2024

@Maran23 This pull request is now open

@Maran23
Copy link
Member Author

Maran23 commented Mar 9, 2024

Note that I found out something interesting which can MAY help us here to solve the problem in another way.

What I found out:
If I set the the opacity of the clip rect to something under 1, this bug disappears.
image

So something in the low level clip rendering is different when an opacity is set. Will investigate if there could be another solution.

@Maran23
Copy link
Member Author

Maran23 commented Mar 10, 2024

Ok, so I found out the following:
When a Rectangle is used as clip without any effect or opacity modification, the rendering goes another (probably faster) route with rendering the clip. That's why setting the opacity to 0.99 fixes the issue - another route will be used for the rendering.
This happens at the low level (NGNode) side of JavaFX.

See here NGNode:
image
renderRectClip seems to be doing something wrong.

I see that the clip rect is floored there, which seems to be the cause. Rounding it is fixing this for me.
The bug always appears when I scroll and the clip RectBounds are something like:
RectBounds { minX:6.999996, minY:37.0, maxX:289.00003, maxY:194.0} (w:282.00003, h:157.0)

while this does not happen when the value is something like:
RectBounds { minX:7.000004, minY:37.0, maxX:289.0, maxY:194.0} (w:282.0, h:157.0)

Note that the minX is floored down, that explains the 1px gap.
I could track it down to be a typical floating point problem:
image
In AffineBase, line 860. He is calculating: 79,2 * 1,25 (render scale). Should the value be snapped here as well somehow?
Another idea is to use doubles instead of float. We lose information when we convert our JavaFX layout double values to float. A quick test showed that this seems to fix the floating point errors.

Another thing I noticed is that the rect calculation seems to be ... weird in renderRectClip.

And now I fully understand why this only happens for the VirtualFlow:
This is the only container and location where the clip is layouted as well! (setLayoutX/setLayoutY).
In ScrollPaneSkin, there was the decision, that the clip is set and the content is layouted only, not the clip.

It may still make sense to me to actually improve the VirtualFlow here - it seems like a good choice to just set the clip and never touch it again and only change the underlying content layout, might be even a bit faster.

But there is obviously a bug on the low level NGNode side as well. Not sure where to go from here.

@openjdk
Copy link

openjdk bot commented Mar 13, 2024

❗ This change is not yet ready to be integrated.
See the Progress checklist in the description for automated requirements.

@openjdk openjdk bot changed the title JDK-8218745: TableView: visual glitch at borders on horizontal scrolling 8218745: TableView: visual glitch at borders on horizontal scrolling Apr 10, 2024
@bridgekeeper
Copy link

bridgekeeper bot commented Apr 10, 2024

@Maran23 This pull request has been inactive for more than 4 weeks and will be automatically closed if another 4 weeks passes without any activity. To avoid this, simply add a new comment to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration!

@Maran23
Copy link
Member Author

Maran23 commented Apr 10, 2024

open for discussion still, but there will be a counter PR from me at one point.

@andy-goryachev-oracle
Copy link
Contributor

andy-goryachev-oracle commented Apr 10, 2024

But there is obviously a bug on the low level NGNode side as well. Not sure where to go from here.

does it mean this PR is not ready, or do we have other issue(s)?

Also, a CSR is needed for this PR to go forward.

@openjdk
Copy link

openjdk bot commented Apr 10, 2024

@Maran23 this pull request can not be integrated into master due to one or more merge conflicts. To resolve these merge conflicts and update this pull request you can run the following commands in the local repository for your personal fork:

git checkout 8218745-snapping-x-y-tableview-scroll-3
git fetch https://git.openjdk.org/jfx.git master
git merge FETCH_HEAD
# resolve conflicts and follow the instructions given by git merge
git commit -m "Merge master"
git push

@openjdk openjdk bot added the merge-conflict Pull request has merge conflict with target branch label Apr 10, 2024
@bridgekeeper
Copy link

bridgekeeper bot commented May 9, 2024

@Maran23 This pull request has been inactive for more than 4 weeks and will be automatically closed if another 4 weeks passes without any activity. To avoid this, simply add a new comment to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration!

…snapping-x-y-tableview-scroll-3

# Conflicts:
#	modules/javafx.controls/src/test/java/test/javafx/scene/control/TableViewTest.java
#	modules/javafx.controls/src/test/java/test/javafx/scene/control/TreeTableViewTest.java
@openjdk openjdk bot removed the merge-conflict Pull request has merge conflict with target branch label May 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
csr Need approved CSR to integrate pull request rfr Ready for review
3 participants