Bug 632904. Check IsEditable(), not content states, if we care about editability. r=ehsan,masayuki
authorBoris Zbarsky <bzbarsky@mit.edu>
Wed, 23 Mar 2011 10:45:21 -0400
changeset 63543 cb3e118dda442bd9e3a935212879d8b56d111a22
parent 63542 9dadd58e33173f6d69523f8e25fae57e9f9bc4f7
child 63544 383148dfab3eab11028edaa4d1112895899346ff
push idunknown
push userunknown
push dateunknown
reviewersehsan, masayuki
bugs632904
milestone2.2a1pre
Bug 632904. Check IsEditable(), not content states, if we care about editability. r=ehsan,masayuki
content/events/src/nsIMEStateManager.cpp
editor/libeditor/html/nsHTMLEditor.cpp
extensions/spellcheck/src/mozInlineSpellChecker.cpp
--- a/content/events/src/nsIMEStateManager.cpp
+++ b/content/events/src/nsIMEStateManager.cpp
@@ -628,29 +628,21 @@ nsTextStateManager::ContentRemoved(nsIDo
     nsContentUtils::AddScriptRunner(
         new TextChangeEvent(mWidget, offset, offset + childOffset, offset));
 }
 
 static nsINode* GetRootEditableNode(nsPresContext* aPresContext,
                                     nsIContent* aContent)
 {
   if (aContent) {
-    nsIContent* root = nsnull;
-    nsIContent* content = aContent;
-    while (content && content->IntrinsicState().HasState(NS_EVENT_STATE_MOZ_READWRITE)) {
-      root = content;
-      content = content->GetParent();
-    }
-    if (!root) {
-      NS_ASSERTION(content, "We should have a content node here");
-      // See if the document is editable
-      nsIDocument* doc = content->GetCurrentDoc();
-      if (doc && doc->IsEditable()) {
-        return doc;
-      }
+    nsINode* root = nsnull;
+    nsINode* node = aContent;
+    while (node && node->IsEditable()) {
+      root = node;
+      node = node->GetNodeParent();
     }
     return root;
   }
   if (aPresContext) {
     nsIDocument* document = aPresContext->Document();
     if (document && document->IsEditable())
       return document;
   }
--- a/editor/libeditor/html/nsHTMLEditor.cpp
+++ b/editor/libeditor/html/nsHTMLEditor.cpp
@@ -3983,17 +3983,17 @@ nsCOMPtr<nsIDOMNode> nsHTMLEditor::FindU
   return resultNode;
 }
 
 NS_IMETHODIMP_(PRBool)
 nsHTMLEditor::IsModifiableNode(nsIDOMNode *aNode)
 {
   nsCOMPtr<nsIContent> content = do_QueryInterface(aNode);
 
-  return !content || !content->IntrinsicState().HasState(NS_EVENT_STATE_MOZ_READONLY);
+  return !content || content->IsEditable();
 }
 
 static nsresult SetSelectionAroundHeadChildren(nsCOMPtr<nsISelection> aSelection, nsWeakPtr aDocWeak)
 {
   nsresult res = NS_OK;
   // Set selection around <head> node
   nsCOMPtr<nsIDOMDocument> doc = do_QueryReferent(aDocWeak);
   NS_ENSURE_TRUE(doc, NS_ERROR_NOT_INITIALIZED);
--- a/extensions/spellcheck/src/mozInlineSpellChecker.cpp
+++ b/extensions/spellcheck/src/mozInlineSpellChecker.cpp
@@ -1153,19 +1153,19 @@ mozInlineSpellChecker::SkipSpellCheckFor
       }
 
       nsCOMPtr<nsIDOMNode> nextParent;
       parent->GetParentNode(getter_AddRefs(nextParent));
       parent = nextParent;
     }
   }
   else {
-    // XXX Do we really want this for all read-write content?
+    // XXX Do we really want this for all editable content?
     nsCOMPtr<nsIContent> content = do_QueryInterface(aNode);
-    *checkSpelling = content->IntrinsicState().HasState(NS_EVENT_STATE_MOZ_READWRITE);
+    *checkSpelling = content->IsEditable();
   }
 
   return NS_OK;
 }
 
 // mozInlineSpellChecker::ScheduleSpellCheck
 //
 //    This is called by code to do the actual spellchecking. We will set up