Bug 211033

Summary: Remove implicit URL->String conversion operators
Product: WebKit Reporter: Alex Christensen <achristensen>
Component: New BugsAssignee: Alex Christensen <achristensen>
Status: RESOLVED FIXED    
Severity: Normal CC: aboxhall, apinheiro, benjamin, berto, cdumez, cfleizach, cgarcia, changseok, cmarcelo, darin, dmazzoni, eric.carlson, esprehn+autocc, ews-watchlist, galpeter, glenn, gustavo, gyuyoung.kim, jcraig, jdiggs, jer.noble, jiewen_tan, philipj, samuel_white, sergio, toyoshim, webkit-bug-importer, yutak
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch
none
Patch
none
Patch
none
Patch
none
Patch
none
Patch
none
Patch none

Alex Christensen
Reported 2020-04-25 16:29:41 PDT
Remove implicit URL->String conversion operators
Attachments
Patch (10.63 KB, patch)
2020-04-25 16:32 PDT, Alex Christensen
no flags
Patch (13.91 KB, patch)
2020-04-25 16:53 PDT, Alex Christensen
no flags
Patch (20.70 KB, patch)
2020-04-25 17:18 PDT, Alex Christensen
no flags
Patch (21.29 KB, patch)
2020-04-25 17:40 PDT, Alex Christensen
no flags
Patch (20.59 KB, patch)
2020-05-20 11:03 PDT, Alex Christensen
no flags
Patch (22.76 KB, patch)
2020-05-20 11:51 PDT, Alex Christensen
no flags
Patch (25.94 KB, patch)
2020-05-20 12:48 PDT, Alex Christensen
no flags
Patch (27.18 KB, patch)
2020-05-20 14:06 PDT, Alex Christensen
no flags
Alex Christensen
Comment 1 2020-04-25 16:32:04 PDT
Alex Christensen
Comment 2 2020-04-25 16:53:32 PDT
EWS Watchlist
Comment 3 2020-04-25 16:54:27 PDT
Thanks for the patch. If this patch contains new public API please make sure it follows the guidelines for new WebKit2 GTK+ API. See http://trac.webkit.org/wiki/WebKitGTK/AddingNewWebKit2API
Alex Christensen
Comment 4 2020-04-25 17:18:17 PDT
Alex Christensen
Comment 5 2020-04-25 17:40:22 PDT
Darin Adler
Comment 6 2020-04-25 17:52:44 PDT
Comment on attachment 397600 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=397600&action=review > Source/WebCore/html/DOMURL.cpp:61 > + return create(url, base.href().string()); This is not good, and easy to fix. Resolving against a base requires a parsed URL; this re-parses for no reason. Why not rearrange the code so that doesn’t happen? Could do it by having another overload of the create function or just write this function out like the one just below it. > Source/WebCore/html/HTMLPlugInElement.cpp:367 > + type = mimeTypeFromDataURL(url.string()); All the callers of the mimeTypeFromDataURL function have a URL. Maybe we should just change it to take const URL& instead of StringView instead of changing all of them. > Source/WebCore/html/URLUtils.h:89 > - if (WTF::protocolIsJavaScript(href())) > + if (href().protocolIsJavaScript()) > return "javascript:"_s; Seems like we don’t need this at all. If URL::protocol properly returns "javascript", then the code below will work. If it doesn’t then it seems likely protocolIsJavaScript will give us false negatives. I think that either this code and should be removed, or it needs to keep using the protocolIsJavaScript function that works on a string. See also my comments about the future in bug 211007. This conflicts with my changes in bug 211025; no big deal, but I would like you to look at that one at some point. > Source/WebCore/html/URLUtils.h:111 > - setHref(url); > + setHref(url.string()); This wouldn’t be needed after my changes in bug 211025; hope you get a chance to check that out. > Source/WebCore/html/URLUtils.h:125 > - setHref(url); > + setHref(url.string()); Ditto. > Source/WebCore/page/Location.cpp:139 > + return setLocation(activeWindow, firstWindow, url.string()); Seems unfortunate to parse, convert to a string, and then reparse. If this is guaranteed to be a complete URL and not a relative URL piece, then we could make a setLocation overload that takes a URL and use it here. > Source/WebCore/page/Location.cpp:149 > + return setLocation(activeWindow, firstWindow, url.string()); Ditto. > Source/WebCore/page/Location.cpp:159 > + return setLocation(activeWindow, firstWindow, url.string()); Ditto. > Source/WebCore/page/Location.cpp:179 > + return setLocation(activeWindow, firstWindow, url.string()); Ditto. > Source/WebCore/page/Location.cpp:189 > + return setLocation(activeWindow, firstWindow, url.string()); Ditto. > Source/WebCore/page/Location.cpp:209 > + return setLocation(activeWindow, firstWindow, url.string()); Ditto. > Source/WebKit/UIProcess/ios/WKActionSheetAssistant.mm:345 > + NSURL *targetURL = [NSURL URLWithString:_positionInformation->url.string()]; Should consider whether we can change this to: NSURL *targetURL = _positionInformation->url; It would change the semantics of how the URL is created to use the NSURL * conversion in the URL class, but maybe that’s good. > Source/WebKit/UIProcess/ios/WKGeolocationProviderIOS.mm:211 > + WebKit::decidePolicyForGeolocationRequestFromOrigin(request.frameInfo.securityOrigin.securityOrigin().ptr(), request.frameInfo.request.url().string(), policyListener.get(), request.view.get()); I think we should change decidePolicyForGeolocationRequestFromOrigin to take a const URL& instead of a String.
Darin Adler
Comment 7 2020-04-25 17:55:30 PDT
Comment on attachment 397602 [details] Patch New changes look good; all my comments should apply to this version as well as the one I reviewed.
Alex Christensen
Comment 8 2020-05-20 11:02:15 PDT
(In reply to Darin Adler from comment #6) > > Source/WebCore/html/HTMLPlugInElement.cpp:367 > > + type = mimeTypeFromDataURL(url.string()); > > All the callers of the mimeTypeFromDataURL function have a URL. Maybe we > should just change it to take const URL& instead of StringView instead of > changing all of them. HTMLPlugInImageElement has only a String when it calls mimeTypeFromDataURL. I'm going to keep it taking a StringView for now. > > Source/WebCore/page/Location.cpp:139 > > + return setLocation(activeWindow, firstWindow, url.string()); > > Seems unfortunate to parse, convert to a string, and then reparse. If this > is guaranteed to be a complete URL and not a relative URL piece, then we > could make a setLocation overload that takes a URL and use it here. This is a String because it is given to Document::completeURL, which uses the string as a relative URL.
Alex Christensen
Comment 9 2020-05-20 11:03:04 PDT
Darin Adler
Comment 10 2020-05-20 11:14:19 PDT
Comment on attachment 399856 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=399856&action=review > Source/WebKit/UIProcess/ios/WKPDFView.mm:532 > + (NSString *)kUTTypeUTF8PlainText : (NSString *)_positionInformation.url.string(), Looking at this makes me realize that we should add a createNSString function on WTF::String so we can make a case like this work without autorelease and without a type cast. I’d like to deprecate the operator NSString * on WTF::String and use createNSString instead.
Alex Christensen
Comment 11 2020-05-20 11:51:29 PDT
Alex Christensen
Comment 12 2020-05-20 12:48:37 PDT
Alex Christensen
Comment 13 2020-05-20 14:06:30 PDT
Darin Adler
Comment 14 2020-05-20 14:47:45 PDT
Comment on attachment 399890 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=399890&action=review > Source/WebKitLegacy/win/Plugins/PluginStream.cpp:146 > - if (protocolIsJavaScript(responseURL)) > + if (responseURL.protocolIsJavaScript()) Is this change safe? I thought you told me that invalid URLs would return false from WebCore::URL::protocolIsJavaScript, but would return true from WebCore::protocolIsJavaScript. > Source/WebKitLegacy/win/Plugins/PluginView.cpp:106 > - if (!protocolIsJavaScript(url)) > + if (!url.protocolIsJavaScript()) Ditto.
Alex Christensen
Comment 15 2020-05-20 15:29:42 PDT
Yes, if you look at URL::protocolIsJavaScript you see it is no change in behavior. Detecting javascript URLs needs special behavior and that function takes it into account, and URL::protocolIs asserts that the protocol is not "javascript" to enforce this.
EWS
Comment 16 2020-05-20 15:59:56 PDT
Committed r261968: <https://trac.webkit.org/changeset/261968> All reviewed patches have been landed. Closing bug and clearing flags on attachment 399890 [details].
Radar WebKit Bug Importer
Comment 17 2020-05-20 16:00:20 PDT
Note You need to log in before you can comment on or make changes to this bug.