On Mon, 15 Jul 2024 12:10:27 GMT, John Hendrikx <[email protected]> wrote:
>> This change removes the origin determination from `resolveLookups`.
>> Instead, the origin from the style is used.
>>
>> Although a comment in the code alluded that this may cause problem with
>> `INLINE` styles, this is not the case. Whenever a `Node` is associated with
>> a `CssStyleHelper`, a suitable shared cache is determined for its use. This
>> already takes into account the presence of an inline style, and only nodes
>> with the same inline style can share such a cache. See `Cache#getStyleMap`
>> and specifically this fragment where an additional selector is added for the
>> inline style:
>>
>> if (hasInlineStyle) {
>> Selector selector =
>> cacheContainer.getInlineStyleSelector(inlineStyle);
>> if (selector != null) selectors.add(selector);
>> }
>
> John Hendrikx has updated the pull request incrementally with one additional
> commit since the last revision:
>
> Add test case
As a side note, there is a bug in the loop detection code in `resolveLookups`.
A `Set` is used to track what `ParsedValue`s have been visited before, but in a
few places this set is cleared. If this happens in a recursive call, and the
caller has to do another lookup replacement, it has lost what `ParsedValue`s it
visited before.
I'll file another issue for that as I already have a test case that results in
a `StackOverflowError`:
@Test
public void infiniteLoop() throws IOException {
Stylesheet stylesheet = new CssParser().parse("userAgentStylSheet", """
.root {
-fx-base-fill: ladder(-fx-base, white 49%, black 50%);
-fx-base: ladder(-fx-base-fill, white 49%, black 50%);
}
.pane {
-fx-background-color: -fx-base;
}
""");
StyleManager.getInstance().setDefaultUserAgentStylesheet(stylesheet);
Pane a = new Pane();
a.getStyleClass().add("pane");
root.getChildren().addAll(a);
stage.show();
Toolkit.getToolkit().firePulse();
}
-------------
PR Comment: https://git.openjdk.org/jfx/pull/1503#issuecomment-2228444299