Bug 1297414 - Treat <div> like <p> for break insertion; r=masayuki

I don't personally agree with this behavior (although I did spec it some
years ago), but it's the behavior of all other UAs, so we should do it
anyway.

MozReview-Commit-ID: IiIg41kMJIU
This commit is contained in:
Aryeh Gregor 2016-08-24 16:03:01 +03:00
parent c442eea5f2
commit e3c9b3f2de
2 changed files with 4 additions and 91 deletions

View File

@ -1563,7 +1563,7 @@ HTMLEditRules::WillInsertBreak(Selection& aSelection,
ReturnInHeader(aSelection, *blockParent, node, offset);
*aHandled = true;
return NS_OK;
} else if (blockParent->IsHTMLElement(nsGkAtoms::p)) {
} else if (blockParent->IsAnyOfHTMLElements(nsGkAtoms::p, nsGkAtoms::div)) {
// Paragraphs: special rules to look for <br>s
nsresult rv =
ReturnInParagraph(&aSelection, GetAsDOMNode(blockParent),
@ -6354,6 +6354,9 @@ HTMLEditRules::ReturnInHeader(Selection& aSelection,
/**
* ReturnInParagraph() does the right thing for returns pressed in paragraphs.
* For our purposes, this means either <p> or <div>, which is not in keeping
* with the semantics of <div>, but is necessary for compatibility with other
* browsers.
*/
nsresult
HTMLEditRules::ReturnInParagraph(Selection* aSelection,

View File

@ -81,30 +81,6 @@
[[["defaultparagraphseparator","p"\],["insertparagraph",""\]\] "foo[\]bar" compare innerHTML]
expected: FAIL
[[["defaultparagraphseparator","div"\],["insertparagraph",""\]\] "<div>[\]foo</div>" compare innerHTML]
expected: FAIL
[[["defaultparagraphseparator","p"\],["insertparagraph",""\]\] "<div>[\]foo</div>" compare innerHTML]
expected: FAIL
[[["defaultparagraphseparator","div"\],["insertparagraph",""\]\] "<div>foo[\]</div>" compare innerHTML]
expected: FAIL
[[["defaultparagraphseparator","p"\],["insertparagraph",""\]\] "<div>foo[\]</div>" compare innerHTML]
expected: FAIL
[[["defaultparagraphseparator","div"\],["insertparagraph",""\]\] "<div>foo[\]<br></div>" compare innerHTML]
expected: FAIL
[[["defaultparagraphseparator","p"\],["insertparagraph",""\]\] "<div>foo[\]<br></div>" compare innerHTML]
expected: FAIL
[[["defaultparagraphseparator","div"\],["insertparagraph",""\]\] "<div>foo[\]bar</div>" compare innerHTML]
expected: FAIL
[[["defaultparagraphseparator","p"\],["insertparagraph",""\]\] "<div>foo[\]bar</div>" compare innerHTML]
expected: FAIL
[[["defaultparagraphseparator","div"\],["insertparagraph",""\]\] "<h1>foo[\]</h1>" compare innerHTML]
expected: FAIL
@ -303,18 +279,6 @@
[[["stylewithcss","false"\],["defaultparagraphseparator","p"\],["insertparagraph",""\]\] "<p><b id=x class=y>foo[\]bar</b></p>" compare innerHTML]
expected: FAIL
[[["stylewithcss","true"\],["defaultparagraphseparator","div"\],["insertparagraph",""\]\] "<div><b>foo[\]bar</b></div>" compare innerHTML]
expected: FAIL
[[["stylewithcss","false"\],["defaultparagraphseparator","div"\],["insertparagraph",""\]\] "<div><b>foo[\]bar</b></div>" compare innerHTML]
expected: FAIL
[[["stylewithcss","true"\],["defaultparagraphseparator","p"\],["insertparagraph",""\]\] "<div><b>foo[\]bar</b></div>" compare innerHTML]
expected: FAIL
[[["stylewithcss","false"\],["defaultparagraphseparator","p"\],["insertparagraph",""\]\] "<div><b>foo[\]bar</b></div>" compare innerHTML]
expected: FAIL
[[["defaultparagraphseparator","div"\],["insertparagraph",""\]\] "<a href=foo>foo[\]bar</a>" compare innerHTML]
expected: FAIL
@ -411,12 +375,6 @@
[[["defaultparagraphseparator","p"\],["insertparagraph",""\]\] "<ul><li><p>foo[\]</ul>" compare innerHTML]
expected: FAIL
[[["defaultparagraphseparator","div"\],["insertparagraph",""\]\] "<address><div>foo[\]</address>" compare innerHTML]
expected: FAIL
[[["defaultparagraphseparator","p"\],["insertparagraph",""\]\] "<address><div>foo[\]</address>" compare innerHTML]
expected: FAIL
[[["defaultparagraphseparator","div"\],["insertparagraph",""\]\] "<dl><dt><div>foo[\]</dl>" compare innerHTML]
expected: FAIL
@ -441,12 +399,6 @@
[[["defaultparagraphseparator","p"\],["insertparagraph",""\]\] "<ul><li><div>foo[\]</ul>" compare innerHTML]
expected: FAIL
[[["defaultparagraphseparator","div"\],["insertparagraph",""\]\] "<div><div>foo[\]</div>" compare innerHTML]
expected: FAIL
[[["defaultparagraphseparator","p"\],["insertparagraph",""\]\] "<div><div>foo[\]</div>" compare innerHTML]
expected: FAIL
[[["defaultparagraphseparator","div"\],["insertparagraph",""\]\] "<dl><dt><p>[\]foo</dl>" compare innerHTML]
expected: FAIL
@ -471,12 +423,6 @@
[[["defaultparagraphseparator","p"\],["insertparagraph",""\]\] "<ul><li><p>[\]foo</ul>" compare innerHTML]
expected: FAIL
[[["defaultparagraphseparator","div"\],["insertparagraph",""\]\] "<address><div>[\]foo</address>" compare innerHTML]
expected: FAIL
[[["defaultparagraphseparator","p"\],["insertparagraph",""\]\] "<address><div>[\]foo</address>" compare innerHTML]
expected: FAIL
[[["defaultparagraphseparator","div"\],["insertparagraph",""\]\] "<dl><dt><div>[\]foo</dl>" compare innerHTML]
expected: FAIL
@ -501,60 +447,24 @@
[[["defaultparagraphseparator","p"\],["insertparagraph",""\]\] "<ul><li><div>[\]foo</ul>" compare innerHTML]
expected: FAIL
[[["defaultparagraphseparator","div"\],["insertparagraph",""\]\] "<div><div>[\]foo</div>" compare innerHTML]
expected: FAIL
[[["defaultparagraphseparator","p"\],["insertparagraph",""\]\] "<div><div>[\]foo</div>" compare innerHTML]
expected: FAIL
[[["defaultparagraphseparator","div"\],["insertparagraph",""\]\] "<address><div>foo[\]bar</address>" compare innerHTML]
expected: FAIL
[[["defaultparagraphseparator","p"\],["insertparagraph",""\]\] "<address><div>foo[\]bar</address>" compare innerHTML]
expected: FAIL
[[["defaultparagraphseparator","div"\],["insertparagraph",""\]\] "<div><div>foo[\]bar</div>" compare innerHTML]
expected: FAIL
[[["defaultparagraphseparator","p"\],["insertparagraph",""\]\] "<div><div>foo[\]bar</div>" compare innerHTML]
expected: FAIL
[[["defaultparagraphseparator","div"\],["insertparagraph",""\]\] "<ol><li class=a id=x><p class=b id=y>foo[\]</ol>" compare innerHTML]
expected: FAIL
[[["defaultparagraphseparator","p"\],["insertparagraph",""\]\] "<ol><li class=a id=x><p class=b id=y>foo[\]</ol>" compare innerHTML]
expected: FAIL
[[["defaultparagraphseparator","div"\],["insertparagraph",""\]\] "<div class=a id=x><div class=b id=y>foo[\]</div></div>" compare innerHTML]
expected: FAIL
[[["defaultparagraphseparator","p"\],["insertparagraph",""\]\] "<div class=a id=x><div class=b id=y>foo[\]</div></div>" compare innerHTML]
expected: FAIL
[[["defaultparagraphseparator","div"\],["insertparagraph",""\]\] "<ol><li class=a id=x><p class=b id=y>[\]foo</ol>" compare innerHTML]
expected: FAIL
[[["defaultparagraphseparator","p"\],["insertparagraph",""\]\] "<ol><li class=a id=x><p class=b id=y>[\]foo</ol>" compare innerHTML]
expected: FAIL
[[["defaultparagraphseparator","div"\],["insertparagraph",""\]\] "<div class=a id=x><div class=b id=y>[\]foo</div></div>" compare innerHTML]
expected: FAIL
[[["defaultparagraphseparator","p"\],["insertparagraph",""\]\] "<div class=a id=x><div class=b id=y>[\]foo</div></div>" compare innerHTML]
expected: FAIL
[[["defaultparagraphseparator","div"\],["insertparagraph",""\]\] "<ol><li class=a id=x><p class=b id=y>foo[\]bar</ol>" compare innerHTML]
expected: FAIL
[[["defaultparagraphseparator","p"\],["insertparagraph",""\]\] "<ol><li class=a id=x><p class=b id=y>foo[\]bar</ol>" compare innerHTML]
expected: FAIL
[[["defaultparagraphseparator","div"\],["insertparagraph",""\]\] "<div class=a id=x><div class=b id=y>foo[\]bar</div></div>" compare innerHTML]
expected: FAIL
[[["defaultparagraphseparator","p"\],["insertparagraph",""\]\] "<div class=a id=x><div class=b id=y>foo[\]bar</div></div>" compare innerHTML]
expected: FAIL
[[["insertparagraph",""\]\] "<pre>foo[\]&#10;</pre>" compare innerHTML]
expected: FAIL