Bug 611182 - Part 6: Actually allow the bogus node to be deleted from the document, and check if the parent is modifiable when inserting an element to prevent a bogus node being inserted under a contenteditable="false" element; r=bzbarsky a=blocking-beta8+
authorEhsan Akhgari <ehsan@mozilla.com>
Fri, 12 Nov 2010 10:38:14 -0500
changeset 57484 8c4b1c2924833701e31be35f4c93cc53c9a32803
parent 57483 66a04ae3d1cd817bfd133b13832bb6d0d783efe5
child 57485 98b0ae8881953f47aa601acbc7fa95ada11b0124
push id16941
push usereakhgari@mozilla.com
push dateSun, 14 Nov 2010 21:28:20 +0000
treeherdermozilla-central@98b0ae888195 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbzbarsky, blocking-beta8
bugs611182, 579985
milestone2.0b8pre
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 611182 - Part 6: Actually allow the bogus node to be deleted from the document, and check if the parent is modifiable when inserting an element to prevent a bogus node being inserted under a contenteditable="false" element; r=bzbarsky a=blocking-beta8+ This fixes a failure in layout/reftests/bugs/579985-1.html, and is tested by it.
editor/libeditor/html/nsHTMLEditor.cpp
editor/libeditor/text/nsTextEditRules.cpp
--- a/editor/libeditor/html/nsHTMLEditor.cpp
+++ b/editor/libeditor/html/nsHTMLEditor.cpp
@@ -3789,17 +3789,17 @@ nsHTMLEditor::GetEmbeddedObjects(nsISupp
 #pragma mark -
 #pragma mark  nsIEditor overrides 
 #pragma mark -
 #endif
 
 NS_IMETHODIMP nsHTMLEditor::DeleteNode(nsIDOMNode * aNode)
 {
   // do nothing if the node is read-only
-  if (!IsModifiableNode(aNode)) {
+  if (!IsModifiableNode(aNode) && !IsMozEditorBogusNode(aNode)) {
     return NS_ERROR_FAILURE;
   }
 
   nsCOMPtr<nsIDOMNode> selectAllNode = FindUserSelectAllNode(aNode);
   
   if (selectAllNode)
   {
     return nsEditor::DeleteNode(selectAllNode);
--- a/editor/libeditor/text/nsTextEditRules.cpp
+++ b/editor/libeditor/text/nsTextEditRules.cpp
@@ -1131,17 +1131,18 @@ nsTextEditRules::CreateBogusNodeIfNeeded
     {
       needsBogusContent = PR_FALSE;
       break;
     }
     nsCOMPtr<nsIDOMNode>temp;
     bodyChild->GetNextSibling(getter_AddRefs(temp));
     bodyChild = do_QueryInterface(temp);
   }
-  if (needsBogusContent)
+  // Skip adding the bogus node if body is read-only
+  if (needsBogusContent && mEditor->IsModifiableNode(body))
   {
     // create a br
     nsCOMPtr<nsIContent> newContent;
     res = mEditor->CreateHTMLContent(NS_LITERAL_STRING("br"), getter_AddRefs(newContent));
     NS_ENSURE_SUCCESS(res, res);
     nsCOMPtr<nsIDOMElement>brElement = do_QueryInterface(newContent);
 
     // set mBogusNode to be the newly created <br>