We were seeing some performance issues when editing documents and noticed that it was occurring in documents that had underlined text. The issue was that any text line that contain underlined FlowLeafElements was getting extra Adornment Shapes added when the TextLine was reused during compose.
The code in question begins in BaseCompose.finishComposeLine:
protected function finishComposeLine(curLine:TextFlowLine, lineSlug:Rectangle):void
{
...
curLine.createAdornments(_blockProgression,_curElement,_curElementStart);
}
The issue is that createAdornments does not check if the TextFlowLine already had Adornment shapes (for drawing the underlines) before updating and then adds another "Shape" object. The net effect is that the TextLine in the display list gets redundant Shapes and performance begins to suffer.
private function updateAdornmentsOnBounds(line:TextFlowLine, blockProgression:String, spanBounds:Rectangle):void
{
var tLine:TextLine = line.getTextLine();
var selObj:Shape = new Shape();
...
tLine.addChild(selObj);
}
The problem was easy to reproduce once we better understood what was happening, every time we would see a compose happen for this line (e.g. hitting return above the line in question), more Shapes would be added. When all that was really necessary was to move the TextLine. Our fix was to change the line in 'finishComposeLine' to check if the curTextLine already had children, which implied that it had Adornments, and was being reused.
// Added check to determine if TextLine is being reused. If the TextLine already has children
// it must be a reused line that is just being moved. The children are the adornments used for underlines/strikethrough/etc...
//
if (curTextLine.numChildren == 0)
curLine.createAdornments(_blockProgression,_curElement,_curElementStart);
Let me know if anything else is needed, or if I should go ahead a file a JIRA ticket for this.
Thanks,
Brett