Title: [134616] trunk/Source/WebKit/blackberry
Revision
134616
Author
[email protected]
Date
2012-11-14 09:04:30 -0800 (Wed, 14 Nov 2012)

Log Message

[BlackBerry] Use mispelled-marker offsets relative to the element
https://bugs.webkit.org/show_bug.cgi?id=102236

Patch by Nima Ghanavatian <[email protected]> on 2012-11-14
Reviewed by Rob Buis.

DocumentMarker offsets are calculated relative to a node. This is causing
problems for contenteditable which can have numerous nodes. Creating a Range around a word
and calculating its location and length gives us the correct override in this case for starting
and ending points to pass to IMF.

Internally reviewed by Mike Fenton.

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

Modified Paths

Diff

Modified: trunk/Source/WebKit/blackberry/ChangeLog (134615 => 134616)


--- trunk/Source/WebKit/blackberry/ChangeLog	2012-11-14 16:53:06 UTC (rev 134615)
+++ trunk/Source/WebKit/blackberry/ChangeLog	2012-11-14 17:04:30 UTC (rev 134616)
@@ -1,3 +1,20 @@
+2012-11-14  Nima Ghanavatian  <[email protected]>
+
+        [BlackBerry] Use mispelled-marker offsets relative to the element
+        https://bugs.webkit.org/show_bug.cgi?id=102236
+
+        Reviewed by Rob Buis.
+
+        DocumentMarker offsets are calculated relative to a node. This is causing
+        problems for contenteditable which can have numerous nodes. Creating a Range around a word
+        and calculating its location and length gives us the correct override in this case for starting
+        and ending points to pass to IMF.
+
+        Internally reviewed by Mike Fenton.
+
+        * WebKitSupport/InputHandler.cpp:
+        (BlackBerry::WebKit::InputHandler::requestSpellingCheckingOptions):
+
 2012-11-13  Mike Fenton  <[email protected]>
 
         [BlackBerry] Fully restore both zoom and scroll when leaving an input field.

Modified: trunk/Source/WebKit/blackberry/WebKitSupport/InputHandler.cpp (134615 => 134616)


--- trunk/Source/WebKit/blackberry/WebKitSupport/InputHandler.cpp	2012-11-14 16:53:06 UTC (rev 134615)
+++ trunk/Source/WebKit/blackberry/WebKitSupport/InputHandler.cpp	2012-11-14 17:04:30 UTC (rev 134616)
@@ -750,6 +750,24 @@
     const WebCore::IntPoint scrollPosition = m_webPage->mainFrame()->view()->scrollPosition();
     caretRect.move(scrollPosition.x(), scrollPosition.y());
 
+    // Calculate the offset for contentEditable since the marker offsets are relative to the node.
+    // Get caret position. Though the spelling markers might no longer exist, if this method is called we can assume the caret was placed on top of a marker earlier.
+    VisiblePosition caretPosition = m_currentFocusElement->document()->frame()->selection()->selection().visibleStart();
+
+    // Create a range from the start to end of word.
+    RefPtr<Range> rangeSelection = VisibleSelection(startOfWord(caretPosition), endOfWord(caretPosition)).toNormalizedRange();
+    if (!rangeSelection)
+        return;
+
+    unsigned location = 0;
+    unsigned length = 0;
+    TextIterator::getLocationAndLengthFromRange(m_currentFocusElement.get(), rangeSelection.get(), location, length);
+
+    if (location != notFound && length) {
+        spellCheckingOptionRequest.startTextPosition = location;
+        spellCheckingOptionRequest.endTextPosition = location + length;
+    }
+
     InputLog(LogLevelInfo, "InputHandler::requestSpellingCheckingOptions caretRect topLeft=(%d,%d), bottomRight=(%d,%d), startTextPosition=%d, endTextPosition=%d"
                             , caretRect.minXMinYCorner().x(), caretRect.minXMinYCorner().y(), caretRect.maxXMaxYCorner().x(), caretRect.maxXMaxYCorner().y()
                             , spellCheckingOptionRequest.startTextPosition, spellCheckingOptionRequest.endTextPosition);
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to