Title: [125441] trunk/Source/WebKit/blackberry
Revision
125441
Author
[email protected]
Date
2012-08-13 13:23:38 -0700 (Mon, 13 Aug 2012)

Log Message

[BlackBerry] Update API for spell checking suggestions again.
https://bugs.webkit.org/show_bug.cgi?id=93877

Reviewed by Antonio Gomes.

PR 163283.

Update the spell checking options request API
to include the caret positions.

Reviewed internally by Nima Ghanavatian.

* Api/WebPageClient.h:
* WebKitSupport/InputHandler.cpp:
(BlackBerry::WebKit::InputHandler::shouldRequestSpellCheckingOptionsForPoint):
(WebKit):
(BlackBerry::WebKit::InputHandler::requestSpellingCheckingOptions):
* WebKitSupport/InputHandler.h:
(Platform):
(InputHandler):
* WebKitSupport/TouchEventHandler.cpp:
(BlackBerry::WebKit::TouchEventHandler::handleTouchPoint):
* WebKitSupport/TouchEventHandler.h:
(TouchEventHandler):

Modified Paths

Diff

Modified: trunk/Source/WebKit/blackberry/Api/WebPageClient.h (125440 => 125441)


--- trunk/Source/WebKit/blackberry/Api/WebPageClient.h	2012-08-13 20:17:57 UTC (rev 125440)
+++ trunk/Source/WebKit/blackberry/Api/WebPageClient.h	2012-08-13 20:23:38 UTC (rev 125441)
@@ -26,6 +26,7 @@
 #include <BlackBerryPlatformInputEvents.h>
 #include <BlackBerryPlatformNavigationType.h>
 #include <BlackBerryPlatformPrimitives.h>
+#include <imf/events.h>
 #include <interaction/ScrollViewBase.h>
 #include <vector>
 
@@ -144,7 +145,7 @@
 
     virtual void showVirtualKeyboard(bool) = 0;
 
-    virtual void requestSpellingSuggestionsForString(unsigned start, unsigned end) = 0;
+    virtual void requestSpellingCheckingOptions(imf_sp_text_t&) = 0;
     virtual int32_t checkSpellingOfStringAsync(wchar_t* text, int length) = 0;
 
     virtual void notifySelectionDetailsChanged(const Platform::IntRect& start, const Platform::IntRect& end, const Platform::IntRectRegion&, bool overrideTouchHandling = false) = 0;

Modified: trunk/Source/WebKit/blackberry/ChangeLog (125440 => 125441)


--- trunk/Source/WebKit/blackberry/ChangeLog	2012-08-13 20:17:57 UTC (rev 125440)
+++ trunk/Source/WebKit/blackberry/ChangeLog	2012-08-13 20:23:38 UTC (rev 125441)
@@ -1,3 +1,30 @@
+2012-08-13  Mike Fenton  <[email protected]>
+
+        [BlackBerry] Update API for spell checking suggestions again.
+        https://bugs.webkit.org/show_bug.cgi?id=93877
+
+        Reviewed by Antonio Gomes.
+
+        PR 163283.
+
+        Update the spell checking options request API
+        to include the caret positions.
+
+        Reviewed internally by Nima Ghanavatian.
+
+        * Api/WebPageClient.h:
+        * WebKitSupport/InputHandler.cpp:
+        (BlackBerry::WebKit::InputHandler::shouldRequestSpellCheckingOptionsForPoint):
+        (WebKit):
+        (BlackBerry::WebKit::InputHandler::requestSpellingCheckingOptions):
+        * WebKitSupport/InputHandler.h:
+        (Platform):
+        (InputHandler):
+        * WebKitSupport/TouchEventHandler.cpp:
+        (BlackBerry::WebKit::TouchEventHandler::handleTouchPoint):
+        * WebKitSupport/TouchEventHandler.h:
+        (TouchEventHandler):
+
 2012-08-13  Antonio Gomes  <[email protected]>
 
         [BlackBerry] Rounding error somewhere when translating CompositingLayer 's for in-region scrolling

Modified: trunk/Source/WebKit/blackberry/WebKitSupport/InputHandler.cpp (125440 => 125441)


--- trunk/Source/WebKit/blackberry/WebKitSupport/InputHandler.cpp	2012-08-13 20:17:57 UTC (rev 125440)
+++ trunk/Source/WebKit/blackberry/WebKitSupport/InputHandler.cpp	2012-08-13 20:23:38 UTC (rev 125441)
@@ -50,6 +50,7 @@
 #include "RenderText.h"
 #include "RenderTextControl.h"
 #include "RenderWidget.h"
+#include "RenderedDocumentMarker.h"
 #include "ScopePointer.h"
 #include "SelectPopupClient.h"
 #include "SelectionHandler.h"
@@ -64,11 +65,11 @@
 #include <BlackBerryPlatformLog.h>
 #include <BlackBerryPlatformMisc.h>
 #include <BlackBerryPlatformSettings.h>
