RFR: 8263095: Provide a way for a custom control to indicate that its userAgentStyleSheet has changed
Alessadro Parisi
github.com+16880178+palexdev at openjdk.java.net
Tue Jun 1 17:25:36 UTC 2021
This change allows custom control to change their style dynamically
When the user-agent stylesheet changes the property automatically calls `NodeHelper.reapplyCSS(Region.this);` to recompute the CSS for the node and its children.
To make this work the StyleManager class must be fixed too.
The line `regionUserAgentStylesheet = weakRegionUserAgentStylesheetMap.computeIfAbsent((Region)region, Region::getUserAgentStylesheet);
` is problematic because if the region is already present in the map but the user-agent stylesheet changed, the value of `regionUserAgentStylesheet` is not updated and this leads to controls having the wrong style.
To fix this issue I added this check:
if (((Region) region).getUserAgentStylesheet() != null && !((Region) region).getUserAgentStylesheet().equals(regionUserAgentStylesheet)) {
weakRegionUserAgentStylesheetMap.put((Region) region, ((Region) region).getUserAgentStylesheet());
regionUserAgentStylesheet = ((Region) region).getUserAgentStylesheet();
}
-------------
Commit messages:
- Allow dynamic implementation of user-agent stylesheet
Changes: https://git.openjdk.java.net/jfx/pull/525/files
Webrev: https://webrevs.openjdk.java.net/?repo=jfx&pr=525&range=00
Issue: https://bugs.openjdk.java.net/browse/JDK-8263095
Stats: 44 lines in 2 files changed: 24 ins; 17 del; 3 mod
Patch: https://git.openjdk.java.net/jfx/pull/525.diff
Fetch: git fetch https://git.openjdk.java.net/jfx pull/525/head:pull/525
PR: https://git.openjdk.java.net/jfx/pull/525
More information about the openjfx-dev
mailing list