FocusController::setFocusedNode() should be setFocusedElement().
[WebKit-https.git] / Source / WebKit / blackberry / WebKitSupport / SelectionHandler.cpp
index 1390f0d..f5736f1 100644 (file)
@@ -891,8 +891,11 @@ void SelectionHandler::selectObject(const WebCore::IntPoint& location, TextGranu
     VisibleSelection selection = VisibleSelection(pointLocation, pointLocation);
 
     // Move focus to the new node if we're not selecting in old input field.
-    if (!m_webPage->m_inputHandler->boundingBoxForInputField().contains(relativePoint))
-        m_webPage->m_page->focusController()->setFocusedNode(selection.start().anchorNode(), focusedFrame);
+    if (!m_webPage->m_inputHandler->boundingBoxForInputField().contains(relativePoint)) {
+        Node* anchorNode = selection.start().anchorNode();
+        if (!anchorNode || anchorNode->isElementNode())
+            m_webPage->m_page->focusController()->setFocusedElement(toElement(anchorNode), focusedFrame);
+    }
 
     m_selectionActive = expandSelectionToGranularity(focusedFrame, selection, granularity, m_webPage->m_inputHandler->isInputMode());
 }