Bug 1395828 (part 3) - Remove AssertParserServiceIsCorrect(). r=mrbkap.
It's a bit strange for the editor to distrust the parser service in this way.
The double-checking seems unnecessary, especially given that it is *buggy*: it
incorrectly includes `col`, `colgroup`, and `legend` as block elements, but
excludes `pre`. (It must only be called in situations where these
incorrectly-classified elements are not passed in, otherwise it would have
triggered by now.) So this patch removes it.
The patch also removes `li` and `pre` from the IsAnyOfHTMLElements() test in
HTMLEditor::NodeIsBlockStatic. Contrary to what the comment in
NodeIsBlockStatic() says, they *are* identified as block elements by the parser
service.
--- a/editor/libeditor/HTMLEditor.cpp
+++ b/editor/libeditor/HTMLEditor.cpp
@@ -686,59 +686,16 @@ HTMLEditor::HandleKeyPressEvent(WidgetKe
// we don't PreventDefault() here or keybindings like control-x won't work
return NS_OK;
}
aKeyboardEvent->PreventDefault();
nsAutoString str(aKeyboardEvent->mCharCode);
return TypedText(str, eTypedText);
}
-static void
-AssertParserServiceIsCorrect(nsIAtom* aTag, bool aIsBlock)
-{
-#ifdef DEBUG
- // Check this against what we would have said with the old code:
- if (aTag == nsGkAtoms::p ||
- aTag == nsGkAtoms::div ||
- aTag == nsGkAtoms::blockquote ||
- aTag == nsGkAtoms::h1 ||
- aTag == nsGkAtoms::h2 ||
- aTag == nsGkAtoms::h3 ||
- aTag == nsGkAtoms::h4 ||
- aTag == nsGkAtoms::h5 ||
- aTag == nsGkAtoms::h6 ||
- aTag == nsGkAtoms::ul ||
- aTag == nsGkAtoms::ol ||
- aTag == nsGkAtoms::dl ||
- aTag == nsGkAtoms::noscript ||
- aTag == nsGkAtoms::form ||
- aTag == nsGkAtoms::hr ||
- aTag == nsGkAtoms::table ||
- aTag == nsGkAtoms::fieldset ||
- aTag == nsGkAtoms::address ||
- aTag == nsGkAtoms::col ||
- aTag == nsGkAtoms::colgroup ||
- aTag == nsGkAtoms::li ||
- aTag == nsGkAtoms::dt ||
- aTag == nsGkAtoms::dd ||
- aTag == nsGkAtoms::legend) {
- if (!aIsBlock) {
- nsAutoString assertmsg (NS_LITERAL_STRING("Parser and editor disagree on blockness: "));
-
- nsAutoString tagName;
- aTag->ToString(tagName);
- assertmsg.Append(tagName);
- char* assertstr = ToNewCString(assertmsg);
- NS_ASSERTION(aIsBlock, assertstr);
- free(assertstr);
- }
- }
-#endif // DEBUG
-}
-
/**
* Returns true if the id represents an element of block type.
* Can be used to determine if a new paragraph should be started.
*/
bool
HTMLEditor::NodeIsBlockStatic(const nsINode* aElement)
{
MOZ_ASSERT(aElement);
@@ -748,36 +705,32 @@ HTMLEditor::NodeIsBlockStatic(const nsIN
if (aElement->IsAnyOfHTMLElements(nsGkAtoms::body,
nsGkAtoms::head,
nsGkAtoms::tbody,
nsGkAtoms::thead,
nsGkAtoms::tfoot,
nsGkAtoms::tr,
nsGkAtoms::th,
nsGkAtoms::td,
- nsGkAtoms::li,
nsGkAtoms::dt,
- nsGkAtoms::dd,
- nsGkAtoms::pre)) {
+ nsGkAtoms::dd)) {
return true;
}
bool isBlock;
#ifdef DEBUG
// XXX we can't use DebugOnly here because VC++ is stupid (bug 802884)
nsresult rv =
#endif
nsContentUtils::GetParserService()->
IsBlock(nsContentUtils::GetParserService()->HTMLAtomTagToId(
aElement->NodeInfo()->NameAtom()),
isBlock);
MOZ_ASSERT(rv == NS_OK);
- AssertParserServiceIsCorrect(aElement->NodeInfo()->NameAtom(), isBlock);
-
return isBlock;
}
nsresult
HTMLEditor::NodeIsBlockStatic(nsIDOMNode* aNode,
bool* aIsBlock)
{
if (!aNode || !aIsBlock) {