[BlackBerry] Switch to point instead of VisiblePosition comparison for input bounds...
authormifenton@rim.com <mifenton@rim.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 21 Nov 2012 19:52:47 +0000 (19:52 +0000)
committermifenton@rim.com <mifenton@rim.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 21 Nov 2012 19:52:47 +0000 (19:52 +0000)
https://bugs.webkit.org/show_bug.cgi?id=102962

Reviewed by Rob Buis.

PR 247270.

Switch from using VisiblePosition to determine if we are in a node
to a comparison of the field bounds.  This fixes the case where
there is no node before the target node to match.

Reviewed Internally by Gen Mak.

* WebKitSupport/DOMSupport.cpp:
* WebKitSupport/DOMSupport.h:
* WebKitSupport/SelectionHandler.cpp:
(BlackBerry::WebKit::SelectionHandler::setCaretPosition):

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

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

index 3b975c2..e9f877e 100644 (file)
@@ -1,3 +1,23 @@
+2012-11-21  Mike Fenton  <mifenton@rim.com>
+
+        [BlackBerry] Switch to point instead of VisiblePosition comparison for input bounds check
+        https://bugs.webkit.org/show_bug.cgi?id=102962
+
+        Reviewed by Rob Buis.
+
+        PR 247270.
+
+        Switch from using VisiblePosition to determine if we are in a node
+        to a comparison of the field bounds.  This fixes the case where
+        there is no node before the target node to match.
+
+        Reviewed Internally by Gen Mak.
+
+        * WebKitSupport/DOMSupport.cpp:
+        * WebKitSupport/DOMSupport.h:
+        * WebKitSupport/SelectionHandler.cpp:
+        (BlackBerry::WebKit::SelectionHandler::setCaretPosition):
+
 2012-11-20  Andrew Lo  <anlo@rim.com>
 
         [BlackBerry] Animated gifs pause on scroll or zoom and sometimes don't resume after scroll or zoom completes
index 1d81a5e..752c573 100644 (file)
@@ -314,34 +314,6 @@ VisibleSelection visibleSelectionForRangeInputElement(Element* element, int star
     return VisibleSelection(visibleStart, visibleEnd);
 }
 
-Node* DOMContainerNodeForPosition(const Position& position)
-{
-    Node* nodeAtPos = position.containerNode();
-    if (nodeAtPos && nodeAtPos->isInShadowTree())
-        nodeAtPos = nodeAtPos->shadowAncestorNode();
-
-    return nodeAtPos;
-}
-
-bool isPositionInNode(Node* node, const Position& position)
-{
-    if (!node)
-        return false;
-
-    Node* domNodeAtPos = DOMContainerNodeForPosition(position);
-    if (!domNodeAtPos)
-        return false;
-
-    int offset = 0;
-    if (domNodeAtPos == position.containerNode())
-        offset = position.computeOffsetInContainerNode();
-
-    RefPtr<Range> rangeForNode = rangeOfContents(node);
-    int ec;
-
-    return rangeForNode->isPointInRange(domNodeAtPos, offset, ec);
-}
-
 static bool matchesReservedStringEmail(const AtomicString& string)
 {
     return string.contains("email", false /* caseSensitive */);
index a86e12a..74175ec 100644 (file)
@@ -76,9 +76,6 @@ void visibleTextQuads(const WebCore::VisibleSelection&, WTF::Vector<WebCore::Flo
 WebCore::VisibleSelection visibleSelectionForRangeInputElement(WebCore::Element*, int start, int end);
 WebCore::VisibleSelection visibleSelectionForInputElement(WebCore::Element*);
 
-WebCore::Node* DOMContainerNodeForPosition(const WebCore::Position&);
-bool isPositionInNode(WebCore::Node*, const WebCore::Position&);
-
 bool elementIdOrNameIndicatesNoAutocomplete(const WebCore::Element*);
 bool elementIdOrNameIndicatesEmail(const WebCore::HTMLInputElement*);
 bool elementIdOrNameIndicatesUrl(const WebCore::HTMLInputElement*);
index fcd2e7e..1b89071 100644 (file)
@@ -253,14 +253,17 @@ void SelectionHandler::setCaretPosition(const WebCore::IntPoint &position)
 
     VisiblePosition visibleCaretPosition(focusedFrame->visiblePositionForPoint(relativePoint));
 
-    if (!DOMSupport::isPositionInNode(m_webPage->focusedOrMainFrame()->document()->focusedNode(), visibleCaretPosition.deepEquivalent())) {
-        if (unsigned short character = directionOfPointRelativeToRect(relativePoint, currentCaretRect))
-            m_webPage->m_inputHandler->handleKeyboardInput(Platform::KeyboardEvent(character));
-
-        // Send the selection changed in case this does not trigger a selection change to
-        // ensure the caret position is accurate. This may be a duplicate event.
-        selectionPositionChanged(true /* forceUpdateWithoutChange */);
-        return;
+    if (RenderObject* focusedRenderer = focusedFrame->document()->focusedNode()->renderer()) {
+        WebCore::IntRect nodeOutlineBounds(focusedRenderer->absoluteOutlineBounds());
+        if (!nodeOutlineBounds.contains(relativePoint)) {
+            if (unsigned short character = directionOfPointRelativeToRect(relativePoint, currentCaretRect))
+                m_webPage->m_inputHandler->handleKeyboardInput(Platform::KeyboardEvent(character));
+
+            // Send the selection changed in case this does not trigger a selection change to
+            // ensure the caret position is accurate. This may be a duplicate event.
+            selectionPositionChanged(true /* forceUpdateWithoutChange */);
+            return;
+        }
     }
 
     VisibleSelection newSelection(visibleCaretPosition);