Title: [128188] trunk/Source/WebKit/blackberry
Revision
128188
Author
commit-qu...@webkit.org
Date
2012-09-11 08:08:43 -0700 (Tue, 11 Sep 2012)

Log Message

[BlackBerry] Take account for single words that exceed our client character limit
https://bugs.webkit.org/show_bug.cgi?id=96389

Fix to the processing of long single-line text using getRangeForSpellCheckWithFineGranularity.
This was failing if a single word was longer than our maximum allowed limit.

Internally reviewed by Mike Fenton.

Patch by Nima Ghanavatian <nghanavat...@rim.com> on 2012-09-11
Reviewed by Rob Buis.

* WebKitSupport/InputHandler.cpp:
(WebKit):
(BlackBerry::WebKit::InputHandler::getRangeForSpellCheckWithFineGranularity):

Modified Paths

Diff

Modified: trunk/Source/WebKit/blackberry/ChangeLog (128187 => 128188)


--- trunk/Source/WebKit/blackberry/ChangeLog	2012-09-11 15:04:07 UTC (rev 128187)
+++ trunk/Source/WebKit/blackberry/ChangeLog	2012-09-11 15:08:43 UTC (rev 128188)
@@ -1,3 +1,19 @@
+2012-09-11  Nima Ghanavatian  <nghanavat...@rim.com>
+
+        [BlackBerry] Take account for single words that exceed our client character limit
+        https://bugs.webkit.org/show_bug.cgi?id=96389
+
+        Fix to the processing of long single-line text using getRangeForSpellCheckWithFineGranularity.
+        This was failing if a single word was longer than our maximum allowed limit.
+
+        Internally reviewed by Mike Fenton.
+
+        Reviewed by Rob Buis.
+
+        * WebKitSupport/InputHandler.cpp:
+        (WebKit):
+        (BlackBerry::WebKit::InputHandler::getRangeForSpellCheckWithFineGranularity):
+
 2012-09-11  Arvid Nilsson  <anils...@rim.com>
 
         [BlackBerry] SelectionHandler drops caret change notifications

Modified: trunk/Source/WebKit/blackberry/WebKitSupport/InputHandler.cpp (128187 => 128188)


--- trunk/Source/WebKit/blackberry/WebKitSupport/InputHandler.cpp	2012-09-11 15:04:07 UTC (rev 128187)
+++ trunk/Source/WebKit/blackberry/WebKitSupport/InputHandler.cpp	2012-09-11 15:08:43 UTC (rev 128188)
@@ -938,14 +938,24 @@
 PassRefPtr<Range> InputHandler::getRangeForSpellCheckWithFineGranularity(VisiblePosition startPosition, VisiblePosition endPosition)
 {
     VisiblePosition endOfCurrentWord = endOfWord(startPosition);
-    RefPtr<Range> rangeForSpellChecking;
-    while (endOfCurrentWord != endPosition) {
-        rangeForSpellChecking = VisibleSelection(startPosition, endOfCurrentWord).toNormalizedRange();
-        // If we exceed the MaxSpellCheckingStringLength limit, then go back one word and return this range.
-        if (rangeForSpellChecking->text().length() >= MaxSpellCheckingStringLength)
-            return VisibleSelection(startPosition, endOfWord(previousWordPosition(endOfCurrentWord))).toNormalizedRange();
 
-        endOfCurrentWord = endOfWord(nextWordPosition(endOfCurrentWord));
+    // Keep iterating until one of our cases is hit, or we've incremented the starting position right to the end.
+    while (startPosition != endPosition) {
+        // Check the text length within this range.
+        if (VisibleSelection(startPosition, endOfCurrentWord).toNormalizedRange()->text().length() >= MaxSpellCheckingStringLength) {
+            // If this is not the first word, return a Range with end boundary set to the previous word.
+            if (startOfWord(endOfCurrentWord, LeftWordIfOnBoundary) != startPosition)
+                return VisibleSelection(startPosition, endOfWord(previousWordPosition(endOfCurrentWord), LeftWordIfOnBoundary)).toNormalizedRange();
+
+            // Our first word has gone over the character limit. Increment the starting position past an uncheckable word.
+            startPosition = endOfCurrentWord;
+        } else if (endOfCurrentWord == endPosition) {
+            // Return the last segment if the end of our word lies at the end of the range.
+            return VisibleSelection(startPosition, endPosition).toNormalizedRange();
+        } else {
+            // Increment the current word.
+            endOfCurrentWord = endOfWord(nextWordPosition(endOfCurrentWord));
+        }
     }
     return 0;
 }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to