I'm reorganizing init and constraint expressions to come in the same list as initial values (so that inheritance works correctly, see LPP-631, LPP-2894). Hence, there is no more $refs to decide if you have a constraint. If you have a constraint, the "value" of an attribute will be an LzConstraintExpr. This is tested for in LzView.applyArgs: LzInitExpr and LzConstraintExpr values are plucked out of the attrs list (after inheritance is computed) and installed when __LZresolveRefs used to happen).

So, there being no more $refs, I am trying to figure out what this code is trying to do:

    // To compute our width:
    // + if text is multiline:
    //    if no width is supplied, use parent width
    // + if text is single line:
// if no width was supplied and there's no constraint, measure the text width:
    //        if empty text content was supplied, use DEFAULT_WIDTH


    //(args.width == null && typeof(args.$refs.width) != "function")

    if (args.width == null) {
        // if there's text content, measure it's width
        if (this.text != null && this.text.length > 0) {
            args.width = this.getTextWidth();
        } else {
// Empty string would result in a zero width view, which confuses
            // developers, so use something reasonable instead.
            args.width = this.DEFAULT_WIDTH;
        }
    }
    // To compute our height:
    // + If height is supplied, use it.
    // + if no height supplied:
    //    if  single line, use font line height
    //    else get height from flash textobject.textHeight
    //
if (args.height == null && typeof(args.$refs.height) != "function") {

In the new regime, if there is a constraint on width or height, then in construct args.width/height will not be null, it will be an LzConstraintExpr. I don't understand why the test for a constraint has been commented out for width, but not for height. The code does not correspond to the comment for either width or height. If the intent is to ignore constraints on width, I will rewrite the test:

    if (args.width == null || args.width instanceof LzConstraintExpr)

and for the height case, where the intent seems to be to _not_ ignore constraints, it will be sufficient to say:

    if (args.height == null)

(In fact the null test should probably be an `in` test.)

Any background you could supply on the logic here and whether the code or the comments should be believed would be helpful.

Reply via email to