Skip to content

Commit

Permalink
Bug 1395828 (part 3) - Remove AssertParserServiceIsCorrect(). r=mrbkap.
Browse files Browse the repository at this point in the history
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.

--HG--
extra : rebase_source : c9bb3c9e07320fafed17942229c316f41ac2a0a6
  • Loading branch information
nnethercote committed Sep 4, 2017
1 parent 1e3e28c commit 9b8908c
Showing 1 changed file with 1 addition and 48 deletions.
49 changes: 1 addition & 48 deletions editor/libeditor/HTMLEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -691,49 +691,6 @@ HTMLEditor::HandleKeyPressEvent(WidgetKeyboardEvent* aKeyboardEvent)
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.
Expand All @@ -753,10 +710,8 @@ HTMLEditor::NodeIsBlockStatic(const nsINode* aElement)
nsGkAtoms::tr,
nsGkAtoms::th,
nsGkAtoms::td,
nsGkAtoms::li,
nsGkAtoms::dt,
nsGkAtoms::dd,
nsGkAtoms::pre)) {
nsGkAtoms::dd)) {
return true;
}

Expand All @@ -771,8 +726,6 @@ HTMLEditor::NodeIsBlockStatic(const nsINode* aElement)
isBlock);
MOZ_ASSERT(rv == NS_OK);

AssertParserServiceIsCorrect(aElement->NodeInfo()->NameAtom(), isBlock);

return isBlock;
}

Expand Down

0 comments on commit 9b8908c

Please sign in to comment.