<HTML><BODY style="word-wrap: break-word; -khtml-nbsp-mode: space; -khtml-line-break: after-white-space; "><DIV class="AppleOriginalContents">In one very important respect, <SPAN style="font: 12.0px Helvetica"><SPAN style="font-family: Lucida Grande;" class="khtml-style-span">DOM::Selection is robust against its boundary nodes being removed from the DOM tree. The Selection class holds its boundary nodes in DOM::Position members, and the Position class holds a reference to its node. Consequently, there is no danger of a node being deleted if it is a boundary node of a selection and the node is removed from the document. You might well generate exceptions if you use such a "dangling" boundary point in a DOM function, but that is a much different problem than dereferencing a pointer to a freed object.<BR><BR></SPAN></SPAN>In one other important way, <SPAN style="font: 12.0px Helvetica"><SPAN style="font-family: Lucida Grande;" class="khtml-style-span">DOM::Selection is not robust against changes to the document, at least not in the way that DOM Ranges behave. I have always thought that it might be good to update Selection objects as the DOM is changed, but, as it has not yet presented problems as big as the ones I have been working on, I have never gotten around to doing the work. Yet, there are some foundation concepts in the Selection class for implementing this second kind of robustness. Take a look at the VisiblePosition class and Selection::validate. <BR><BR></SPAN></SPAN>As for sending patches, I must be honest with you and say that I am severely pressed for time, and I will have very little opportunity to discuss or debate changes on this list. That said, I see no problem with sending the patches. Today, I will see about putting together a patch to bring you up to date.<BR><BR>- Ken<BR><BR><BR>On Nov 26, 2004, at 9:15 AM, Leo Savernik wrote:<BR><BR><SPAN class="Apple-extra-linebreak"><BR></SPAN><BLOCKQUOTE type="cite"><SPAN style="font: 12.0px Helvetica">Hello,</SPAN><BR><SPAN style="font: 12.0px Helvetica"></SPAN><BR><SPAN style="font: 12.0px Helvetica">In WebCore 146.1, all the old selection-specific stuff has been replaced to<SPAN class="Apple-converted-space"> </SPAN></SPAN><BR><SPAN style="font: 12.0px Helvetica">make use of DOM::Selection.</SPAN><BR><SPAN style="font: 12.0px Helvetica"></SPAN><BR><SPAN style="font: 12.0px Helvetica">The problem I see with this implementation is that DOM::Selection isn't robust<SPAN class="Apple-converted-space"> </SPAN></SPAN><BR><SPAN style="font: 12.0px Helvetica">against changes to the dom tree. As the principal selection stays active<SPAN class="Apple-converted-space"> </SPAN></SPAN><BR><SPAN style="font: 12.0px Helvetica">between events, the boundary nodes may have been deleted meanwhile -&gt;<SPAN class="Apple-converted-space"> </SPAN></SPAN><BR><SPAN style="font: 12.0px Helvetica">dangling pointer in Selection -&gt; crash.</SPAN><BR><SPAN style="font: 12.0px Helvetica"></SPAN><BR><SPAN style="font: 12.0px Helvetica">Did you take any countermeasures that protect WebCore from the above scenario<SPAN class="Apple-converted-space"> </SPAN></SPAN><BR><SPAN style="font: 12.0px Helvetica">or are you planning on any such countermeasures?</SPAN><BR><SPAN style="font: 12.0px Helvetica"></SPAN><BR><SPAN style="font: 12.0px Helvetica">Btw, now that contenteditable has been unveiled for Safari, I ask you to post<SPAN class="Apple-converted-space"> </SPAN></SPAN><BR><SPAN style="font: 12.0px Helvetica">patches against contenteditable/caret/selection stuff to this list. Thank<SPAN class="Apple-converted-space"> </SPAN></SPAN><BR><SPAN style="font: 12.0px Helvetica">you.</SPAN><BR><SPAN style="font: 12.0px Helvetica"></SPAN><BR><SPAN style="font: 12.0px Helvetica">mfg</SPAN><BR><SPAN style="font: 12.0px Helvetica"><SPAN class="Apple-converted-space"> </SPAN>Leo</SPAN><BR><SPAN style="font: 12.0px Helvetica">_______________________________________________</SPAN><BR><SPAN style="font: 12.0px Helvetica">Khtml-devel@kde.org</SPAN><BR><SPAN style="font: 12.0px Helvetica">https://mail.kde.org/mailman/listinfo/khtml-devel</SPAN><BR></BLOCKQUOTE></DIV><BR><BR></BODY></HTML>