[BlackBerry] Validation of Last Fat Finger result is needed for selection.
authormifenton@rim.com <mifenton@rim.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 18 May 2012 21:50:47 +0000 (21:50 +0000)
committermifenton@rim.com <mifenton@rim.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 18 May 2012 21:50:47 +0000 (21:50 +0000)
https://bugs.webkit.org/show_bug.cgi?id=86888

Reviewed by Antonio Gomes.

PR 128393.

Cached FatFingersResults must be validatible against
the desired request to ensure the result is both for
the same point and of the same type.

* WebKitSupport/FatFingers.h:
(WebKit):
(FatFingersResult):
(BlackBerry::WebKit::FatFingersResult::FatFingersResult):
(BlackBerry::WebKit::FatFingersResult::reset):
(BlackBerry::WebKit::FatFingersResult::resultMatches):
(BlackBerry::WebKit::FatFingersResult::originPosition):
(BlackBerry::WebKit::FatFingersResult::adjustedPosition):
(BlackBerry::WebKit::FatFingersResult::positionWasAdjusted):
(BlackBerry::WebKit::FatFingersResult::isTextInput):
(BlackBerry::WebKit::FatFingersResult::isValid):
(BlackBerry::WebKit::FatFingersResult::node):
(BlackBerry::WebKit::FatFingersResult::nodeAsElementIfApplicable):
* WebKitSupport/SelectionHandler.cpp:
(BlackBerry::WebKit::SelectionHandler::selectAtPoint):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@117638 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit/blackberry/ChangeLog
Source/WebKit/blackberry/WebKitSupport/FatFingers.h
Source/WebKit/blackberry/WebKitSupport/SelectionHandler.cpp

index ecc459a..a6041bf 100644 (file)
@@ -1,3 +1,32 @@
+2012-05-18  Mike Fenton  <mifenton@rim.com>
+
+        [BlackBerry] Validation of Last Fat Finger result is needed for selection.
+        https://bugs.webkit.org/show_bug.cgi?id=86888
+
+        Reviewed by Antonio Gomes.
+
+        PR 128393.
+
+        Cached FatFingersResults must be validatible against
+        the desired request to ensure the result is both for
+        the same point and of the same type.
+
+        * WebKitSupport/FatFingers.h:
+        (WebKit):
+        (FatFingersResult):
+        (BlackBerry::WebKit::FatFingersResult::FatFingersResult):
+        (BlackBerry::WebKit::FatFingersResult::reset):
+        (BlackBerry::WebKit::FatFingersResult::resultMatches):
+        (BlackBerry::WebKit::FatFingersResult::originPosition):
+        (BlackBerry::WebKit::FatFingersResult::adjustedPosition):
+        (BlackBerry::WebKit::FatFingersResult::positionWasAdjusted):
+        (BlackBerry::WebKit::FatFingersResult::isTextInput):
+        (BlackBerry::WebKit::FatFingersResult::isValid):
+        (BlackBerry::WebKit::FatFingersResult::node):
+        (BlackBerry::WebKit::FatFingersResult::nodeAsElementIfApplicable):
+        * WebKitSupport/SelectionHandler.cpp:
+        (BlackBerry::WebKit::SelectionHandler::selectAtPoint):
+
 2012-05-18  MORITA Hajime  <morrita@google.com>
 
         https://bugs.webkit.org/show_bug.cgi?id=85515
