<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">

<head>
<meta http-equiv=Content-Type content="text/html; charset=us-ascii">
<meta name=Generator content="Microsoft Word 12 (filtered medium)">
<base href="x-msg://269/">
<style>
<!--
 /* Font Definitions */
 @font-face
        {font-family:Helvetica;
        panose-1:2 11 6 4 2 2 2 2 2 4;}
@font-face
        {font-family:Helvetica;
        panose-1:2 11 6 4 2 2 2 2 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
        {font-family:Menlo;
        panose-1:0 0 0 0 0 0 0 0 0 0;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.apple-style-span
        {mso-style-name:apple-style-span;}
span.EmailStyle18
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page Section1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.Section1
        {page:Section1;}
-->
</style>
<!--[if gte mso 9]><xml>
 <o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
 <o:shapelayout v:ext="edit">
  <o:idmap v:ext="edit" data="1" />
 </o:shapelayout></xml><![endif]-->
</head>

<body lang=EN-US link=blue vlink=purple style='word-wrap: break-word;
-webkit-nbsp-mode: space;-webkit-line-break: after-white-space'>

<div class=Section1>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>Hi,<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>Thank you very much for your suggestions Dave!<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>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&#8217;ve proposed a patch in the bug that I logged. <o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>This afternoon I&#8217;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. <o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>This change may speed up other ports as well, it seems like all
ports are re-creating the platform specific TextBreakIterator &nbsp;whenever it
is requested.<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>Here is the bug that I logged, any comments would be appreciated.<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><a href="https://bugs.webkit.org/show_bug.cgi?id=39958">https://bugs.webkit.org/show_bug.cgi?id=39958</a><o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>Thanks again!<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>David<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p>&nbsp;</o:p></span></p>

<div>

<div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in'>

<p class=MsoNormal><b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>From:</span></b><span
style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'> ext David Hyatt
[mailto:hyatt@apple.com] <br>
<b>Sent:</b> Monday, June 07, 2010 2:45 PM<br>
<b>To:</b> Leong David (Nokia-S/Vancouver)<br>
<b>Cc:</b> webkit-dev@lists.webkit.org<br>
<b>Subject:</b> Re: [webkit-dev] Question about TextBreakIterator usage in
RenderText<o:p></o:p></span></p>

</div>

</div>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

<div>

<div>

<div>

<p class=MsoNormal>On Jun 7, 2010, at 4:18 PM, <a
href="mailto:David.Leong@nokia.com">David.Leong@nokia.com</a> wrote:<o:p></o:p></p>

</div>

<p class=MsoNormal><br>
<br>
<o:p></o:p></p>

<div>

<div>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Calibri","sans-serif"'>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?<o:p></o:p></span></p>

</div>

<div>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Calibri","sans-serif"'>&nbsp;<o:p></o:p></span></p>

</div>

</div>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

</div>

<div>

<p class=MsoNormal>That's what the ICU implementation does. &nbsp;I think you
just need to fix your implementation to do the same. &nbsp;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. &nbsp;Then
the existing cursorMovementIterator could be renamed and be called by the new
cross-platform function. &nbsp; However you could also just fix your
implementation of cursorMovementIterator to reuse the iterator.<o:p></o:p></p>

</div>

<div>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

</div>

<div>

<div>

<p class=MsoNormal><span style='font-size:8.5pt;font-family:"Menlo","serif";
color:#B731A1'>static</span><span style='font-size:8.5pt;font-family:"Menlo","serif"'>
<span style='color:#B731A1'>bool</span> createdCursorMovementIterator = <span
style='color:#B731A1'>false</span>;<o:p></o:p></span></p>

</div>

<div>

<p class=MsoNormal><span style='font-size:8.5pt;font-family:"Menlo","serif";
color:#B731A1'>static</span><span style='font-size:8.5pt;font-family:"Menlo","serif"'>
TextBreakIterator* staticCursorMovementIterator;<o:p></o:p></span></p>

</div>

<div>

<p class=MsoNormal><span style='font-size:8.5pt;font-family:"Menlo","serif";
color:#B731A1'>return</span><span style='font-size:8.5pt;font-family:"Menlo","serif"'>
<span style='color:#33595D'>setUpIteratorWithRules</span>(createdCursorMovementIterator,
staticCursorMovementIterator, kRules, <span style='color:#6F41A8'>string</span>,
<span style='color:#518187'>length</span>);<o:p></o:p></span></p>

</div>

<div>

<p class=MsoNormal><span style='font-size:8.5pt;font-family:"Menlo","serif"'><o:p>&nbsp;</o:p></span></p>

</div>

</div>

<div>

<p class=MsoNormal>dave<o:p></o:p></p>

</div>

<div>

<p class=MsoNormal>(<a href="mailto:hyatt@apple.com">hyatt@apple.com</a>)<o:p></o:p></p>

</div>

<div>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

</div>

<div>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

</div>

</div>

</div>

</body>

</html>