Bug 47980

Summary: Add the feature "Add as search engine..." in a search text field context menu for chromium
Product: WebKit Reporter: philippe.beauchamp
Component: WebKit APIAssignee: philippe.beauchamp
Status: RESOLVED FIXED    
Severity: Enhancement CC: commit-queue, dglazkov, philippe.beauchamp, pkasting, sky, webkit.review.bot
Priority: P4    
Version: 528+ (Nightly build)   
Hardware: All   
OS: All   
Attachments:
Description Flags
Proposed patch
philippe.beauchamp: review-
Proposed Patch V2 - Split of HasSuitableTextElement in two parts
none
Proposed Patch V2 - Split of HasSuitableTextElement in two parts
abarth: review-
Proposed Patch V3
none
Proposed Patch V3 - removed \r char
abarth: review-
Proposed Patch V5
none
Proposed Patch V5
none
Proposed Patch V6
dglazkov: review-
Proposed Patch V7
none
Proposed Patch V7
dglazkov: review-
Proposed Patch V8
none
Proposed Patch V9
dglazkov: review-
Proposed Patch V10 - Removed WebCore namespace tags none

philippe.beauchamp
Reported 2010-10-20 05:53:24 PDT
Attachments
Proposed patch (8.74 KB, patch)
2010-10-20 05:56 PDT, philippe.beauchamp
philippe.beauchamp: review-
Proposed Patch V2 - Split of HasSuitableTextElement in two parts (12.73 KB, patch)
2010-10-24 20:48 PDT, philippe.beauchamp
no flags
Proposed Patch V2 - Split of HasSuitableTextElement in two parts (12.71 KB, patch)
2010-10-24 21:08 PDT, philippe.beauchamp
abarth: review-
Proposed Patch V3 (12.56 KB, patch)
2010-10-28 05:26 PDT, philippe.beauchamp
no flags
Proposed Patch V3 - removed \r char (12.55 KB, patch)
2010-10-28 07:32 PDT, philippe.beauchamp
abarth: review-
Proposed Patch V5 (12.75 KB, patch)
2010-11-01 06:01 PDT, philippe.beauchamp
no flags
Proposed Patch V5 (12.74 KB, patch)
2010-11-01 06:13 PDT, philippe.beauchamp
no flags
Proposed Patch V6 (13.06 KB, patch)
2010-11-02 05:41 PDT, philippe.beauchamp
dglazkov: review-
Proposed Patch V7 (13.62 KB, patch)
2011-04-25 10:13 PDT, philippe.beauchamp
no flags
Proposed Patch V7 (13.69 KB, patch)
2011-04-25 10:53 PDT, philippe.beauchamp
dglazkov: review-
Proposed Patch V8 (13.56 KB, patch)
2011-05-16 20:26 PDT, philippe.beauchamp
no flags
Proposed Patch V9 (13.73 KB, patch)
2011-05-19 06:26 PDT, philippe.beauchamp
dglazkov: review-
Proposed Patch V10 - Removed WebCore namespace tags (13.62 KB, patch)
2011-06-02 18:54 PDT, philippe.beauchamp
no flags
philippe.beauchamp
Comment 1 2010-10-20 05:56:15 PDT
Created attachment 71278 [details] Proposed patch
Peter Kasting
Comment 2 2010-10-20 09:32:06 PDT
Comment on attachment 71278 [details] Proposed patch View in context: https://bugs.webkit.org/attachment.cgi?id=71278&action=review > WebKit/chromium/ChangeLog:64 > +>>>>>>> .r69954 You have a merge conflict marker here.
Peter Kasting
Comment 3 2010-10-20 09:32:52 PDT
Also, why did you mark yourself r-? Is this patch not yet what you want?
Scott Violet
Comment 4 2010-10-20 12:16:11 PDT
I think you should split HasSuitableTextElement into at least two functions: . FindSuitableTextElement: used if no element provided to the constructor. . Another function that builds the encodedString.
philippe.beauchamp
Comment 5 2010-10-24 20:48:08 PDT
Created attachment 71712 [details] Proposed Patch V2 - Split of HasSuitableTextElement in two parts
philippe.beauchamp
Comment 6 2010-10-24 21:08:35 PDT
Created attachment 71714 [details] Proposed Patch V2 - Split of HasSuitableTextElement in two parts
WebKit Review Bot
Comment 7 2010-10-24 21:12:38 PDT
Attachment 71714 [details] did not pass style-queue: Failed to run "['WebKitTools/Scripts/check-webkit-style']" exit_code: 1 WebKit/chromium/src/ContextMenuClientImpl.cpp:44: Alphabetical sorting problem. [build/include_order] [4] WebKit/chromium/src/WebSearchableFormData.cpp:233: Boolean expressions that span multiple lines should have their operators on the left side of the line instead of the right side. [whitespace/operators] [4] Total errors found: 2 in 5 files If any of these errors are false positives, please file a bug against check-webkit-style.
Scott Violet
Comment 8 2010-10-25 11:21:13 PDT
Comment on attachment 71714 [details] Proposed Patch V2 - Split of HasSuitableTextElement in two parts View in context: https://bugs.webkit.org/attachment.cgi?id=71714&action=review > WebKit/chromium/src/WebSearchableFormData.cpp:147 > +WebCore::HTMLInputElement* HasSuitableTextElement(const HTMLFormElement* form, TextEncoding* encoding) Rename to FindSuitableTextElement. > WebKit/chromium/src/WebSearchableFormData.cpp:187 > +bool BuildSearchString(const HTMLFormElement* form, Vector<char>* encodedString, TextEncoding* encoding, const WebCore::HTMLInputElement* textElement) This seems to always return true, so convert to void. > WebKit/chromium/src/WebSearchableFormData.cpp:196 > + if (!formElement->appendFormData(dataList, false)) You also do this in BuildSearchString. It should probably only be here. > WebKit/chromium/src/WebSearchableFormData.cpp:235 > + return; Spacing looks off here.
philippe.beauchamp
Comment 9 2010-10-25 12:14:17 PDT
Comment on attachment 71714 [details] Proposed Patch V2 - Split of HasSuitableTextElement in two parts View in context: https://bugs.webkit.org/attachment.cgi?id=71714&action=review >> WebKit/chromium/src/WebSearchableFormData.cpp:196 >> + if (!formElement->appendFormData(dataList, false)) > > You also do this in BuildSearchString. It should probably only be here. Agree. This is what I did at first but there is something strange with the "if (input->isTextField() && !items.isEmpty()" the input->isTextField() returns true for a list. We need to find a better way to determine that this is a list other than generating it. I'll try to investigate tonight to find the exact explanation, still not clear for me.
Adam Barth
Comment 10 2010-10-27 13:09:19 PDT
Comment on attachment 71714 [details] Proposed Patch V2 - Split of HasSuitableTextElement in two parts Please address the review comments above.
philippe.beauchamp
Comment 11 2010-10-28 05:26:15 PDT
Created attachment 72172 [details] Proposed Patch V3
WebKit Review Bot
Comment 12 2010-10-28 05:28:17 PDT
Attachment 72172 [details] did not pass style-queue: Failed to run "['WebKitTools/Scripts/check-webkit-style']" exit_code: 1 WebKit/chromium/src/ContextMenuClientImpl.cpp:44: Alphabetical sorting problem. [build/include_order] [4] WebKit/chromium/src/WebSearchableFormData.cpp:159: One or more unexpected \r (^M) found; better to use only a \n [whitespace/carriage_return] [1] Suppressing further [whitespace/carriage_return] reports for this file. Total errors found: 3 in 5 files If any of these errors are false positives, please file a bug against check-webkit-style.
philippe.beauchamp
Comment 13 2010-10-28 07:32:49 PDT
Created attachment 72190 [details] Proposed Patch V3 - removed \r char Scott, What do you think about the formElement->willValidate() condition instead of generating the list? Seems to be working fine. Do you see something that can break this? Philippe
WebKit Review Bot
Comment 14 2010-10-28 07:35:51 PDT
Attachment 72190 [details] did not pass style-queue: Failed to run "['WebKitTools/Scripts/check-webkit-style']" exit_code: 1 WebKit/chromium/src/ContextMenuClientImpl.cpp:44: Alphabetical sorting problem. [build/include_order] [4] Total errors found: 1 in 5 files If any of these errors are false positives, please file a bug against check-webkit-style.
WebKit Review Bot
Comment 15 2010-10-28 19:29:20 PDT
Scott Violet
Comment 16 2010-10-29 08:41:55 PDT
Comment on attachment 72190 [details] Proposed Patch V3 - removed \r char View in context: https://bugs.webkit.org/attachment.cgi?id=72190&action=review > WebKit/chromium/src/WebSearchableFormData.cpp:228 > + && !selectedInputElement) You need another set of parens here. > WebKit/chromium/src/WebSearchableFormData.cpp:250 > + } Verify that if selectedInputElement is supplied that it's in the form.
Adam Barth
Comment 17 2010-10-31 18:09:56 PDT
Comment on attachment 72190 [details] Proposed Patch V3 - removed \r char Does not compile.
philippe.beauchamp
Comment 18 2010-11-01 06:01:14 PDT
Created attachment 72498 [details] Proposed Patch V5
WebKit Review Bot
Comment 19 2010-11-01 06:04:15 PDT
Attachment 72498 [details] did not pass style-queue: Failed to run "['WebKitTools/Scripts/check-webkit-style']" exit_code: 1 WebKit/chromium/src/ContextMenuClientImpl.cpp:44: Alphabetical sorting problem. [build/include_order] [4] WebKit/chromium/src/WebSearchableFormData.cpp:211: An else should appear on the same line as the preceding } [whitespace/newline] [4] Total errors found: 2 in 5 files If any of these errors are false positives, please file a bug against check-webkit-style.
philippe.beauchamp
Comment 20 2010-11-01 06:13:00 PDT
Created attachment 72499 [details] Proposed Patch V5
Scott Violet
Comment 21 2010-11-01 08:31:23 PDT
Comment on attachment 72499 [details] Proposed Patch V5 View in context: https://bugs.webkit.org/attachment.cgi?id=72499&action=review > WebKit/chromium/src/WebSearchableFormData.cpp:181 > +bool BuildSearchString(const HTMLFormElement* form, Vector<char>* encodedString, TextEncoding* encoding, const WebCore::HTMLInputElement* textElement) Document method and return value. > WebKit/chromium/src/WebSearchableFormData.cpp:211 > + FormDataBuilder::encodeStringAsFormData(*encodedString, j->data()); Add parens around this. > WebKit/chromium/src/WebSearchableFormData.cpp:270 > + if (!validSearchString) Should this be before 266? Perhaps it should just be: if (!BuildSear...()) return;
philippe.beauchamp
Comment 22 2010-11-02 05:41:00 PDT
Created attachment 72654 [details] Proposed Patch V6
WebKit Review Bot
Comment 23 2010-11-02 05:43:35 PDT
Attachment 72654 [details] did not pass style-queue: Failed to run "['WebKitTools/Scripts/check-webkit-style']" exit_code: 1 WebKit/chromium/src/ContextMenuClientImpl.cpp:44: Alphabetical sorting problem. [build/include_order] [4] WebKit/chromium/src/WebSearchableFormData.cpp:184: Line contains invalid UTF-8 (or Unicode replacement character). [readability/utf8] [5] Total errors found: 2 in 5 files If any of these errors are false positives, please file a bug against check-webkit-style.
philippe.beauchamp
Comment 24 2010-11-02 05:46:32 PDT
Comment on attachment 72499 [details] Proposed Patch V5 View in context: https://bugs.webkit.org/attachment.cgi?id=72499&action=review >> WebKit/chromium/src/WebSearchableFormData.cpp:270 >> + if (!validSearchString) > > Should this be before 266? Perhaps it should just be: > > if (!BuildSear...()) > return; The firstSubmitButton is set true at 261 and is set back to false at 267. It will be left true if BuildSearchString returns false.
Scott Violet
Comment 25 2010-11-02 10:44:11 PDT
The changes to WebSearchableFormData LGTM, you'll need to get someone else to review the changes to ContextMenuClientImpl.cpp.
philippe.beauchamp
Comment 26 2010-11-02 17:34:21 PDT
Comment on attachment 72499 [details] Proposed Patch V5 View in context: https://bugs.webkit.org/attachment.cgi?id=72499&action=review >> WebKit/chromium/src/WebSearchableFormData.cpp:270 >> + if (!validSearchString) > > Should this be before 266? Perhaps it should just be: > > if (!BuildSear...()) > return; The firstSubmitButton is set true at 261 and is set back to false at 267. It will be left true if BuildSearchString returns false.
philippe.beauchamp
Comment 27 2010-11-02 19:29:55 PDT
Comment on attachment 72499 [details] Proposed Patch V5 View in context: https://bugs.webkit.org/attachment.cgi?id=72499&action=review >> WebKit/chromium/src/WebSearchableFormData.cpp:270 >> + if (!validSearchString) > > Should this be before 266? Perhaps it should just be: > > if (!BuildSear...()) > return; The firstSubmitButton is set true at 261 and is set back to false at 267. It will be left true if BuildSearchString returns false.
philippe.beauchamp
Comment 28 2010-11-02 19:38:45 PDT
(In reply to comment #25) > The changes to WebSearchableFormData LGTM, you'll need to get someone else to review the changes to ContextMenuClientImpl.cpp. OK thanks, Peter, are you right person to have a look at it?
Peter Kasting
Comment 29 2010-11-03 10:06:15 PDT
(In reply to comment #28) > (In reply to comment #25) > > The changes to WebSearchableFormData LGTM, you'll need to get someone else to review the changes to ContextMenuClientImpl.cpp. > > OK thanks, Peter, are you right person to have a look at it? I can't review this because I don't know how all the WebKit data structures here fit together. For example, I can't tell you whether your method of obtaining the current form is the right one. I'm not sure who knows this. Maybe dglazkov knows who'd know. I can tell you that you can combine some of your nested conditionals.
Dimitri Glazkov (Google)
Comment 30 2010-11-04 14:32:51 PDT
Comment on attachment 72654 [details] Proposed Patch V6 View in context: https://bugs.webkit.org/attachment.cgi?id=72654&action=review > WebKit/chromium/public/WebSearchableFormData.h:48 > + WEBKIT_API WebSearchableFormData(const WebFormElement&, const WebCore::HTMLInputElement* selectedInputElement = 0); Please don't pass WebCore types into WebKit API. That's what WebInputElement/WebElement wrappers are for. > WebKit/chromium/src/ContextMenuClientImpl.cpp:253 > + WebCore::HTMLInputElement* selectedElement = static_cast<WebCore::HTMLInputElement*>(r.innerNonSharedNode()); What if it's not an HTMLInputElement? > WebKit/chromium/src/WebSearchableFormData.cpp:147 > +WebCore::HTMLInputElement* FindSuitableTextElement(const HTMLFormElement* form) Why do we have Capitalized methods in WebKit? That's not WebKit style http://webkit.org/coding/coding-style.html > WebKit/chromium/src/WebSearchableFormData.cpp:187 > +bool BuildSearchString(const HTMLFormElement* form, Vector<char>* encodedString, TextEncoding* encoding, const WebCore::HTMLInputElement* textElement) Ditto. > WebKit/chromium/src/WebSearchableFormData.cpp:222 > +{ > + bool isElementFound = false; > + > + // FIXME: Consider refactoring this code so that we don't call form->associatedElements() twice. > + for (Vector<HTMLFormControlElement*>::const_iterator i(form->associatedElements().begin()); i != form->associatedElements().end(); ++i) { > + HTMLFormControlElement* formElement = *i; > + if (formElement->disabled() || formElement->name().isNull()) > + continue; > + > + FormDataList dataList(*encoding); > + if (!formElement->appendFormData(dataList, false)) > + continue; > + > + const Vector<FormDataList::Item>& items = dataList.items(); > + > + for (Vector<FormDataList::Item>::const_iterator j(items.begin()); j != items.end(); ++j) { > + // Handle ISINDEX / <input name=isindex> specially, but only if it's > + // the first entry. > + if (!encodedString->isEmpty() || j->data() != "isindex") { > + if (!encodedString->isEmpty()) > + encodedString->append('&'); > + FormDataBuilder::encodeStringAsFormData(*encodedString, j->data()); > + encodedString->append('='); > + } > + ++j; > + if (formElement == textElement) { > + encodedString->append("{searchTerms}", 13); > + isElementFound = true; > + } else { > + FormDataBuilder::encodeStringAsFormData(*encodedString, j->data()); > + } > + } > + } > + return isElementFound; > +} Can this somehow not be a mostly duplication of FormData logic? > WebKit/chromium/src/WebSearchableFormData.cpp:284 > + m_encoding = (String) encoding.name(); Whoa. Why are we casting things here like that?
Peter Kasting
Comment 31 2011-04-21 13:13:52 PDT
Philippe, are you still around? I'd hate to see this die.
philippe.beauchamp
Comment 32 2011-04-22 08:05:30 PDT
I'm still around. I agree, we should move this forward. I’ll check this during the weekend. Philippe (In reply to comment #31) > Philippe, are you still around? I'd hate to see this die.
philippe.beauchamp
Comment 33 2011-04-25 10:13:57 PDT
Created attachment 90924 [details] Proposed Patch V7
WebKit Review Bot
Comment 34 2011-04-25 10:22:26 PDT
Attachment 90924 [details] did not pass style-queue: Failed to run "['Tools/Scripts/check-webkit-style', '--diff-files', u'Source/WebKit/chromium/ChangeLog', u'Sourc..." exit_code: 1 Source/WebKit/chromium/ChangeLog:1: ChangeLog entry has no bug number [changelog/bugnumber] [5] Source/WebKit/chromium/src/WebSearchableFormData.cpp:230: One line control clauses should not use braces. [whitespace/braces] [4] Source/WebKit/chromium/src/WebSearchableFormData.cpp:192: Line contains invalid UTF-8 (or Unicode replacement character). [readability/utf8] [5] Source/WebKit/chromium/public/WebSearchableFormData.h:36: Alphabetical sorting problem. [build/include_order] [4] Source/WebKit/chromium/public/WebSearchableFormData.h:47: Missing spaces around = [whitespace/operators] [4] Source/WebKit/chromium/src/ContextMenuClientImpl.cpp:46: Alphabetical sorting problem. [build/include_order] [4] Total errors found: 6 in 5 files If any of these errors are false positives, please file a bug against check-webkit-style.
philippe.beauchamp
Comment 35 2011-04-25 10:53:05 PDT
Created attachment 90932 [details] Proposed Patch V7
WebKit Review Bot
Comment 36 2011-04-25 10:55:42 PDT
Attachment 90932 [details] did not pass style-queue: Failed to run "['Tools/Scripts/check-webkit-style', '--diff-files', u'Source/WebKit/chromium/ChangeLog', u'Sourc..." exit_code: 1 Source/WebKit/chromium/src/ContextMenuClientImpl.cpp:46: Alphabetical sorting problem. [build/include_order] [4] Total errors found: 1 in 5 files If any of these errors are false positives, please file a bug against check-webkit-style.
philippe.beauchamp
Comment 37 2011-05-09 05:40:52 PDT
Hello Dimitri, Can you have look at the patch when you have some time? I changed the Webcore/Webkit api call and other items. I'm not sure about the conversion for the selectedInputElement into WebCore type in WebSearchableFormData, can you comment on this? thanks, Philippe (In reply to comment #35) > Created an attachment (id=90932) [details] > Proposed Patch V7
Dimitri Glazkov (Google)
Comment 38 2011-05-16 09:07:35 PDT
Comment on attachment 90932 [details] Proposed Patch V7 View in context: https://bugs.webkit.org/attachment.cgi?id=90932&action=review Please address style elf's feedback. > Source/WebKit/chromium/src/WebSearchableFormData.cpp:151 > +WebCore::HTMLInputElement* findSuitableSearchInputElement(const HTMLFormElement* form) Don't need WebCore namespace qualifier here. > Source/WebKit/chromium/src/WebSearchableFormData.cpp:165 > + // Return nothing if an element is not in the default state > + // Return nothing if a text area is found. This comment just repeats what the code does. Don't need it here.
philippe.beauchamp
Comment 39 2011-05-16 20:26:36 PDT
Created attachment 93734 [details] Proposed Patch V8 Updated Patch. -Removed comments -Removed WebCore namespace qualifier Style error is false positive for Alphabetical Sorting problem *** #include "HitTestResult.h" #include "HTMLFormElement.h" ^ *** in \Tools\Scripts\webkitpy\style\checkers\cpp.py:2703 if previous_header_type == _OTHER_HEADER and previous_line.strip() > line.strip(): should be something like: if previous_header_type == _OTHER_HEADER and previous_line.strip().lower() > line.strip().lower(): I'll report to check-webkit-style
WebKit Review Bot
Comment 40 2011-05-16 20:28:20 PDT
Attachment 93734 [details] did not pass style-queue: Failed to run "['Tools/Scripts/check-webkit-style', '--diff-files', u'Source/WebKit/chromium/ChangeLog', u'Sourc..." exit_code: 1 Source/WebKit/chromium/src/ContextMenuClientImpl.cpp:46: Alphabetical sorting problem. [build/include_order] [4] Total errors found: 1 in 5 files If any of these errors are false positives, please file a bug against check-webkit-style.
philippe.beauchamp
Comment 41 2011-05-19 06:26:48 PDT
Created attachment 94064 [details] Proposed Patch V9 Solved the Alphabetical sorting problem, I didn't pay attention to the Style Guideline for this one.
Dimitri Glazkov (Google)
Comment 42 2011-05-27 09:13:02 PDT
(In reply to comment #39) > Created an attachment (id=93734) [details] > Proposed Patch V8 > > Updated Patch. > -Removed comments > -Removed WebCore namespace qualifier > > Style error is false positive for Alphabetical Sorting problem > *** > #include "HitTestResult.h" > #include "HTMLFormElement.h" > ^ > *** > in \Tools\Scripts\webkitpy\style\checkers\cpp.py:2703 > if previous_header_type == _OTHER_HEADER and previous_line.strip() > line.strip(): > > should be something like: > if previous_header_type == _OTHER_HEADER and previous_line.strip().lower() > line.strip().lower(): > > I'll report to check-webkit-style It's intentionally a case-sensitive sort. See http://www.webkit.org/coding/coding-style.html
Dimitri Glazkov (Google)
Comment 43 2011-05-27 09:13:51 PDT
(In reply to comment #41) > Created an attachment (id=94064) [details] > Proposed Patch V9 > > Solved the Alphabetical sorting problem, I didn't pay attention to the Style Guideline for this one. Ah, I see you got this :)
Dimitri Glazkov (Google)
Comment 44 2011-05-27 09:18:55 PDT
Comment on attachment 94064 [details] Proposed Patch V9 View in context: https://bugs.webkit.org/attachment.cgi?id=94064&action=review > Source/WebKit/chromium/src/ContextMenuClientImpl.cpp:277 > + WebCore::HTMLFormElement* form = selectedFrame->selection()->currentForm(); Still don't need WebCore namespace here and elsewhere.
philippe.beauchamp
Comment 45 2011-06-02 18:54:58 PDT
Created attachment 95844 [details] Proposed Patch V10 - Removed WebCore namespace tags
WebKit Commit Bot
Comment 46 2011-06-03 09:41:17 PDT
Comment on attachment 95844 [details] Proposed Patch V10 - Removed WebCore namespace tags Rejecting attachment 95844 [details] from commit-queue. Failed to run "['./Tools/Scripts/webkit-patch', '--status-host=queues.webkit.org', '--bot-id=cr-jail-7', 'apply-..." exit_code: 1 Last 500 characters of output: autoinstalled/mechanize/_urllib2_fork.py", line 332, in _call_chain result = func(*args) File "/mnt/git/webkit-commit-queue/Tools/Scripts/webkitpy/thirdparty/autoinstalled/mechanize/_urllib2_fork.py", line 1170, in https_open return self.do_open(conn_factory, req) File "/mnt/git/webkit-commit-queue/Tools/Scripts/webkitpy/thirdparty/autoinstalled/mechanize/_urllib2_fork.py", line 1118, in do_open raise URLError(err) urllib2.URLError: <urlopen error [Errno 60] Operation timed out> Full output: http://queues.webkit.org/results/8763145
WebKit Commit Bot
Comment 47 2011-06-03 10:39:23 PDT
Comment on attachment 95844 [details] Proposed Patch V10 - Removed WebCore namespace tags Clearing flags on attachment: 95844 Committed r88030: <http://trac.webkit.org/changeset/88030>
WebKit Commit Bot
Comment 48 2011-06-03 10:39:31 PDT
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.