-#include <imf/events.h>
 #include <sys/keycodes.h>
 
 #define ENABLE_INPUT_LOG 0
 #define ENABLE_FOCUS_LOG 0
+#define ENABLE_SPELLING_LOG 0
 
 static const unsigned MaxLearnTextDataSize = 500;
 
@@ -87,6 +88,12 @@
 #define FocusLog(severity, format, ...)
 #endif // ENABLE_FOCUS_LOG
 
+#if ENABLE_SPELLING_LOG
+#define SpellingLog(severity, format, ...) logAlways(severity, format, ## __VA_ARGS__)
+#else
+#define SpellingLog(severity, format, ...)
+#endif // ENABLE_SPELLING_LOG
+
 namespace BlackBerry {
 namespace WebKit {
 
@@ -648,6 +655,50 @@
     return 0;
 }
 
+bool InputHandler::shouldRequestSpellCheckingOptionsForPoint(Platform::IntPoint& point, const Element* touchedElement, imf_sp_text_t& spellCheckingOptionRequest)
+{
+    if (!isActiveTextEdit() || touchedElement != m_currentFocusElement)
+        return false;
+
+    LayoutPoint contentPos(m_webPage->mapFromViewportToContents(point));
+    contentPos = DOMSupport::convertPointToFrame(m_webPage->mainFrame(), m_webPage->focusedOrMainFrame(), roundedIntPoint(contentPos));
+
+    Document* document = m_currentFocusElement->document();
+    ASSERT(document);
+
+    RenderedDocumentMarker* marker = document->markers()->renderedMarkerContainingPoint(contentPos, DocumentMarker::Spelling);
+    if (!marker)
+        return false;
+
+    SpellingLog(LogLevelInfo, "InputHandler::shouldRequestSpellCheckingOptionsForPoint Found spelling marker at point %d, %d", point.x(), point.y());
+
+    // imf_sp_text_t should be generated in pixel viewport coordinates.
+    WebCore::IntRect rect = m_webPage->mapToTransformed(m_webPage->focusedOrMainFrame()->view()->contentsToWindow(enclosingIntRect(marker->renderedRect())));
+    m_webPage->clipToTransformedContentsRect(rect);
+
+    // TODO use the actual caret position after it is placed.
+    spellCheckingOptionRequest.caret_rect.caret_top_x = point.x();
+    spellCheckingOptionRequest.caret_rect.caret_top_y = rect.y();
+    spellCheckingOptionRequest.caret_rect.caret_bottom_x = point.x();
+    spellCheckingOptionRequest.caret_rect.caret_bottom_y = rect.y() + rect.height();
+    spellCheckingOptionRequest.startTextPosition = marker->startOffset();
+    spellCheckingOptionRequest.endTextPosition = marker->endOffset();
+
+    return true;
+}
+
+void InputHandler::requestSpellingCheckingOptions(imf_sp_text_t& spellCheckingOptionRequest)
+{
+    SpellingLog(LogLevelInfo, "InputHandler::requestSpellingCheckingOptions Sending request:\ncaret_rect.caret_top_x = %d\ncaret_rect.caret_top_y = %d" \
+                              "\ncaret_rect.caret_bottom_x = %d\ncaret_rect.caret_bottom_y = %d\nstartTextPosition = %d\nendTextPosition = %d",
+                              spellCheckingOptionRequest.caret_rect.caret_top_x, spellCheckingOptionRequest.caret_rect.caret_top_y,
+                              spellCheckingOptionRequest.caret_rect.caret_bottom_x, spellCheckingOptionRequest.caret_rect.caret_bottom_y,
+                              spellCheckingOptionRequest.startTextPosition, spellCheckingOptionRequest.endTextPosition);
+
+    if (spellCheckingOptionRequest.startTextPosition || spellCheckingOptionRequest.endTextPosition)
+        m_webPage->m_client->requestSpellingCheckingOptions(spellCheckingOptionRequest);
+}
+
 void InputHandler::setElementUnfocused(bool refocusOccuring)
 {
     if (isActiveTextEdit()) {

Modified: trunk/Source/WebKit/blackberry/WebKitSupport/InputHandler.h (125440 => 125441)


--- trunk/Source/WebKit/blackberry/WebKitSupport/InputHandler.h	2012-08-13 20:17:57 UTC (rev 125440)
+++ trunk/Source/WebKit/blackberry/WebKitSupport/InputHandler.h	2012-08-13 20:23:38 UTC (rev 125441)
@@ -21,6 +21,7 @@
 
 #include <BlackBerryPlatformInputEvents.h>
 
+#include <imf/events.h>
 #include <imf/input_data.h>
 #include <map>
 #include <wtf/RefPtr.h>
@@ -44,6 +45,7 @@
 namespace BlackBerry {
 
 namespace Platform {
+class IntPoint;
 class KeyboardEvent;
 }
 
@@ -128,6 +130,9 @@
     void spellCheckingRequestProcessed(int32_t transactionId, spannable_string_t*);
     void spellCheckingRequestCancelled(int32_t id, bool isSequenceId = false);
 
+    bool shouldRequestSpellCheckingOptionsForPoint(Platform::IntPoint&, const WebCore::Element*, imf_sp_text_t&);
+    void requestSpellingCheckingOptions(imf_sp_text_t&);
+
 private:
     enum PendingKeyboardStateChange { NoChange, Visible, NotVisible };
 

Modified: trunk/Source/WebKit/blackberry/WebKitSupport/TouchEventHandler.cpp (125440 => 125441)


--- trunk/Source/WebKit/blackberry/WebKitSupport/TouchEventHandler.cpp	2012-08-13 20:17:57 UTC (rev 125440)
+++ trunk/Source/WebKit/blackberry/WebKitSupport/TouchEventHandler.cpp	2012-08-13 20:23:38 UTC (rev 125441)
@@ -42,7 +42,6 @@
 #include "RenderLayer.h"
 #include "RenderTheme.h"
 #include "RenderView.h"
-#include "RenderedDocumentMarker.h"
 #include "SelectionHandler.h"
 #include "WebPage_p.h"
 #include "WebTapHighlight.h"
@@ -214,7 +213,12 @@
         }
     case Platform::TouchPoint::TouchReleased:
         {
-            unsigned spellLength = spellCheck(point);
+            imf_sp_text_t spellCheckOptionRequest;
+            bool shouldRequestSpellCheckOptions = false;
+
+            if (m_lastFatFingersResult.isTextInput())
+                shouldRequestSpellCheckOptions = m_webPage->m_inputHandler->shouldRequestSpellCheckingOptionsForPoint(point.m_pos, m_lastFatFingersResult.nodeAsElementIfApplicable(), spellCheckOptionRequest);
+
             // Apply any suppressed changes. This does not eliminate the need
             // for the show after the handling of fat finger pressed as it may
             // have triggered a state change.
@@ -240,11 +244,8 @@
             PlatformMouseEvent mouseEvent(adjustedPoint, m_lastScreenPoint, PlatformEvent::MouseReleased, 1, LeftButton, TouchScreen);
             m_webPage->handleMouseEvent(mouseEvent);
             m_lastFatFingersResult.reset(); // Reset the fat finger result as its no longer valid when a user's finger is not on the screen.
-            if (spellLength) {
-                unsigned end = m_webPage->m_inputHandler->caretPosition();
-                unsigned start = end - spellLength;
-                m_webPage->m_client->requestSpellingSuggestionsForString(start, end);
-            }
+            if (shouldRequestSpellCheckOptions)
+                m_webPage->m_inputHandler->requestSpellingCheckingOptions(spellCheckOptionRequest);
             return true;
         }
     case Platform::TouchPoint::TouchMoved:
@@ -264,31 +265,6 @@
     return false;
 }
 
-unsigned TouchEventHandler::spellCheck(Platform::TouchPoint& touchPoint)
-{
-    Element* elementUnderFatFinger = m_lastFatFingersResult.nodeAsElementIfApplicable();
-    if (!m_lastFatFingersResult.isTextInput() || !elementUnderFatFinger)
-        return 0;
-
-    LayoutPoint contentPos(m_webPage->mapFromViewportToContents(touchPoint.m_pos));
-    contentPos = DOMSupport::convertPointToFrame(m_webPage->mainFrame(), m_webPage->focusedOrMainFrame(), contentPos);
-
-    Document* document = elementUnderFatFinger->document();
-    ASSERT(document);
-    RenderedDocumentMarker* marker = document->markers()->renderedMarkerContainingPoint(contentPos, DocumentMarker::Spelling);
-    if (!marker)
-        return 0;
-
-    IntRect rect = marker->renderedRect();
-    LayoutPoint newContentPos = LayoutPoint(rect.x() + rect.width(), rect.y() + rect.height() / 2);
-    Frame* frame = m_webPage->focusedOrMainFrame();
-    if (frame != m_webPage->mainFrame())
-        newContentPos = m_webPage->mainFrame()->view()->windowToContents(frame->view()->contentsToWindow(newContentPos));
-    m_lastFatFingersResult.m_adjustedPosition = newContentPos;
-    m_lastFatFingersResult.m_positionWasAdjusted = true;
-    return marker->endOffset() - marker->startOffset();
-}
-
 void TouchEventHandler::handleFatFingerPressed()
 {
     if (!m_didCancelTouch) {

Modified: trunk/Source/WebKit/blackberry/WebKitSupport/TouchEventHandler.h (125440 => 125441)


--- trunk/Source/WebKit/blackberry/WebKitSupport/TouchEventHandler.h	2012-08-13 20:17:57 UTC (rev 125440)
+++ trunk/Source/WebKit/blackberry/WebKitSupport/TouchEventHandler.h	2012-08-13 20:23:38 UTC (rev 125441)
@@ -45,7 +45,6 @@
     void resetLastFatFingersResult() { m_lastFatFingersResult.reset(); }
 
 private:
-    unsigned spellCheck(Platform::TouchPoint&);
     void handleFatFingerPressed();
 
     void drawTapHighlight();
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to