8388304: Scene.setNodeOrientation triggers instant CSS but also doesn't update properly. - #2213
Conversation
Replace applyCss() with reapplyCSS() in the nodeOrientation invalidation: applyCss() reapplied styles eagerly without rebuilding style maps, leaving :dir() matches stale. reapplyCSS() re-matches and defers to the next pulse.
|
👋 Welcome back fkirmaier! A progress list of the required criteria for merging this PR into |
|
❗ This change is not yet ready to be integrated. |
|
This seems like a relatively safe fix on the surface, but we will not have time to adequately review it before the |
|
I could imagine, that some parts of the code-base rely on the forced CSS computation. |
Maran23
left a comment
There was a problem hiding this comment.
Fix looks good to me and makes sense. This is in-line with other operations.
applyCss is usually only ever called for newly added children so that they are computed correctly immediately.
Although this is very fragile, as there is also:
jfx/modules/javafx.graphics/src/main/java/javafx/scene/Node.java
Lines 9961 to 9974 in 1718958
Which sometimes seems to not work correctly, probably because of nested parent.
Me and John were wondered about this at one point as well. But that is another story altogether.
So the nodeOrientation really is the odd one here. I don't see a reason we should call applyCss instead of the reapplyCSS.
|
|
||
| @Disabled("JDK-8234152") | ||
| @Test | ||
| public void test_CompounSelector_dir_pseudoClass_on_child_with_scene_effective_orientation_ltr() { |
There was a problem hiding this comment.
While here, can we fix the typo in test_Compoun -> test_Compound here and some other tests aswell
There was a problem hiding this comment.
Fixed the 2 Compun - couldn't find another spelling error.
| } | ||
|
|
||
| @Test | ||
| public void testCssUpdates() { |
There was a problem hiding this comment.
Maybe we should name it similar as what you wrote in your description - maybe testChangeNodeOrientationWillReapplyCss or testChangeNodeOrientationWillBatchReapplyCss
There was a problem hiding this comment.
It's now named testChangeNodeOrientationWillReapplyCss.
|
Looks good, tested on several applications and all good. Note that you need to fix the warnings / errors that are mentioned in the PR body. This is unrelated to this PR (so should not block it): I just had a look why the other tests fail. It is always the same reason which I think might not even a bug. When I change: Stylesheet stylesheet = new CssParser().parse(
".root:dir(rtl) .rect { -fx-fill: #ff0000; }" +
".root:dir(ltr) .rect { -fx-fill: #00ff00; }" +
".root .rect { -fx-fill: #0000ff; }"
);to: Stylesheet stylesheet = new CssParser().parse(
".root .rect { -fx-fill: #0000ff; }" +
".root .rect:dir(rtl) { -fx-fill: #ff0000; }" +
".root .rect:dir(ltr) { -fx-fill: #00ff00; }"
);all tests are green. In CSS, the order matters. Although the CSS specification documents that the specifity should be higher with a pseudoclass (so in this case, the order should NOT matter). So JavaFX is not following the CSS specification here, but might be intended (although weird - I would say this is a bug). |
I don't know, specificity is encoded a bit weird (only 4 bits, and doesn't guard overflows) in |
Good catch! Thats an odd check. Together with: this gives us the full picture. Unrelated to this PR, but very weird. |
Fix
The PR replaces applyCss() with reapplyCSS in the nodeOrientation code of Scene.
applyCss() reapplied styles eagerly - and didn't rebuild the "style maps" resulting in wrong css.
reapplyCSS() rematches correctly - and also defers it to the next pulse.
I've added a unit test to: Node_effectiveOrientation_Css_Test.
Test improvements
Because the whole test class was disabled, I've also investigated which tests are working - and reenabled the working tests.
This PR also fixes 2 of the previously failing tests in Node_effectiveOrientation_Css_Test - which are now enabled.
Which are the following tests:
Progress
Error
- [x] I confirm that I make this contribution in accordance with the [OpenJDK Interim AI Policy](https://openjdk.org/legal/ai).Warning
8388304: Scene.setNodeOrientation triggers instant CSS but also doesn't update properly.Issue
Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/jfx.git pull/2213/head:pull/2213$ git checkout pull/2213Update a local copy of the PR:
$ git checkout pull/2213$ git pull https://git.openjdk.org/jfx.git pull/2213/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 2213View PR using the GUI difftool:
$ git pr show -t 2213Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jfx/pull/2213.diff