RESOLVED FIXED 52781
Inserting multiple whitespace using text composition (IME) should insert interleaved nbsp and whitespace.
https://bugs.webkit.org/show_bug.cgi?id=52781
Summary Inserting multiple whitespace using text composition (IME) should insert inte...
Hajime Morrita
Reported 2011-01-19 21:20:29 PST
Attachments
fixes the bug (9.44 KB, patch)
2011-01-24 11:47 PST, Ryosuke Niwa
no flags
fixed typos & comment per ojan's comment (9.55 KB, patch)
2011-01-24 18:28 PST, Ryosuke Niwa
no flags
fixed one more typo (9.55 KB, patch)
2011-01-24 18:42 PST, Ryosuke Niwa
ojan: review+
Ryosuke Niwa
Comment 1 2011-01-24 11:47:47 PST
Created attachment 79951 [details] fixes the bug
Ojan Vafai
Comment 2 2011-01-24 16:54:42 PST
Comment on attachment 79951 [details] fixes the bug View in context: https://bugs.webkit.org/attachment.cgi?id=79951&action=review > Source/WebCore/editing/htmlediting.cpp:359 > + Vector<UChar> rebalanacedString; s/rebalanacedString/rebalancedString Also, why use a Vector<UChar> instead of String like the old code did? > Source/WebCore/editing/htmlediting.h:239 > // Miscellaneous functions on String > - > +inline bool isWhitespace(UChar c) > +{ > + return c == noBreakSpace || c == ' ' || c == '\n' || c == '\t'; > +} Nit: technically, this is not a function on String, os the comment is not correct.
Ojan Vafai
Comment 3 2011-01-24 16:55:02 PST
Comment on attachment 79951 [details] fixes the bug Whoops, meant to r-.
Ryosuke Niwa
Comment 4 2011-01-24 17:24:21 PST
Comment on attachment 79951 [details] fixes the bug View in context: https://bugs.webkit.org/attachment.cgi?id=79951&action=review >> Source/WebCore/editing/htmlediting.cpp:359 >> + Vector<UChar> rebalanacedString; > > s/rebalanacedString/rebalancedString > > Also, why use a Vector<UChar> instead of String like the old code did? As far I checked, we can't modify each character in String directly (because multiple String instances may share single StringImpl). i.e. String only has UChar operator[](unsigned index) const. >> Source/WebCore/editing/htmlediting.h:239 >> +} > > Nit: technically, this is not a function on String, os the comment is not correct. Maybe I should change the comment to "Miscellaneous functions on Text"?
Ryosuke Niwa
Comment 5 2011-01-24 18:28:37 PST
Created attachment 80006 [details] fixed typos & comment per ojan's comment
WebKit Review Bot
Comment 6 2011-01-24 18:33:23 PST
WebKit Review Bot
Comment 7 2011-01-24 18:33:55 PST
Ryosuke Niwa
Comment 8 2011-01-24 18:42:52 PST
Created attachment 80007 [details] fixed one more typo
Early Warning System Bot
Comment 9 2011-01-24 18:45:36 PST
Build Bot
Comment 10 2011-01-24 18:51:15 PST
Ojan Vafai
Comment 11 2011-01-24 18:59:26 PST
Comment on attachment 79951 [details] fixes the bug View in context: https://bugs.webkit.org/attachment.cgi?id=79951&action=review >>> Source/WebCore/editing/htmlediting.cpp:359 >>> + Vector<UChar> rebalanacedString; >> >> s/rebalanacedString/rebalancedString >> >> Also, why use a Vector<UChar> instead of String like the old code did? > > As far I checked, we can't modify each character in String directly (because multiple String instances may share single StringImpl). i.e. String only has UChar operator[](unsigned index) const. I don't understand. Isn't that what the old code was doing with the "replace" calls?
Ojan Vafai
Comment 12 2011-01-24 19:02:24 PST
Comment on attachment 80007 [details] fixed one more typo Ryosuke informed me that replace copies the string. So the new code is certainly more efficient.
Ryosuke Niwa
Comment 13 2011-01-24 19:09:28 PST
(In reply to comment #12) > (From update of attachment 80007 [details]) > Ryosuke informed me that replace copies the string. So the new code is certainly more efficient. Note: new function creates copy regardless of whether there are whitespace or not while the old implementation doesn't make a copy when there are no whitespace. However, in practice, almost all text contains whitespace so this shouldn't be a problem. We can add that optimization later if we're so inclined.
Ryosuke Niwa
Comment 14 2011-01-24 19:27:30 PST
Note You need to log in before you can comment on or make changes to this bug.