TLF has the following code in SpanElement:

                /** @private */
                override public function createContentElement():void
                {
                        if (_blockElement && _blockElement.textBlock)
                                return;
                        
                        calculateComputedFormat();      // BEFORE creating the 
element
                        _blockElement = new TextElement(_text,null);            
        
                        super.createContentElement();
                }

Which gets compiled to this:

/** @asprivate 
 * @export
 * @override
 */
org.apache.royale.textLayout.elements.SpanElement.prototype.createContentElement
 = function() {
  if (this._blockElement && this._blockElement.textBlock)
    return;
  this.calculateComputedFormat();
  this._blockElement = new com.printui.text.engine.TextElement(this._text, 
null);
  
  
  
org.apache.royale.textLayout.elements.SpanElement.superClass_.createContentElement.apply(this);
};

Minified, that function looks like this:
hK.prototype.sf = function() {
    this.Xa && this.Xa.textBlock || (this.Xa = new iK(this._text,null),
    hK.o.sf.apply(this))
}

Notice that the function call of calculateComputedFormat(); is missing in the 
minified code.

The reason for this is because the function is deemed to not have side effects 
by the Closure compiler.

That function (in FlowElement) looks like this:
                public function get computedFormat():ITextLayoutFormat
                {
                        if (_computedFormat == null)
                                _computedFormat = doComputeTextLayoutFormat();
                        return _computedFormat;
                }

                public function calculateComputedFormat():ITextLayoutFormat
                {
                        // use the class-sppecific getter
                        return computedFormat;
                }
Apparently, the Closure Compiler assumes that getters do not have side effects.

I can work around this problem in TLF, but it seems to me that this is a 
problem which should be fixed in the compiler.

Thoughts?
Harbs

Reply via email to