RESOLVED FIXED Bug 35723
Refactoring: window.btoa() and window.atob() should be implemented on DOMWindow
https://bugs.webkit.org/show_bug.cgi?id=35723
Summary Refactoring: window.btoa() and window.atob() should be implemented on DOMWindow
Hajime Morrita
Reported 2010-03-04 00:05:20 PST
Currently window.btoa() and window.atob() are separetely implemented in both JSC and V8 binding. They should share code as much as possible and the code should be on DOMWindow.
Attachments
patch v0 (12.84 KB, patch)
2010-03-04 01:35 PST, Hajime Morrita
no flags
v1; fix style violations (12.84 KB, patch)
2010-03-04 02:06 PST, Hajime Morrita
no flags
v2; follow the feedback, cleanup a little (12.65 KB, patch)
2010-03-04 18:04 PST, Hajime Morrita
no flags
v3; rename hasMultibyteCharacters to isSafeToConvertCharList (12.65 KB, patch)
2010-03-04 19:58 PST, Hajime Morrita
no flags
Hajime Morrita
Comment 1 2010-03-04 01:35:06 PST
Created attachment 49997 [details] patch v0
WebKit Review Bot
Comment 2 2010-03-04 01:38:13 PST
Attachment 49997 [details] did not pass style-queue: Failed to run "WebKitTools/Scripts/check-webkit-style" exit_code: 1 WebCore/page/DOMWindow.cpp:832: Missing spaces around = [whitespace/operators] [4] WebCore/page/DOMWindow.cpp:832: Missing spaces around < [whitespace/operators] [3] Total errors found: 2 in 7 files If any of these errors are false positives, please file a bug against check-webkit-style.
Hajime Morrita
Comment 3 2010-03-04 02:06:23 PST
Created attachment 49998 [details] v1; fix style violations
Darin Adler
Comment 4 2010-03-04 09:27:07 PST
Comment on attachment 49998 [details] v1; fix style violations > - return jsString(exec, String(out.data(), out.size())); > + return jsString(exec, String(result.characters(), result.length())); This is wrong. It makes an extra copy of the entire string! It should just be jsString(exec, result).
Hajime Morrita
Comment 5 2010-03-04 18:04:22 PST
Created attachment 50075 [details] v2; follow the feedback, cleanup a little
Hajime Morrita
Comment 6 2010-03-04 18:06:23 PST
Thank you for reviewing quickly! (In reply to comment #4) > This is wrong. It makes an extra copy of the entire string! It should just be > jsString(exec, result). Fixed. And removed unnecessary code that last patch has.
Darin Adler
Comment 7 2010-03-04 18:44:25 PST
Comment on attachment 50075 [details] v2; follow the feedback, cleanup a little > +static bool hasMultibyteCharacters(const String& string) > +{ > + for (unsigned i = 0; i < string.length(); i++) { > + if (string[i] > 0xFF) > + return true; > + } > + > + return false; > +} This is not a great name for this function. I don’t really think of U+0040 as a “single byte” character nor do I think of U+0100 as “multi-byte”. Patch otherwise seems OK. r=me
Hajime Morrita
Comment 8 2010-03-04 19:58:59 PST
Created attachment 50083 [details] v3; rename hasMultibyteCharacters to isSafeToConvertCharList
Hajime Morrita
Comment 9 2010-03-04 20:01:40 PST
Thank you for reviewing! > This is not a great name for this function. I don’t really think of U+0040 as a > “single byte” character nor do I think of U+0100 as “multi-byte”. I agree that "multi-byte character" is not right. But I'm not sure if there is some good concept to represent this case. So I chose the name intend to be valid locally in this context.
Darin Adler
Comment 10 2010-03-05 10:03:35 PST
Comment on attachment 50083 [details] v3; rename hasMultibyteCharacters to isSafeToConvertCharList > +static bool isSafeToConvertCharList(const String& string) This is probably better than the old name, but I would have used a name like containsOnlyEightBitCharacters. Sorry I didn't suggest a name last time. r=me either with your name or with my suggested name.
WebKit Commit Bot
Comment 11 2010-03-06 05:03:58 PST
Comment on attachment 50083 [details] v3; rename hasMultibyteCharacters to isSafeToConvertCharList Clearing flags on attachment: 50083 Committed r55619: <http://trac.webkit.org/changeset/55619>
WebKit Commit Bot
Comment 12 2010-03-06 05:04:02 PST
All reviewed patches have been landed. Closing bug.
Note You need to log in before you can comment on or make changes to this bug.