Bug 106662 - [EFL][GTK] checkSpellingOfString treats the multiple words as spelled correctly
Summary: [EFL][GTK] checkSpellingOfString treats the multiple words as spelled correctly
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit EFL (show other bugs)
Version: 528+ (Nightly build)
Hardware: All Linux
: P2 Normal
Assignee: Grzegorz Czajkowski
URL:
Keywords:
Depends on:
Blocks: 104528
  Show dependency treegraph
 
Reported: 2013-01-11 06:56 PST by Grzegorz Czajkowski
Modified: 2013-01-17 00:27 PST (History)
10 users (show)

See Also:


Attachments
proposed patch (4.98 KB, patch)
2013-01-11 07:02 PST, Grzegorz Czajkowski
svillar: review-
buildbot: commit-queue-
Details | Formatted Diff | Diff
stop checking next words if the current word is misspelled (7.17 KB, patch)
2013-01-15 00:47 PST, Grzegorz Czajkowski
no flags Details | Formatted Diff | Diff
apply Sergio's suggestion (5.84 KB, patch)
2013-01-15 06:03 PST, Grzegorz Czajkowski
tonikitoo: review+
tonikitoo: commit-queue-
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Grzegorz Czajkowski 2013-01-11 06:56:17 PST
TextCheckerEnchant::checkSpellingOfString() method, treats the multiple words as spelled correctly if one of them is ok. For example, string such as "OK zz OK" is spelled correctly!

The method at the beginning assumes that the given string is spelled correctly, then it iterates over the words. In checkSpellingOfWord, if the word is ok, we mark it as spelled correctly and we do return. In the fact, the location and length of the previously misspelled words will be overwritten.
Comment 1 Grzegorz Czajkowski 2013-01-11 07:02:52 PST
Created attachment 182338 [details]
proposed patch
Comment 2 Build Bot 2013-01-11 07:28:21 PST
Comment on attachment 182338 [details]
proposed patch

Attachment 182338 [details] did not pass mac-ews (mac):
Output: http://queues.webkit.org/results/15815191

New failing tests:
svg/as-image/img-relative-height.html
Comment 3 Grzegorz Czajkowski 2013-01-11 07:46:09 PST
(In reply to comment #2)
> (From update of attachment 182338 [details])
> Attachment 182338 [details] did not pass mac-ews (mac):
> Output: http://queues.webkit.org/results/15815191
> 
> New failing tests:
> svg/as-image/img-relative-height.html

The patch touches only TextCheckerEnchant.cpp file which is building for EFL and GTK+ WebKit ports. I believe this regression is not connected with this patch.
Comment 4 Sergio Villar Senin 2013-01-14 02:26:53 PST
Comment on attachment 182338 [details]
proposed patch

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

The problem is not in checkSpellingOfWord() but in checkSpellingOfString(). What happens in the test case you mention is that after considering that zz is misspelled (and thus filling misspellingLocation and misspellingLength with the proper values), then it processes the 3rd word which is correct and thus it will overwrite the two variables with 0, -1, so the whole string will be considered correct. What you have to do is exit if one of the words is wrong.

> Source/WebCore/platform/text/enchant/TextCheckerEnchant.cpp:78
>          }

This is wrong, the word is OK if it's correct according to at least one dictionary not the other way around.
Comment 5 Grzegorz Czajkowski 2013-01-15 00:47:31 PST
Created attachment 182713 [details]
stop checking next words if the current word is misspelled
Comment 6 Sergio Villar Senin 2013-01-15 03:32:32 PST
Comment on attachment 182713 [details]
stop checking next words if the current word is misspelled

Why are you adding a return value? In order to know if a word is correct you just need to check that misspellingLocation == -1, there is no need to add a boolean.
Comment 7 Sergio Villar Senin 2013-01-15 03:37:46 PST
Comment on attachment 182713 [details]
stop checking next words if the current word is misspelled

Sorry I shouldn't have set the r- not being a reviewer.
Comment 8 Grzegorz Czajkowski 2013-01-15 06:02:05 PST
(In reply to comment #6)
> (From update of attachment 182713 [details])
> Why are you adding a return value? In order to know if a word is correct you just need to check that misspellingLocation == -1, there is no need to add a boolean.

I thought about checking misspellingLocation == -1 after your review but when I started to make the proper changes, IMO the code wasn't look well. However, returning the same information (whether the word is misspelled or not) by return value and parameter is worst. Patch is coming.
Comment 9 Grzegorz Czajkowski 2013-01-15 06:03:27 PST
Created attachment 182746 [details]
apply Sergio's suggestion
Comment 10 Sergio Villar Senin 2013-01-16 05:15:06 PST
(In reply to comment #9)
> Created an attachment (id=182746) [details]
> apply Sergio's suggestion

LGTM now
Comment 11 Antonio Gomes 2013-01-16 05:59:50 PST
Comment on attachment 182746 [details]
apply Sergio's suggestion

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

> Source/WebCore/platform/text/enchant/TextCheckerEnchant.cpp:-72
> -    for (Vector<EnchantDict*>::const_iterator dictIter = m_enchantDictionaries.begin(); dictIter != m_enchantDictionaries.end(); ++dictIter) {

nit "{" is still needed as the 'for' content wraps line.
Comment 12 Grzegorz Czajkowski 2013-01-17 00:27:37 PST
Committed r139971: <http://trac.webkit.org/changeset/139971>