-
Notifications
You must be signed in to change notification settings - Fork 561
8186188: TableColumHeader: initial auto-size broken if has graphic #1405
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
Conversation
|
👋 Welcome back mhanl! A progress list of the required criteria for merging this PR into |
|
@Maran23 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 |
Webrevs
|
… the font is now always there
andy-goryachev-oracle
left a comment
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.
the main question is whether this PR depends on #1422, or whether the unrelated changes need to be removed.
| double headerGraphicWidth = graphic == null ? 0 : graphic.prefWidth(-1) + header.label.getGraphicTextGap(); | ||
| double headerWidth = headerTextWidth + headerGraphicWidth + 10 + header.snappedLeftInset() + header.snappedRightInset(); | ||
| header.applyCss(); | ||
| double headerWidth = header.label.prefWidth(-1) + 10; |
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.
should we extract this magic constant (along with the comment)?
although this might be outside of the scope of this PR, lines 651, 744.
| .map(lineTo -> new Point2D( | ||
| xAxis.getValueForDisplay(lineTo.getX()).doubleValue(), | ||
| yAxis.getValueForDisplay(lineTo.getY()).doubleValue()) | ||
| Math.round(xAxis.getValueForDisplay(lineTo.getX()).doubleValue()), |
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.
please revert the unrelated changes (moved to #1422)
| String bounds = computeBoundsString((Region)childrenList.get(0), (Region)childrenList.get(1), | ||
| (Region)childrenList.get(2)); | ||
| assertEquals("10 478 234 37 254 432 234 83 499 375 234 140 ", bounds); | ||
| assertEquals("10 453 218 35 238 409 218 79 465 355 218 133 ", bounds); |
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.
unrelated
| Scene s = new Scene(textInput); | ||
| textInput.applyCss(); | ||
| assertEquals(Font.font("Helvetica", 24), textInput.getFont()); | ||
| assertEquals(Font.font("Amble", 24), textInput.getFont()); |
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.
unrelated
| import javafx.scene.input.MouseEvent; | ||
| import javafx.scene.layout.HBox; | ||
| import javafx.scene.text.Text; | ||
| import org.junit.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.
this is a new test - should we use JUnit5?
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 copied the other test class, but sure, is probably better to switch this to JUnit 5 then.
|
|
||
| private TableColumnHeader firstColumnHeader; | ||
| private TreeTableView<Person> tableView; | ||
| private StageLoader sl; |
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: this field should probably be named stageLoader
| TableColumnHeaderShim.resizeColumnToFitContent(firstColumnHeader, -1); | ||
|
|
||
| assertEquals("Width must be the same", | ||
| width, column.getWidth(), 0.001); |
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.
maybe a constant, here and elsewhere
private static final double EPSILON = 0.001;
?
| if (name.equals("system") || name.equals("system regular")) { | ||
| if (name.equals("system regular")) { | ||
| FontHelper.setNativeFont(font, nativeFont, font.getName(), "System", "Regular"); | ||
| } else if (name.equals("system bold")) { |
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.
does this mean this PR requires #1422 to be integrated first?
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.
Yes, that would be easier for reviewing this. Once merged, I will update this branch. :)
|
/reviewers 2 |
|
@kevinrushforth |
…188-tc-init-size # Conflicts: # modules/javafx.graphics/src/test/java/test/com/sun/javafx/pgstub/StubFontLoader.java
effad
left a comment
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.
As per request I tested the changes of this PR with the Benchmark found at https://gist.github.com/effad/9eebee0c1e86a8e605cb55ced9485dd4
Baseline: JFX 23-internal+0-2024-04-02-130613 average run time: 975
After gh pr checkout 1405: JFX 23-internal+0-2024-04-02-130613 average run time: 1026
So we have a measurable (~5%) but (IMO) neglectable slowdown. Compared to JFX 21.0.2+5 (2460) we are still more than twice as fast.
|
@effad Thank you, much appreciated! Good to see that this does not cause any major performance problems. |
andy-goryachev-oracle
left a comment
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.
Works as expected with the code in the ticket, no issues found with the monkey tester.
Thanks!
|
/integrate |
|
Going to push as commit 44d53ba.
Your commit was automatically rebased without conflicts. |
This PR fixes the issue that the initial column autosizing is wrong under some circumstances.
The following things will break the initial autosizing:
The reason is actually quite simple: The CSS is not (yet) applied initially, we therefore ALWAYS take the default font into account + the graphic is not yet layouted as well.
It was not so easy to write tests for this, also for me thetest_resizeColumnToFitContentHeaderis always failing locally. I don't know what happens here, but he seems to not find a (Stub?)Fontfor me.EDIT: Found out the cause and fixed it. I will check if I can write more tests since it works now. :)
The test I wrote now is checking if the css is applied after we triggered the autosize, which is what we would expect here since we measure text.
I also copied the
TableColumnHeaderTestand rewrote the tests forTreeTableViewas well, so we can catch any errors here as well since they both use different code (although it is technically the same - C&P errors can happen very easy).Progress
Issue
Reviewers
Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/jfx.git pull/1405/head:pull/1405$ git checkout pull/1405Update a local copy of the PR:
$ git checkout pull/1405$ git pull https://git.openjdk.org/jfx.git pull/1405/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 1405View PR using the GUI difftool:
$ git pr show -t 1405Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jfx/pull/1405.diff
Webrev
Link to Webrev Comment