Need help with newline handling

Harri Porten porten at froglogic.com
Sun Feb 28 14:10:10 GMT 2010


Hello,

I need some advise on how to handle 
https://bugs.kde.org/show_bug.cgi?id=58111 which is about copy&paste 
problems. What happens is that a user who copies HTML like this

==============
<p>coucou<br>
hop<br>
==============

gets the text "coucou<newline><space>hop". The leading space is 
superfluous. I've tracked it down to the following: setText() is called on 
the RenderText object for the "hop" string. It has a leading newline 
character which gets turned into a space by 
DOMString::collapseWhiteSpace()[1]. Since our copy&paste code makes us of 
the text stored in the Render objects it'll put this space into the 
clipboard as well.

I wonder if it's the right thing to convert leading newlines that way. 
Trying a patch that collapses leading newlines completely (attached) but 
got a lot of visible regressions from our test suite.

My question: is the collapsing code in RenderText::setText() the right 
place to fix the issue? Or should I restrict the fix to the 
KHTMLPart::selectedText() function?

Harri.

[1] http://www.w3.org/TR/css3-text/#white-space-processing
-------------- next part --------------
A non-text attachment was scrubbed...
Name: collapse.diff
Type: text/x-diff
Size: 617 bytes
Desc: 
URL: <https://mail.kde.org/mailman/private/kfm-devel/attachments/20100228/93288030/attachment.diff>


More information about the kfm-devel mailing list