Title: [122032] releases/WebKitGTK/webkit-1.8/Source/WebKit/gtk
Revision
122032
Author
[email protected]
Date
2012-07-06 13:22:57 -0700 (Fri, 06 Jul 2012)

Log Message

Merge - 121360 [gtk] Spell checker doesn't recognize contractions (apostrophes)
https://bugs.webkit.org/show_bug.cgi?id=86118

Reviewed by Gustavo Noronha Silva.

Work-around a bug in Pango by trying to detect apostrophes
that create contractions. This work-around is similar to one
found in gtkspell.

* webkit/webkitspellcheckerenchant.cpp:
(wordEndIsAContractionApostrophe): Added this helper which tries to detect
situations where a word end is both an apostrophe and followed by a alphabetic
character.
(checkSpellingOfString): When searching for the end of a word, skip over
apostrophes that appear to be part of contractions.

Modified Paths

Diff

Modified: releases/WebKitGTK/webkit-1.8/Source/WebKit/gtk/ChangeLog (122031 => 122032)


--- releases/WebKitGTK/webkit-1.8/Source/WebKit/gtk/ChangeLog	2012-07-06 20:22:48 UTC (rev 122031)
+++ releases/WebKitGTK/webkit-1.8/Source/WebKit/gtk/ChangeLog	2012-07-06 20:22:57 UTC (rev 122032)
@@ -1,3 +1,21 @@
+2012-06-27  Martin Robinson  <[email protected]>
+
+        [gtk] Spell checker doesn't recognize contractions (apostrophes)
+        https://bugs.webkit.org/show_bug.cgi?id=86118
+
+        Reviewed by Gustavo Noronha Silva.
+
+        Work-around a bug in Pango by trying to detect apostrophes
+        that create contractions. This work-around is similar to one
+        found in gtkspell.
+
+        * webkit/webkitspellcheckerenchant.cpp:
+        (wordEndIsAContractionApostrophe): Added this helper which tries to detect
+        situations where a word end is both an apostrophe and followed by a alphabetic
+        character.
+        (checkSpellingOfString): When searching for the end of a word, skip over
+        apostrophes that appear to be part of contractions.
+
 2012-05-31  Hajime Morrita  <[email protected]>
 
         REGRESSION(r117572): editing/spelling/spellcheck-async-remove-frame.html crashes on Mac

Modified: releases/WebKitGTK/webkit-1.8/Source/WebKit/gtk/webkit/webkitspellcheckerenchant.cpp (122031 => 122032)


--- releases/WebKitGTK/webkit-1.8/Source/WebKit/gtk/webkit/webkitspellcheckerenchant.cpp	2012-07-06 20:22:48 UTC (rev 122031)
+++ releases/WebKitGTK/webkit-1.8/Source/WebKit/gtk/webkit/webkitspellcheckerenchant.cpp	2012-07-06 20:22:57 UTC (rev 122032)
@@ -88,6 +88,18 @@
     priv->enchantDicts = 0;
 }
 
+static bool wordEndIsAContractionApostrophe(const char* string, long offset)
+{
+    if (g_utf8_get_char(g_utf8_offset_to_pointer(string, offset)) != g_utf8_get_char("'"))
+        return false;
+
+    // If this is the last character in the string, it cannot be the apostrophe part of a contraction.
+    if (offset == g_utf8_strlen(string, -1))
+        return false;
+
+    return g_unichar_isalpha(g_utf8_get_char(g_utf8_offset_to_pointer(string, offset + 1)));
+}
+
 static void checkSpellingOfString(WebKitSpellChecker* checker, const char* string, int* misspellingLocation, int* misspellingLength)
 {
     WebKitSpellCheckerEnchantPrivate* priv = WEBKIT_SPELL_CHECKER_ENCHANT(checker)->priv;
@@ -113,7 +125,7 @@
             int end = i;
             int wordLength;
 
-            while (attrs.get()[end].is_word_end < 1)
+            while (attrs.get()[end].is_word_end < 1 || wordEndIsAContractionApostrophe(string, end))
                 end++;
 
             wordLength = end - start;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to