Skip to main content
September 28, 2009
Question

Bugs in FlowComposerBase

  • September 28, 2009
  • 1 reply
  • 585 views

I've run across what appear to be a few bugs in FlowComposerBase.

First of all, the findLineAtPosition method has a preferPrevious:Boolean=false optional parameter.  That parameter is not passed to the findLineIndexAtPosition call used within the findLineAtPosition method to look up the line index.  Is this a simple oversight?

Secondly, in the findLineIndexAtPosition method, if we cannot locate appropriate TextFlowLine object for the requested absolutePosition, we return '_lines.length'.  That will never be a valid line index.  Because of this condition, passing textFlow.textLength to either findLine or findLineIndex will always result in a runtime exception, as far as I can tell.  Should it be returning '_lines.length - 1' instead, or is there more to this than I'm realizing?

We are reproducing the exception by pasting 10 characters of text into an empty text flow and then immediately hitting the END key.  Exception is thrown in NavigationUtil.endOfLine() method.

Any thoughts?

Thanks,

Brent Arndorfer

This topic has been closed for replies.

1 reply

Adobe Employee
September 28, 2009

findLineAtPosition issue is a bug I'll fix that - thanks for the report.

Second issue: you pass a position off the end - TLF returns a line index off the end.  It's implementing the documented behavior.  The parameter is a position so a textFlow with textLength 2 has positions 0 and 1.  Send in textFlow.textLength-1 to get the last line - note that when there is overflow text this may be a large TextFlowLine with no actual TextLine.  Or even just get textFlow.flowComposer.getLineAt(textFlow.flowComposer.numLines-1) for the last line.

Thanks,

Richard

September 28, 2009

When I first started looking into this I ran into the aforementioned behavior of the composer, which I understand now to be the correct behavior.  Upon further investigation, the issue we're running into is this:

1) User pastes some text, say 10 characters long, into empty TextFlow and then immediately presses the END key.

2) That eventually results in a call to NavigationUtil.endOfLine() method.  The TextRange that gets passed in there has absoluteEnd == textFlow.textLegth.

3) In NavigationUtil.endOfLine(), that results in the endIdx var being equal to textFlow.textLength, which is in turn passed to tf.findLeaf().

4) In findLeaf() method of FlowGroupElement, it receieves a relativePosition equal to tf.textLength, which always results in the local childIdx var being equal to -1 and therefore null is returned.

5) On the next line back in NavigationUtil.endOfLine(), we call leaf.getPara.. which causes the null pointer exception.

I noticed that checkCompose gets called immediately before we attempt to find the leaf elem, so that should eliminate any issue with composition being out of date.  I've double checked that we're composed OK, etc.  Just curious if you have any further thoughts.

Thanks,

Brent

September 28, 2009

I should probably add that we have special paste handling behavior and in this case the 'text' that we're pasting is actually inserting a link element.  I can't reproduce this when pasting plain text.  I'd say it's likely something related to the LinkElement textLength evaluation or something else that's occurring during our paste operation.

Brent