index cb31f97..f872e8a 100644 (file)
@@ -45,77 +45,9 @@ namespace BlackBerry {
 namespace WebKit {
 
 class WebPagePrivate;
-class FatFingers;
+class FatFingersResult;
 class TouchEventHandler;
 
-class FatFingersResult {
-public:
-
-    FatFingersResult(const WebCore::IntPoint& p = WebCore::IntPoint::zero())
-        : m_originalPosition(p)
-        , m_adjustedPosition(p)
-        , m_positionWasAdjusted(false)
-        , m_isTextInput(false)
-        , m_isValid(false)
-        , m_nodeUnderFatFinger(0)
-    {
-    }
-
-    void reset()
-    {
-        m_originalPosition = m_adjustedPosition = WebCore::IntPoint::zero();
-        m_positionWasAdjusted = false;
-        m_isTextInput = false;
-        m_isValid = false;
-        m_nodeUnderFatFinger = 0;
-    }
-
-    WebCore::IntPoint originPosition() const { return m_originalPosition; }
-    WebCore::IntPoint adjustedPosition() const { return m_adjustedPosition; }
-    bool positionWasAdjusted() const { return m_isValid && m_positionWasAdjusted; }
-    bool isTextInput() const { return m_isValid && !!m_nodeUnderFatFinger && m_isTextInput; }
-    bool isValid() const { return m_isValid; }
-
-    enum ContentType { ShadowContentAllowed, ShadowContentNotAllowed };
-
-    WebCore::Node* node(ContentType type = ShadowContentAllowed) const
-    {
-        if (!m_nodeUnderFatFinger || !m_nodeUnderFatFinger->inDocument())
-            return 0;
-
-        WebCore::Node* result = m_nodeUnderFatFinger.get();
-
-        if (type == ShadowContentAllowed)
-            return result;
-
-        // Shadow trees can be nested.
-        while (result->isInShadowTree())
-            result = toElement(result->shadowAncestorNode());
-
-        return result;
-    }
-
-    WebCore::Element* nodeAsElementIfApplicable(ContentType type = ShadowContentAllowed) const
-    {
-        WebCore::Node* result = node(type);
-        if (!result || !result->isElementNode())
-            return 0;
-
-        return static_cast<WebCore::Element*>(result);
-    }
-
-private:
-    friend class WebKit::FatFingers;
-    friend class WebKit::TouchEventHandler;
-
-    WebCore::IntPoint m_originalPosition; // Main frame contents coordinates.
-    WebCore::IntPoint m_adjustedPosition; // Main frame contents coordinates.
-    bool m_positionWasAdjusted;
-    bool m_isTextInput; // Check if the element under the touch point will require a VKB be displayed so that
-                        // the touch down can be suppressed.
-    bool m_isValid;
-    RefPtr<WebCore::Node> m_nodeUnderFatFinger;
-};
 
 class FatFingers {
 public:
@@ -184,6 +116,82 @@ private:
     CachedRectHitTestResults m_cachedRectHitTestResults;
 };
 
+class FatFingersResult {
+public:
+
+    FatFingersResult(const WebCore::IntPoint& p = WebCore::IntPoint::zero(), const FatFingers::TargetType targetType = FatFingers::ClickableElement)
+        : m_originalPosition(p)
+        , m_adjustedPosition(p)
+        , m_targetType(targetType)
+        , m_positionWasAdjusted(false)
+        , m_isTextInput(false)
+        , m_isValid(false)
+        , m_nodeUnderFatFinger(0)
+    {
+    }
+
+    void reset()
+    {
+        m_originalPosition = m_adjustedPosition = WebCore::IntPoint::zero();
+        m_positionWasAdjusted = false;
+        m_isTextInput = false;
+        m_isValid = false;
+        m_nodeUnderFatFinger = 0;
+    }
+
+    bool resultMatches(const WebCore::IntPoint& p, const FatFingers::TargetType targetType) const
+    {
+        return m_isValid && p == m_originalPosition && targetType == m_targetType;
+    }
+
+    WebCore::IntPoint originPosition() const { return m_originalPosition; }
+    WebCore::IntPoint adjustedPosition() const { return m_adjustedPosition; }
+    bool positionWasAdjusted() const { return m_isValid && m_positionWasAdjusted; }
+    bool isTextInput() const { return m_isValid && !!m_nodeUnderFatFinger && m_isTextInput; }
+    bool isValid() const { return m_isValid; }
+
+    enum ContentType { ShadowContentAllowed, ShadowContentNotAllowed };
+
+    WebCore::Node* node(ContentType type = ShadowContentAllowed) const
+    {
+        if (!m_nodeUnderFatFinger || !m_nodeUnderFatFinger->inDocument())
+            return 0;
+
+        WebCore::Node* result = m_nodeUnderFatFinger.get();
+
+        if (type == ShadowContentAllowed)
+            return result;
+
+        // Shadow trees can be nested.
+        while (result->isInShadowTree())
+            result = toElement(result->shadowAncestorNode());
+
+        return result;
+    }
+
+    WebCore::Element* nodeAsElementIfApplicable(ContentType type = ShadowContentAllowed) const
+    {
+        WebCore::Node* result = node(type);
+        if (!result || !result->isElementNode())
+            return 0;
+
+        return static_cast<WebCore::Element*>(result);
+    }
+
+private:
+    friend class WebKit::FatFingers;
+    friend class WebKit::TouchEventHandler;
+
+    WebCore::IntPoint m_originalPosition; // Main frame contents coordinates.
+    WebCore::IntPoint m_adjustedPosition; // Main frame contents coordinates.
+    FatFingers::TargetType m_targetType;
+    bool m_positionWasAdjusted;
+    bool m_isTextInput; // Check if the element under the touch point will require a VKB be displayed so that
+                        // the touch down can be suppressed.
+    bool m_isValid;
+    RefPtr<WebCore::Node> m_nodeUnderFatFinger;
+};
+
 }
 }
 
index ac63433..351f527 100644 (file)
@@ -554,7 +554,7 @@ void SelectionHandler::selectAtPoint(const WebCore::IntPoint& location)
     WebCore::IntPoint targetPosition;
     // FIXME: Factory this get right fat finger code into a helper.
     const FatFingersResult lastFatFingersResult = m_webPage->m_touchEventHandler->lastFatFingersResult();
-    if (lastFatFingersResult.positionWasAdjusted() && lastFatFingersResult.nodeAsElementIfApplicable()) {
+    if (lastFatFingersResult.resultMatches(location, FatFingers::Text) && lastFatFingersResult.positionWasAdjusted() && lastFatFingersResult.nodeAsElementIfApplicable()) {
         targetNode = lastFatFingersResult.node(FatFingersResult::ShadowContentNotAllowed);
         targetPosition = lastFatFingersResult.adjustedPosition();
     } else {