Bug 173495 - Cleanup: WebContentMenuClient::searchWithGoogle() should parse URL using URL { URL { }, ... } instead of URL { ParsedURLString, ... }
Summary: Cleanup: WebContentMenuClient::searchWithGoogle() should parse URL using URL ...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore Misc. (show other bugs)
Version: WebKit Local Build
Hardware: All All
: P2 Normal
Assignee: Daniel Bates
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2017-06-16 14:03 PDT by Daniel Bates
Modified: 2017-06-16 17:56 PDT (History)
2 users (show)

See Also:


Attachments
Patch (5.24 KB, patch)
2017-06-16 14:04 PDT, Daniel Bates
no flags Details | Formatted Diff | Diff
Patch (5.33 KB, patch)
2017-06-16 14:10 PDT, Daniel Bates
no flags Details | Formatted Diff | Diff
Patch (5.35 KB, patch)
2017-06-16 14:11 PDT, Daniel Bates
achristensen: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel Bates 2017-06-16 14:03:44 PDT
When parsing an arbitrary string s that looks like a URL we should use URL { URL { }, s }. The constructor URL { ParsedURLString, s' } should only be used when s' is the result from URL::string(). WebContentMenuClient::searchWithGoogle() should use URL { URL { }, ... } to construct the URL object for the string it built.
Comment 1 Daniel Bates 2017-06-16 14:04:59 PDT
Created attachment 313129 [details]
Patch
Comment 2 Daniel Bates 2017-06-16 14:10:21 PDT
Created attachment 313130 [details]
Patch
Comment 3 Daniel Bates 2017-06-16 14:11:46 PDT
Created attachment 313131 [details]
Patch
Comment 4 Alex Christensen 2017-06-16 14:12:22 PDT
Comment on attachment 313131 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=313131&action=review

> Source/WebKit/win/WebCoreSupport/WebContextMenuClient.cpp:66
> +    String url = "http://www.google.com/search?q=" + encoded + "&ie=UTF-8&oe=UTF-8";

I think makeString is even more efficient than calling operator+ twice.
Comment 5 Daniel Bates 2017-06-16 14:24:08 PDT
(In reply to Alex Christensen from comment #4)
> Comment on attachment 313131 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=313131&action=review
> 
> > Source/WebKit/win/WebCoreSupport/WebContextMenuClient.cpp:66
> > +    String url = "http://www.google.com/search?q=" + encoded + "&ie=UTF-8&oe=UTF-8";
> 
> I think makeString is even more efficient than calling operator+ twice.

The StringOperators usage in this line is almost as efficient as makeString(), which is efficient enough for our use here. StringOperators ensures that we allocate for the finalized size once and then copy the parts just like makeString(). The difference between StringOperators and makeString() is the StringOperators can create temporaries and ultimately we need to convert from StringAppend to String. These differences likely go away with a good optimizing compiler.
Comment 6 Radar WebKit Bug Importer 2017-06-16 17:50:11 PDT
<rdar://problem/32827445>
Comment 7 Daniel Bates 2017-06-16 17:56:06 PDT
Committed r218435: <http://trac.webkit.org/changeset/218435>