Bug 911201 - Do not create a bogus br node for editable areas containing non-editable block elements; r=roc
authorEhsan Akhgari <ehsan@mozilla.com>
Thu, 27 Nov 2014 21:06:44 -0500
changeset 230253 585dbcf446ea270c4185a36f45df33e45e1cd130
parent 230252 66722c270acb01215da6fb05a780d1b36c136d3b
child 230254 af03bce1c07fe8076056b37487fd2a747943fe9f
push id156
push userdburns@mozilla.com
push dateFri, 28 Nov 2014 14:54:24 +0000
reviewersroc
bugs911201
milestone36.0a1
Bug 911201 - Do not create a bogus br node for editable areas containing non-editable block elements; r=roc We no longer rely on the bogus br node for positioning the caret. If an editable region has a non-editable block element, we can probably rely on the block element to reserve the vertical height, so in those cases we should be able to get away without a bogus br node.
editor/libeditor/nsTextEditRules.cpp
editor/reftests/911201-ref.html
editor/reftests/911201.html
editor/reftests/reftest.list
--- a/editor/libeditor/nsTextEditRules.cpp
+++ b/editor/libeditor/nsTextEditRules.cpp
@@ -1149,17 +1149,17 @@ nsTextEditRules::CreateBogusNodeIfNeeded
   // Now we've got the body element. Iterate over the body element's children,
   // looking for editable content. If no editable content is found, insert the
   // bogus node.
   for (nsCOMPtr<nsIContent> bodyChild = body->GetFirstChild();
        bodyChild;
        bodyChild = bodyChild->GetNextSibling()) {
     if (mEditor->IsMozEditorBogusNode(bodyChild) ||
         !mEditor->IsEditable(body) || // XXX hoist out of the loop?
-        mEditor->IsEditable(bodyChild)) {
+        mEditor->IsEditable(bodyChild) || mEditor->IsBlockNode(bodyChild)) {
       return NS_OK;
     }
   }
 
   // Skip adding the bogus node if body is read-only.
   if (!mEditor->IsModifiableNode(body)) {
     return NS_OK;
   }
new file mode 100644
--- /dev/null
+++ b/editor/reftests/911201-ref.html
@@ -0,0 +1,2 @@
+<!DOCTYPE html>
+<body contenteditable><div contenteditable=false>foo</div></body>
new file mode 100644
--- /dev/null
+++ b/editor/reftests/911201.html
@@ -0,0 +1,2 @@
+<!DOCTYPE html>
+<body contenteditable onload="document.body.innerHTML='<div contenteditable=false>foo</div>';"></body>
--- a/editor/reftests/reftest.list
+++ b/editor/reftests/reftest.list
@@ -120,11 +120,12 @@ needs-focus == spellcheck-contenteditabl
 == spellcheck-contenteditable-attr-dynamic.html spellcheck-contenteditable-disabled-ref.html
 == spellcheck-contenteditable-attr-dynamic-inherit.html spellcheck-contenteditable-disabled-ref.html
 == spellcheck-contenteditable-property-dynamic.html spellcheck-contenteditable-disabled-ref.html
 == spellcheck-contenteditable-property-dynamic-inherit.html spellcheck-contenteditable-disabled-ref.html
 == spellcheck-contenteditable-attr-dynamic-override.html spellcheck-contenteditable-disabled-ref.html
 == spellcheck-contenteditable-attr-dynamic-override-inherit.html spellcheck-contenteditable-disabled-ref.html
 == spellcheck-contenteditable-property-dynamic-override.html spellcheck-contenteditable-disabled-ref.html
 == spellcheck-contenteditable-property-dynamic-override-inherit.html spellcheck-contenteditable-disabled-ref.html
+== 911201.html 911201-ref.html
 needs-focus == 969773.html 969773-ref.html
 == 997805.html 997805-ref.html
 == 1088158.html 1088158-ref.html