Bug 108509

Summary: [Chromium] Select multi-word misspelling on context click
Product: WebKit Reporter: Rouslan Solomakhin <rouslan+webkit>
Component: HTML EditingAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: groby, jochen, morrita, rniwa, rouslan+webkit, tony, webkit.review.bot
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on:    
Bug Blocks: 106815    
Attachments:
Description Flags
Patch
none
Patch for landing
none
Patch for landing
none
Patch for landing none

Description Rouslan Solomakhin 2013-01-31 12:18:59 PST
Spell check should select multi-word misspellings on context click. To test manually, enable 'Ask Google for Suggestions' in Chrome, type 'It should be upper case.', and context-click on the word 'upper'. The test succeeds when 'upper case' was selected after context click.
Comment 1 Rouslan Solomakhin 2013-01-31 13:38:42 PST
Created attachment 185850 [details]
Patch
Comment 2 Tony Chang 2013-01-31 15:10:02 PST
Comment on attachment 185850 [details]
Patch

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

As a follow up, it would be nice if we moved the spellchecking code into a helper function out of getCustomMenuFromDefaultItems() since that function is > 200 lines.

> Source/WebKit/chromium/src/ContextMenuClientImpl.cpp:295
> +                    if (markerRange->startOffset() == selectionRange->startOffset() && markerRange->endOffset() == selectionRange->endOffset()) {

Could you use WebCore::areRangesEqual() here instead of comparing start and end?
Comment 3 Rouslan Solomakhin 2013-01-31 16:01:36 PST
Created attachment 185884 [details]
Patch for landing
Comment 4 WebKit Review Bot 2013-01-31 16:03:58 PST
Attachment 185884 [details] did not pass style-queue:

Failed to run "['Tools/Scripts/check-webkit-style', '--diff-files', u'LayoutTests/ChangeLog', u'LayoutTests/editing/spelling/spelling-exactly-selected-multiple-words-expected.txt', u'LayoutTests/editing/spelling/spelling-exactly-selected-multiple-words.html', u'LayoutTests/editing/spelling/spelling-should-select-multiple-words-expected.txt', u'LayoutTests/editing/spelling/spelling-should-select-multiple-words.html', u'LayoutTests/platform/chromium/TestExpectations', u'Source/WebKit/chromium/ChangeLog', u'Source/WebKit/chromium/src/ContextMenuClientImpl.cpp', u'Tools/ChangeLog', u'Tools/DumpRenderTree/chromium/TestRunner/src/MockSpellCheck.cpp']" exit_code: 1
Source/WebKit/chromium/src/ContextMenuClientImpl.cpp:150:  Place brace on its own line for function definitions.  [whitespace/braces] [4]
Tools/DumpRenderTree/chromium/TestRunner/src/MockSpellCheck.cpp:40:  Place brace on its own line for function definitions.  [whitespace/braces] [4]
Total errors found: 2 in 9 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 5 Rouslan Solomakhin 2013-01-31 16:04:48 PST
(In reply to comment #2)
> (From update of attachment 185850 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=185850&action=review
> 
> As a follow up, it would be nice if we moved the spellchecking code into a helper function out of getCustomMenuFromDefaultItems() since that function is > 200 lines.

Moved the async part of the spellchecking code into "selectMisspellingAsync()", which is symmetric to the synchronous version "selectMisspelledWord()". Do we need more refactorings here?

> > Source/WebKit/chromium/src/ContextMenuClientImpl.cpp:295
> > +                    if (markerRange->startOffset() == selectionRange->startOffset() && markerRange->endOffset() == selectionRange->endOffset()) {
> 
> Could you use WebCore::areRangesEqual() here instead of comparing start and end?


Done.
Comment 6 Rouslan Solomakhin 2013-01-31 16:06:04 PST
Created attachment 185887 [details]
Patch for landing
Comment 7 Rouslan Solomakhin 2013-01-31 16:07:05 PST
Comment on attachment 185887 [details]
Patch for landing

Fixed style errors.
Comment 8 Tony Chang 2013-01-31 16:35:49 PST
Comment on attachment 185887 [details]
Patch for landing

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

I had suggested moving in a follow up change because now the diff doesn't show your changes.  Anyway, this is OK too.

> Source/WebKit/chromium/src/ContextMenuClientImpl.cpp:149
> +// Helper function to get misspelling on which context menu is to be invoked
> +// for asynchronous spellcheck. This function changes the selection only when
> +// there were no selected characters.

Remove this comment.

> Tools/DumpRenderTree/chromium/TestRunner/src/MockSpellCheck.cpp:120
> +    if (word == WebString::fromUTF8("wellcome"))
> +        append(suggestions, WebString::fromUTF8("welcome"));

Why do we copy and swap?  Why can't we append to |suggestions| directly?
Comment 9 Rouslan Solomakhin 2013-01-31 16:44:35 PST
Created attachment 185896 [details]
Patch for landing
Comment 10 Rouslan Solomakhin 2013-01-31 16:45:45 PST
(In reply to comment #8)
> (From update of attachment 185887 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=185887&action=review
> 
> I had suggested moving in a follow up change because now the diff doesn't show your changes.  Anyway, this is OK too.

Sorry about the confusion.

> > Source/WebKit/chromium/src/ContextMenuClientImpl.cpp:149
> > +// Helper function to get misspelling on which context menu is to be invoked
> > +// for asynchronous spellcheck. This function changes the selection only when
> > +// there were no selected characters.
> 
> Remove this comment.

Removed.

> > Tools/DumpRenderTree/chromium/TestRunner/src/MockSpellCheck.cpp:120
> > +    if (word == WebString::fromUTF8("wellcome"))
> > +        append(suggestions, WebString::fromUTF8("welcome"));
> 
> Why do we copy and swap?  Why can't we append to |suggestions| directly?

WebVector has a constant size.
Comment 11 Rouslan Solomakhin 2013-01-31 16:53:15 PST
(In reply to comment #10)
> WebVector has a constant size.

... and does not have built-in append(), add(), or push_back() methods.
Comment 12 Tony Chang 2013-01-31 17:01:36 PST
Comment on attachment 185896 [details]
Patch for landing

(In reply to comment #10)
> (In reply to comment #8)

> > > Tools/DumpRenderTree/chromium/TestRunner/src/MockSpellCheck.cpp:120
> > > +    if (word == WebString::fromUTF8("wellcome"))
> > > +        append(suggestions, WebString::fromUTF8("welcome"));
> > 
> > Why do we copy and swap?  Why can't we append to |suggestions| directly?
> 
> WebVector has a constant size.

I see. Makes sense.
Comment 13 WebKit Review Bot 2013-01-31 18:06:52 PST
Comment on attachment 185896 [details]
Patch for landing

Clearing flags on attachment: 185896

Committed r141519: <http://trac.webkit.org/changeset/141519>
Comment 14 WebKit Review Bot 2013-01-31 18:06:57 PST
All reviewed patches have been landed.  Closing bug.