[webkit-dev] Question about TextBreakIterator usage in RenderText

David.Leong at nokia.com David.Leong at nokia.com
Mon Jun 7 14:18:29 PDT 2010


I have a question about how the RenderText class handles the usage of TextBreakIterators in RenderText::previousOffset() and RenderText::nextOffset(). Currently I am facing a problem where we have a single div with 20,000 characters in the div. When the user clicks on the text, the mouse down event goes into the render text code to find the position for a point. [RenderText::positionForPoint)] This initializes the PositionIterator to iterate through the text .

The problem I am seeing is this entire flow is stateless, every call to RenderText::previousOffset() and RenderText::nextOffset() creates a new textBreakIterator but with the same data. In the QtWebkit port it is using HarfBuzz where on initialization the TextBreakIterator parses the text entirely and causes performance issues because of the repeated calculations on the same text.

Obviously the other ports are using ICU or other algorithms and may not see this problem. I tried the same page on Safari and it seems to be ok.

My question is can we optimize this flow somehow? Can we re-use the TextBreakIterator in the render text class when performing the RenderText::positionForPoint() function?

I'm new to webkit so please correct me if there are any errors :) Any advice would be greatly appreciated.

Thank you in advanced,

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-dev/attachments/20100607/dc84caf6/attachment.html>

More information about the webkit-dev mailing list