Bug 195346

Summary: [Win] Remove -DUCHAR_TYPE=wchar_t stopgap and learn to live with char16_t.
Product: WebKit Reporter: Ross Kirsling <ross.kirsling>
Component: New BugsAssignee: Ross Kirsling <ross.kirsling>
Status: RESOLVED FIXED    
Severity: Normal CC: achristensen, annulen, bfulgham, commit-queue, darin, don.olmstead, Hironori.Fujii, pvollan, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
See Also: https://bugs.webkit.org/show_bug.cgi?id=181004
Attachments:
Description Flags
Patch
none
Patch
none
Patch
none
Patch
none
Patch
none
Patch
none
Patch
none
Patch none

Ross Kirsling
Reported 2019-03-05 17:19:12 PST
[Win] Remove -DUCHAR_TYPE=wchar_t stopgap and learn to live with char16_t.
Attachments
Patch (123.22 KB, patch)
2019-03-05 17:34 PST, Ross Kirsling
no flags
Patch (123.29 KB, patch)
2019-03-05 18:22 PST, Ross Kirsling
no flags
Patch (110.47 KB, patch)
2019-03-06 14:24 PST, Ross Kirsling
no flags
Patch (110.46 KB, patch)
2019-03-06 16:16 PST, Ross Kirsling
no flags
Patch (110.44 KB, patch)
2019-03-06 16:19 PST, Ross Kirsling
no flags
Patch (110.44 KB, patch)
2019-03-06 16:29 PST, Ross Kirsling
no flags
Patch (108.00 KB, patch)
2019-03-06 20:57 PST, Ross Kirsling
no flags
Patch (108.01 KB, patch)
2019-03-06 21:04 PST, Ross Kirsling
no flags
Ross Kirsling
Comment 1 2019-03-05 17:34:27 PST
Ross Kirsling
Comment 2 2019-03-05 18:22:14 PST
Fujii Hironori
Comment 3 2019-03-05 19:03:55 PST
Comment on attachment 363719 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=363719&action=review > Source/WTF/wtf/text/win/WCharStringExtras.h:40 > +inline wchar_t* ucharAsWCharMutable(UChar* characters) You can overload. const wchar_t* ucharAsWChar(const UChar* characters) wchar_t* ucharAsWChar(UChar* characters) And, I prefer wcharFrom. > Source/WebKitLegacy/win/DOMCSSClasses.cpp:95 > + WTF::String cssTextString = nullTerminatedWCharToString(cssText); WTF::String has platform specific ctors, String(CFStringRef) and String(NSString *). We should have String(BSTR). > Source/WebKitLegacy/win/WebCoreSupport/WebChromeClient.cpp:668 > + String file = nullTerminatedWCharToString(files); Why do need nullTerminatedWCharToString here? WTF::String has a ctor from UChar*. // Construct a string with UTF-16 data, from a null-terminated source. WTF_EXPORT_PRIVATE String(const UChar*); First of all, nullTerminatedWCharToString is needed?
Fujii Hironori
Comment 4 2019-03-05 19:11:04 PST
Comment on attachment 363719 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=363719&action=review >> Source/WebKitLegacy/win/WebCoreSupport/WebChromeClient.cpp:668 >> + String file = nullTerminatedWCharToString(files); > > Why do need nullTerminatedWCharToString here? > WTF::String has a ctor from UChar*. > > // Construct a string with UTF-16 data, from a null-terminated source. > WTF_EXPORT_PRIVATE String(const UChar*); > > First of all, nullTerminatedWCharToString is needed? I understand. Ignore this comment. We need platfrom specific ctor, String(wchat_t*). But we can't have this until AppleWin port update ICU.
Fujii Hironori
Comment 5 2019-03-05 19:14:21 PST
Comment on attachment 363719 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=363719&action=review >> Source/WebKitLegacy/win/DOMCSSClasses.cpp:95 >> + WTF::String cssTextString = nullTerminatedWCharToString(cssText); > > WTF::String has platform specific ctors, String(CFStringRef) and String(NSString *). > We should have String(BSTR). Oh, no. BSTR is just a typedef of wchar_t. We can't do that until AppleWin port updates ICU.
Fujii Hironori
Comment 6 2019-03-05 19:23:19 PST
Comment on attachment 363719 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=363719&action=review >>> Source/WebKitLegacy/win/DOMCSSClasses.cpp:95 >>> + WTF::String cssTextString = nullTerminatedWCharToString(cssText); >> >> WTF::String has platform specific ctors, String(CFStringRef) and String(NSString *). >> We should have String(BSTR). > > Oh, no. BSTR is just a typedef of wchar_t. We can't do that until AppleWin port updates ICU. How about this idea? #if OS(WINDOWS) && U_ICU_VERSION_MAJOR_NUM >= 59 WTF_EXPORT_PRIVATE String(const wchar_t*) #endif
Ross Kirsling
Comment 7 2019-03-05 19:50:31 PST
(In reply to Fujii Hironori from comment #6) > Comment on attachment 363719 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=363719&action=review > > >>> Source/WebKitLegacy/win/DOMCSSClasses.cpp:95 > >>> + WTF::String cssTextString = nullTerminatedWCharToString(cssText); > >> > >> WTF::String has platform specific ctors, String(CFStringRef) and String(NSString *). > >> We should have String(BSTR). > > > > Oh, no. BSTR is just a typedef of wchar_t. We can't do that until AppleWin port updates ICU. > > How about this idea? > > #if OS(WINDOWS) && U_ICU_VERSION_MAJOR_NUM >= 59 > WTF_EXPORT_PRIVATE String(const wchar_t*) > #endif Damn, I did all this without realizing that AppleWin is still behind. That seems like a good plan though.
Ross Kirsling
Comment 8 2019-03-06 14:24:34 PST
Ross Kirsling
Comment 9 2019-03-06 16:16:00 PST
Ross Kirsling
Comment 10 2019-03-06 16:19:47 PST
Ross Kirsling
Comment 11 2019-03-06 16:29:53 PST
Fujii Hironori
Comment 12 2019-03-06 18:13:58 PST
Comment on attachment 363815 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=363815&action=review > Source/WebKitLegacy/win/Plugins/PluginDatabaseWin.cpp:355 > + directories.append(String(macromediaDirectoryStr)); directories.append take a String as a argument. And, you added non-explicit ctor. So, you can omit explicit String ctor call. directories.append(macromediaDirectoryStr); I don't have a strong opinion. > Source/WebKitLegacy/win/WebFrame.cpp:735 > + Frame* foundFrame = coreFrame->tree().find(AtomicString(ucharFrom(name), SysStringLen(name)), *coreFrame); Let's do same for AtomicString. Then, you can remove these patch hunks.
Ross Kirsling
Comment 13 2019-03-06 18:19:23 PST
(In reply to Fujii Hironori from comment #12) > Comment on attachment 363815 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=363815&action=review > > > Source/WebKitLegacy/win/Plugins/PluginDatabaseWin.cpp:355 > > + directories.append(String(macromediaDirectoryStr)); > > directories.append take a String as a argument. And, you added non-explicit > ctor. So, you can omit explicit String ctor call. > directories.append(macromediaDirectoryStr); > I don't have a strong opinion. Sure, I can prune as many of these as possible. > > Source/WebKitLegacy/win/WebFrame.cpp:735 > > + Frame* foundFrame = coreFrame->tree().find(AtomicString(ucharFrom(name), SysStringLen(name)), *coreFrame); > > Let's do same for AtomicString. Then, you can remove these patch hunks. Will do -- looks like there are CFStringRef/NSString ctors for AtomicString after all.
Fujii Hironori
Comment 14 2019-03-06 18:21:42 PST
This is just my idea. There are a lot of conversion code from WTF::String to wchar_t*. > wcharFrom(title.charactersWithNullTermination().data()) Looks very long. This can be simplified if we have, for example WinString class. > WinString(title) class WinString { WinString(const String&); operator wchar_t*() const; }; WebCore already has WebCore::BString class. But, it is using SysAllocString. I think WinString should use fastMalloc.
Ross Kirsling
Comment 15 2019-03-06 19:12:25 PST
(In reply to Fujii Hironori from comment #14) > There are a lot of conversion code from WTF::String to wchar_t*. > > > wcharFrom(title.charactersWithNullTermination().data()) > > Looks very long. I agree -- I've removed stringToNullTerminatedWChar here (because it's a copy-paste of charactersWithNullTermination with a return type of Vector<wchar_t> and I thought it would be bad to have the definitions get out of sync) but we still kind of need a replacement. Since we're already adding String(const wchar_t*), I think it could be reasonable to add a Vector<wchar_t> method too, e.g.: > WTF_EXPORT_PRIVATE Vector<wchar_t> wideCharacters() const;
Fujii Hironori
Comment 16 2019-03-06 19:50:33 PST
(In reply to Ross Kirsling from comment #15) > Since we're already adding String(const wchar_t*), I think it could be > reasonable to add a Vector<wchar_t> method too, e.g.: > > WTF_EXPORT_PRIVATE Vector<wchar_t> wideCharacters() const; Sounds good to me.
Ross Kirsling
Comment 17 2019-03-06 20:57:52 PST
Ross Kirsling
Comment 18 2019-03-06 21:04:50 PST
WebKit Commit Bot
Comment 19 2019-03-06 23:32:03 PST
Comment on attachment 363843 [details] Patch Clearing flags on attachment: 363843 Committed r242592: <https://trac.webkit.org/changeset/242592>
WebKit Commit Bot
Comment 20 2019-03-06 23:32:05 PST
All reviewed patches have been landed. Closing bug.
Radar WebKit Bug Importer
Comment 21 2019-03-06 23:34:03 PST
Fujii Hironori
Comment 22 2019-03-07 20:41:01 PST
Darin Adler
Comment 23 2019-03-10 12:42:55 PDT
I’m thinking we might want to move from UChar to char16_t across all of WebKit at some point.
Note You need to log in before you can comment on or make changes to this bug.