Bug 1134280 - Get rid of Tag() - patch 3 - nsContentUtils::IsHTMLBlock should work with nsIContent inste nsIAtom, r=smaug

This commit is contained in:
Andrea Marchesini 2015-03-03 11:09:00 +00:00
parent 983b9d9fa4
commit ef86fe9f3e
4 changed files with 37 additions and 39 deletions

View File

@ -1508,42 +1508,41 @@ nsContentUtils::IsHTMLWhitespaceOrNBSP(char16_t aChar)
/* static */
bool
nsContentUtils::IsHTMLBlock(nsIAtom* aLocalName)
nsContentUtils::IsHTMLBlock(nsIContent* aContent)
{
return
(aLocalName == nsGkAtoms::address) ||
(aLocalName == nsGkAtoms::article) ||
(aLocalName == nsGkAtoms::aside) ||
(aLocalName == nsGkAtoms::blockquote) ||
(aLocalName == nsGkAtoms::center) ||
(aLocalName == nsGkAtoms::dir) ||
(aLocalName == nsGkAtoms::div) ||
(aLocalName == nsGkAtoms::dl) || // XXX why not dt and dd?
(aLocalName == nsGkAtoms::fieldset) ||
(aLocalName == nsGkAtoms::figure) || // XXX shouldn't figcaption be on this list
(aLocalName == nsGkAtoms::footer) ||
(aLocalName == nsGkAtoms::form) ||
(aLocalName == nsGkAtoms::h1) ||
(aLocalName == nsGkAtoms::h2) ||
(aLocalName == nsGkAtoms::h3) ||
(aLocalName == nsGkAtoms::h4) ||
(aLocalName == nsGkAtoms::h5) ||
(aLocalName == nsGkAtoms::h6) ||
(aLocalName == nsGkAtoms::header) ||
(aLocalName == nsGkAtoms::hgroup) ||
(aLocalName == nsGkAtoms::hr) ||
(aLocalName == nsGkAtoms::li) ||
(aLocalName == nsGkAtoms::listing) ||
(aLocalName == nsGkAtoms::menu) ||
(aLocalName == nsGkAtoms::multicol) || // XXX get rid of this one?
(aLocalName == nsGkAtoms::nav) ||
(aLocalName == nsGkAtoms::ol) ||
(aLocalName == nsGkAtoms::p) ||
(aLocalName == nsGkAtoms::pre) ||
(aLocalName == nsGkAtoms::section) ||
(aLocalName == nsGkAtoms::table) ||
(aLocalName == nsGkAtoms::ul) ||
(aLocalName == nsGkAtoms::xmp);
return aContent->IsAnyOfHTMLElements(nsGkAtoms::address,
nsGkAtoms::article,
nsGkAtoms::aside,
nsGkAtoms::blockquote,
nsGkAtoms::center,
nsGkAtoms::dir,
nsGkAtoms::div,
nsGkAtoms::dl, // XXX why not dt and dd?
nsGkAtoms::fieldset,
nsGkAtoms::figure, // XXX shouldn't figcaption be on this list
nsGkAtoms::footer,
nsGkAtoms::form,
nsGkAtoms::h1,
nsGkAtoms::h2,
nsGkAtoms::h3,
nsGkAtoms::h4,
nsGkAtoms::h5,
nsGkAtoms::h6,
nsGkAtoms::header,
nsGkAtoms::hgroup,
nsGkAtoms::hr,
nsGkAtoms::li,
nsGkAtoms::listing,
nsGkAtoms::menu,
nsGkAtoms::multicol, // XXX get rid of this one?
nsGkAtoms::nav,
nsGkAtoms::ol,
nsGkAtoms::p,
nsGkAtoms::pre,
nsGkAtoms::section,
nsGkAtoms::table,
nsGkAtoms::ul,
nsGkAtoms::xmp);
}
/* static */

View File

@ -361,7 +361,7 @@ public:
/**
* Is the HTML local name a block element?
*/
static bool IsHTMLBlock(nsIAtom* aLocalName);
static bool IsHTMLBlock(nsIContent* aContent);
enum ParseHTMLIntegerResultFlags {
eParseHTMLInteger_NoFlags = 0,

View File

@ -1812,7 +1812,7 @@ nsPlainTextSerializer::IsElementBlock(Element* aElement)
return displayStyle->IsBlockOutsideStyle();
}
// Fall back to looking at the tag, in case there is no style information.
return nsContentUtils::IsHTMLBlock(GetIdForContent(aElement));
return nsContentUtils::IsHTMLBlock(aElement);
}
/**

View File

@ -744,8 +744,7 @@ bool nsFind::IsBlockNode(nsIContent* aContent)
return true;
}
return aContent->IsHTMLElement() &&
nsContentUtils::IsHTMLBlock(aContent->NodeInfo()->NameAtom());
return nsContentUtils::IsHTMLBlock(aContent);
}
bool nsFind::IsTextNode(nsIDOMNode* aNode)