Bug 906979 - Make it possible again to force spell checking on text controls with spellcheck=false. r=roc, a=bajaj
authorEhsan Akhgari <ehsan@mozilla.com>
Thu, 22 Aug 2013 17:49:11 -0400
changeset 148435 dc4285f36240706319954efd3b326e5acf938b75
parent 148434 af82c387aced05f3b7b62327b40ddbe8ed141148
child 148436 d856284278cc0df9bc87c862f31baed1fca400fa
push id2799
push userryanvm@gmail.com
push dateFri, 23 Aug 2013 20:44:41 +0000
treeherdermozilla-beta@dc4285f36240 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc, bajaj
bugs906979
milestone24.0
Bug 906979 - Make it possible again to force spell checking on text controls with spellcheck=false. r=roc, a=bajaj
extensions/spellcheck/src/mozInlineSpellChecker.cpp
--- a/extensions/spellcheck/src/mozInlineSpellChecker.cpp
+++ b/extensions/spellcheck/src/mozInlineSpellChecker.cpp
@@ -60,16 +60,17 @@
 #include "nsIContent.h"
 #include "nsEventListenerManager.h"
 #include "nsGUIEvent.h"
 #include "nsRange.h"
 #include "nsContentUtils.h"
 #include "nsEditor.h"
 #include "mozilla/Services.h"
 #include "nsIObserverService.h"
+#include "nsITextControlElement.h"
 
 using namespace mozilla::dom;
 
 // Set to spew messages to the console about what is happening.
 //#define DEBUG_INLINESPELL
 
 // the number of milliseconds that we will take at once to do spellchecking
 #define INLINESPELL_CHECK_TIMEOUT 50
@@ -1262,16 +1263,31 @@ mozInlineSpellChecker::SkipSpellCheckFor
     // Check spelling only if the node is editable, and GetSpellcheck() is true
     // on the nearest HTMLElement ancestor.
     nsCOMPtr<nsIContent> content = do_QueryInterface(aNode);
     if (!content->IsEditable()) {
       *checkSpelling = false;
       return NS_OK;
     }
 
+    // Make sure that we can always turn on spell checking for inputs/textareas.
+    // Note that because of the previous check, at this point we know that the
+    // node is editable.
+    if (content->IsInAnonymousSubtree()) {
+      nsCOMPtr<nsIContent> node = content->GetParent();
+      while (node && node->IsInNativeAnonymousSubtree()) {
+        node = node->GetParent();
+      }
+      nsCOMPtr<nsITextControlElement> textControl = do_QueryInterface(node);
+      if (textControl) {
+        *checkSpelling = true;
+        return NS_OK;
+      }
+    }
+
     // Get HTML element ancestor (might be aNode itself, although probably that
     // has to be a text node in real life here)
     nsCOMPtr<nsIDOMHTMLElement> htmlElement = do_QueryInterface(content);
     while (content && !htmlElement) {
       content = content->GetParent();
       htmlElement = do_QueryInterface(content);
     }
     NS_ASSERTION(htmlElement, "Why do we have no htmlElement?");