Redo spellchecking of a field if the layout has changed
[WebKit-https.git] / Source / WebKit / blackberry / WebCoreSupport / EditorClientBlackBerry.cpp
index 10867b1..cf0cccb 100644 (file)
@@ -33,6 +33,8 @@
 #include "Page.h"
 #include "PlatformKeyboardEvent.h"
 #include "SelectionHandler.h"
+#include "Settings.h"
+#include "SpellChecker.h"
 #include "WebPage_p.h"
 #include "WindowsKeyboardCodes.h"
 
@@ -67,23 +69,20 @@ bool EditorClientBlackBerry::shouldDeleteRange(Range* range)
     return true;
 }
 
-bool EditorClientBlackBerry::shouldShowDeleteInterface(HTMLElement*)
-{
-    notImplemented();
-    return false;
-}
-
 bool EditorClientBlackBerry::smartInsertDeleteEnabled()
 {
-    notImplemented();
-    return false;
+    Page* page = WebPagePrivate::core(m_webPagePrivate->m_webPage);
+    if (!page)
+        return false;
+    return page->settings()->smartInsertDeleteEnabled();
 }
 
 bool EditorClientBlackBerry::isSelectTrailingWhitespaceEnabled()
 {
-    if (m_webPagePrivate->m_dumpRenderTree)
-        return m_webPagePrivate->m_dumpRenderTree->isSelectTrailingWhitespaceEnabled();
-    return false;
+    Page* page = WebPagePrivate::core(m_webPagePrivate->m_webPage);
+    if (!page)
+        return false;
+    return page->settings()->selectTrailingWhitespaceEnabled();
 }
 
 void EditorClientBlackBerry::enableSpellChecking(bool enable)
@@ -110,7 +109,7 @@ bool EditorClientBlackBerry::shouldSpellCheckFocusedField()
 
     // If the field does not support autocomplete, do not do spellchecking.
     if (node->isElementNode()) {
-        const Element* element = static_cast<const Element*>(node);
+        const Element* element = toElement(node);
         if (element->hasTagName(HTMLNames::inputTag) && !DOMSupport::elementSupportsAutocomplete(element))
             return false;
     }
@@ -191,8 +190,12 @@ bool EditorClientBlackBerry::shouldChangeSelectedRange(Range* fromRange, Range*
 
     Frame* frame = m_webPagePrivate->focusedOrMainFrame();
     if (frame && frame->document()) {
-        if (frame->document()->focusedNode() && frame->document()->focusedNode()->hasTagName(HTMLNames::selectTag))
-            return false;
+        if (Node* focusedNode = frame->document()->focusedNode()) {
+            if (focusedNode->hasTagName(HTMLNames::selectTag))
+                return false;
+            if (focusedNode->isElementNode() && DOMSupport::isPopupInputField(toElement(focusedNode)))
+                return false;
+        }
 
         // Check if this change does not represent a focus change and input is active and if so ensure the keyboard is visible.
         if (m_webPagePrivate->m_inputHandler->isInputMode() && fromRange && toRange && (fromRange->startContainer() == toRange->startContainer()))
@@ -578,7 +581,8 @@ void EditorClientBlackBerry::checkGrammarOfString(const UChar*, int, WTF::Vector
 
 void EditorClientBlackBerry::requestCheckingOfString(PassRefPtr<TextCheckingRequest> testCheckingRequest)
 {
-    m_webPagePrivate->m_inputHandler->requestCheckingOfString(textCheckingRequest);
+    RefPtr<SpellCheckRequest> spellCheckRequest = static_cast<SpellCheckRequest*>(textCheckingRequest.get());
+    m_webPagePrivate->m_inputHandler->requestCheckingOfString(spellCheckRequest);
 }
 
 void EditorClientBlackBerry::checkTextOfParagraph(const UChar*, int, TextCheckingTypeMask, Vector<TextCheckingResult>&)