Bug 1395828 (part 1) - Add nsHTMLElement::IsBlock(). r=mrbkap.
authorNicholas Nethercote <nnethercote@mozilla.com>
Fri, 01 Sep 2017 19:38:09 +1000
changeset 428331 6238f14363f27df8cc8d570e7e4d8dce25299ba1
parent 428330 ae143cf168fe424c6041da8474090e74817741d3
child 428332 73cbc76a296bd9558d3ec3bee9dfb1ec26c08337
push id7761
push userjlund@mozilla.com
push dateFri, 15 Sep 2017 00:19:52 +0000
treeherdermozilla-beta@c38455951db4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmrbkap
bugs1395828
milestone57.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1395828 (part 1) - Add nsHTMLElement::IsBlock(). r=mrbkap. This mirrors the existing nsHTMLElement::IsContainer() function.
parser/htmlparser/nsElementTable.cpp
parser/htmlparser/nsElementTable.h
parser/htmlparser/nsParserService.cpp
--- a/parser/htmlparser/nsElementTable.cpp
+++ b/parser/htmlparser/nsElementTable.cpp
@@ -169,24 +169,33 @@ const nsHTMLElement gHTMLElements[] = {
   ELEM(instruction, kFlowEntity,                 false)
   ELEM(userdefined, (kFlowEntity|kHeadMisc),     false)
 };
 
 #undef ELEM
 
 /*********************************************************************************************/
 
-bool nsHTMLElement::IsContainer(eHTMLTags aChild)
+bool nsHTMLElement::IsMemberOf(int32_t aSet) const
 {
-  return !gHTMLElements[aChild].mLeaf;
+  return TestBits(aSet, mParentBits);
 }
 
-bool nsHTMLElement::IsMemberOf(int32_t aSet) const
+bool nsHTMLElement::IsContainer(eHTMLTags aId)
 {
-  return TestBits(aSet,mParentBits);
+  return !gHTMLElements[aId].mLeaf;
+}
+
+bool nsHTMLElement::IsBlock(eHTMLTags aId)
+{
+  return gHTMLElements[aId].IsMemberOf(kBlock)       ||
+         gHTMLElements[aId].IsMemberOf(kBlockEntity) ||
+         gHTMLElements[aId].IsMemberOf(kHeading)     ||
+         gHTMLElements[aId].IsMemberOf(kPreformatted)||
+         gHTMLElements[aId].IsMemberOf(kList);
 }
 
 #ifdef DEBUG
 void CheckElementTable()
 {
   for (eHTMLTags t = eHTMLTag_unknown; t <= eHTMLTag_userdefined; t = eHTMLTags(t + 1)) {
     NS_ASSERTION(gHTMLElements[t].mTagID == t, "gHTMLElements entries does match tag list.");
   }
--- a/parser/htmlparser/nsElementTable.h
+++ b/parser/htmlparser/nsElementTable.h
@@ -82,13 +82,14 @@ struct nsHTMLElement {
 
 #ifdef DEBUG
   eHTMLTags       mTagID;
 #endif
   int             mParentBits;        //defines groups that can contain this element
   bool            mLeaf;
 
   static  bool    IsContainer(eHTMLTags aTag);
+  static  bool    IsBlock(eHTMLTags aTag);
 };
 
 extern const nsHTMLElement gHTMLElements[];
 
 #endif
--- a/parser/htmlparser/nsParserService.cpp
+++ b/parser/htmlparser/nsParserService.cpp
@@ -45,21 +45,12 @@ nsParserService::IsContainer(int32_t aId
   aIsContainer = nsHTMLElement::IsContainer((eHTMLTags)aId);
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsParserService::IsBlock(int32_t aId, bool& aIsBlock) const
 {
-  if((aId>eHTMLTag_unknown) && (aId<eHTMLTag_userdefined)) {
-    aIsBlock=((gHTMLElements[aId].IsMemberOf(kBlock))       ||
-              (gHTMLElements[aId].IsMemberOf(kBlockEntity)) ||
-              (gHTMLElements[aId].IsMemberOf(kHeading))     ||
-              (gHTMLElements[aId].IsMemberOf(kPreformatted))||
-              (gHTMLElements[aId].IsMemberOf(kList)));
-  }
-  else {
-    aIsBlock = false;
-  }
+  aIsBlock = nsHTMLElement::IsBlock((eHTMLTags)aId);
 
   return NS_OK;
 }