[webkit-dev] Question about TextBreakIterator usage in RenderText

David.Leong at nokia.com David.Leong at nokia.com
Mon Jun 7 18:52:27 PDT 2010


Hi,

Thank you very much for your suggestions Dave!

I already tried to setup a cache in the QtTextBreakIterator implementation, but there was concern that caching the pointer and length may cause random crashes if somehow the address is reused. My alternative idea is to calculate a hash when we request the QtTextBreakIterator to uniquely identify the string so we can reuse the break iterator. The second idea works and I've proposed a patch in the bug that I logged.

This afternoon I've been trying to move the cache idea up to the RenderText class as a member when the text iterator is requested. Unfortunately this does not very well because HTMLEditing calculates the text position when handling the mouse down event. The memory overhead of keeping a TextBreakIterator instance in RenderText seems to be quite expensive. I also attempted making the text iterator a static cross-platform object. In order to reuse the TextBreakIterator there is no good way to check whether the iterator is setup with the correct text and state.

This change may speed up other ports as well, it seems like all ports are re-creating the platform specific TextBreakIterator  whenever it is requested.

Here is the bug that I logged, any comments would be appreciated.
https://bugs.webkit.org/show_bug.cgi?id=39958

Thanks again!
David

From: ext David Hyatt [mailto:hyatt at apple.com]
Sent: Monday, June 07, 2010 2:45 PM
To: Leong David (Nokia-S/Vancouver)
Cc: webkit-dev at lists.webkit.org
Subject: Re: [webkit-dev] Question about TextBreakIterator usage in RenderText

On Jun 7, 2010, at 4:18 PM, David.Leong at nokia.com<mailto:David.Leong at nokia.com> wrote:


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?


That's what the ICU implementation does.  I think you just need to fix your implementation to do the same.  If you want to push the re-use higher you could probably make cursorMovementIterator cross-platform and then have it contain the static pointer to the reused iterator.  Then the existing cursorMovementIterator could be renamed and be called by the new cross-platform function.   However you could also just fix your implementation of cursorMovementIterator to reuse the iterator.

static bool createdCursorMovementIterator = false;
static TextBreakIterator* staticCursorMovementIterator;
return setUpIteratorWithRules(createdCursorMovementIterator, staticCursorMovementIterator, kRules, string, length);

dave
(hyatt at apple.com<mailto:hyatt at apple.com>)


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


More information about the webkit-dev mailing list