Title: [121360] trunk/Source/WebKit/gtk
Revision
121360
Author
commit-qu...@webkit.org
Date
2012-06-27 13:22:32 -0700 (Wed, 27 Jun 2012)

Log Message

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

Patch by Martin Robinson <mrobin...@igalia.com> on 2012-06-27
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: trunk/Source/WebKit/gtk/ChangeLog (121359 => 121360)


--- trunk/Source/WebKit/gtk/ChangeLog	2012-06-27 19:54:48 UTC (rev 121359)
+++ trunk/Source/WebKit/gtk/ChangeLog	2012-06-27 20:22:32 UTC (rev 121360)
@@ -1,3 +1,21 @@
+2012-06-27  Martin Robinson  <mrobin...@igalia.com>
+
+        [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-06-27  Zan Dobersek  <zandober...@gmail.com>
 
         [Gtk] Add support for the Gamepad API

Modified: trunk/Source/WebKit/gtk/webkit/webkitspellcheckerenchant.cpp (121359 => 121360)


--- trunk/Source/WebKit/gtk/webkit/webkitspellcheckerenchant.cpp	2012-06-27 19:54:48 UTC (rev 121359)
+++ trunk/Source/WebKit/gtk/webkit/webkitspellcheckerenchant.cpp	2012-06-27 20:22:32 UTC (rev 121360)
@@ -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
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to