Title: [133902] trunk/Source/WebKit/blackberry
Revision
133902
Author
[email protected]
Date
2012-11-08 08:24:07 -0800 (Thu, 08 Nov 2012)

Log Message

[BlackBerry] Verify touched element using the rootEditableElement
https://bugs.webkit.org/show_bug.cgi?id=101510

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

Reviewed internally by Mike Fenton.

Move up the tree until we find the rootEditableElement and use
that to compare with the touched element.

* WebKitSupport/FatFingers.h:
(BlackBerry::WebKit::FatFingersResult::node):
(BlackBerry::WebKit::FatFingersResult::nodeAsElementIfApplicable):
* WebKitSupport/InputHandler.cpp:
(BlackBerry::WebKit::InputHandler::shouldRequestSpellCheckingOptionsForPoint):
* WebKitSupport/TouchEventHandler.cpp:
(BlackBerry::WebKit::TouchEventHandler::handleTouchPoint):

Modified Paths

Diff

Modified: trunk/Source/WebKit/blackberry/ChangeLog (133901 => 133902)


--- trunk/Source/WebKit/blackberry/ChangeLog	2012-11-08 15:43:36 UTC (rev 133901)
+++ trunk/Source/WebKit/blackberry/ChangeLog	2012-11-08 16:24:07 UTC (rev 133902)
@@ -1,3 +1,23 @@
+2012-11-08  Nima Ghanavatian  <[email protected]>
+
+        [BlackBerry] Verify touched element using the rootEditableElement
+        https://bugs.webkit.org/show_bug.cgi?id=101510
+
+        Reviewed by Rob Buis.
+
+        Reviewed internally by Mike Fenton.
+
+        Move up the tree until we find the rootEditableElement and use
+        that to compare with the touched element.
+
+        * WebKitSupport/FatFingers.h:
+        (BlackBerry::WebKit::FatFingersResult::node):
+        (BlackBerry::WebKit::FatFingersResult::nodeAsElementIfApplicable):
+        * WebKitSupport/InputHandler.cpp:
+        (BlackBerry::WebKit::InputHandler::shouldRequestSpellCheckingOptionsForPoint):
+        * WebKitSupport/TouchEventHandler.cpp:
+        (BlackBerry::WebKit::TouchEventHandler::handleTouchPoint):
+
 2012-11-07  Rob Buis  <[email protected]>
 
         [BlackBerry] Remove setUserStyleSheetString/userStyleSheetString

Modified: trunk/Source/WebKit/blackberry/WebKitSupport/FatFingers.h (133901 => 133902)


--- trunk/Source/WebKit/blackberry/WebKitSupport/FatFingers.h	2012-11-08 15:43:36 UTC (rev 133901)
+++ trunk/Source/WebKit/blackberry/WebKitSupport/FatFingers.h	2012-11-08 16:24:07 UTC (rev 133902)
@@ -149,7 +149,7 @@
 
     enum ContentType { ShadowContentAllowed, ShadowContentNotAllowed };
 
-    WebCore::Node* node(ContentType type = ShadowContentAllowed) const
+    WebCore::Node* node(ContentType type = ShadowContentAllowed, bool shouldUseRootEditableElement = false) const
     {
         if (!m_nodeUnderFatFinger || !m_nodeUnderFatFinger->inDocument())
             return 0;
@@ -163,12 +163,23 @@
         while (result->isInShadowTree())
             result = toElement(result->shadowAncestorNode());
 
+        if (!shouldUseRootEditableElement || !result->isElementNode())
+            return result;
+
+        // Retrieve the top level editable node
+        while (!result->isRootEditableElement()) {
+            WebCore::Element* parentElement = result->parentElement();
+            if (!parentElement)
+                break;
+            result = parentElement;
+        }
+
         return result;
     }
 
-    WebCore::Element* nodeAsElementIfApplicable(ContentType type = ShadowContentAllowed) const
+    WebCore::Element* nodeAsElementIfApplicable(ContentType type = ShadowContentAllowed, bool shouldUseRootEditableElement = false) const
     {
-        WebCore::Node* result = node(type);
+        WebCore::Node* result = node(type, shouldUseRootEditableElement);
         if (!result || !result->isElementNode())
             return 0;
 

Modified: trunk/Source/WebKit/blackberry/WebKitSupport/InputHandler.cpp (133901 => 133902)


--- trunk/Source/WebKit/blackberry/WebKitSupport/InputHandler.cpp	2012-11-08 15:43:36 UTC (rev 133901)
+++ trunk/Source/WebKit/blackberry/WebKitSupport/InputHandler.cpp	2012-11-08 16:24:07 UTC (rev 133902)
@@ -699,13 +699,27 @@
 
 bool InputHandler::shouldRequestSpellCheckingOptionsForPoint(Platform::IntPoint& point, const Element* touchedElement, imf_sp_text_t& spellCheckingOptionRequest)
 {
-    if (!isActiveTextEdit() || touchedElement != m_currentFocusElement)
+    if (!isActiveTextEdit())
         return false;
 
+    Element* currentFocusElement = m_currentFocusElement.get();
+    if (!currentFocusElement || !currentFocusElement->isElementNode())
+        return false;
+
+    while (!currentFocusElement->isRootEditableElement()) {
+        Element* parentElement = currentFocusElement->parentElement();
+        if (!parentElement)
+            break;
+        currentFocusElement = parentElement;
+    }
+
+    if (touchedElement != 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();
+    Document* document = currentFocusElement->document();
     ASSERT(document);
 
     RenderedDocumentMarker* marker = document->markers()->renderedMarkerContainingPoint(contentPos, DocumentMarker::Spelling);

Modified: trunk/Source/WebKit/blackberry/WebKitSupport/TouchEventHandler.cpp (133901 => 133902)


--- trunk/Source/WebKit/blackberry/WebKitSupport/TouchEventHandler.cpp	2012-11-08 15:43:36 UTC (rev 133901)
+++ trunk/Source/WebKit/blackberry/WebKitSupport/TouchEventHandler.cpp	2012-11-08 16:24:07 UTC (rev 133902)
@@ -239,7 +239,7 @@
 
             if (m_lastFatFingersResult.isTextInput())
                 shouldRequestSpellCheckOptions = m_webPage->m_inputHandler->shouldRequestSpellCheckingOptionsForPoint(point.m_pos
-                                                                                                                      , m_lastFatFingersResult.nodeAsElementIfApplicable(FatFingersResult::ShadowContentNotAllowed)
+                                                                                                                      , m_lastFatFingersResult.nodeAsElementIfApplicable(FatFingersResult::ShadowContentNotAllowed, true /* shouldUseRootEditableElement */)
                                                                                                                       , spellCheckOptionRequest);
 
             // Apply any suppressed changes. This does not eliminate the need
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to