On Mon, 24 Feb 2025 20:54:05 GMT, Andy Goryachev <ango...@openjdk.org> wrote:

>> Yeah, or possibly zero included.  What I meant here is that these are 
>> **real** values, and don't have a "special" value `-1` meaning 
>> absent/unavailable.
>
> A _very quick_ test with the monkey tester showed it never entered 
> `boundedSize()` with zero values, but I can't be sure (I've seen 0's in 
> `layoutChildren()`).
> 
> The statement about "never -1" is even more suspect below when margins are 
> subtracted...
> 
> I just wanted to point this out because I am not entirely sure that we'll 
> never receive 0 width/height.

There are a few guards in the code that prevent these values from becoming 
negative (as some negative values have special meanings).  See for example this 
code: 

    @Override public final double minWidth(double height) {
        final double override = getMinWidth();
        if (override == USE_COMPUTED_SIZE) {
            return super.minWidth(height);
        } else if (override == USE_PREF_SIZE) {
            return prefWidth(height);
        }
        return Double.isNaN(override) || override < 0 ? 0 : override;
    }

This method is `final`, to prevent anyone from messing with this logic.  And as 
you can see, the `override` value (which comes from calling `computeMinWidth` 
for example) is checked against special values, and other values are returned 
instead.  If it is not any special value, it is guarded against negative (it 
becomes 0) and against `NaN`.

Whether that truly guarantees we'll never see negative values, I'm not 100% 
sure off, but I think that's definitely the intent as specific negative values 
have special meanings.  So I think I'll document these as `cannot be negative`.

-------------

PR Review Comment: https://git.openjdk.org/jfx/pull/1723#discussion_r1976024980

Reply via email to