Bug 1134280 - Get rid of Tag() - patch 4 - Get rid of nsDocumentEncoder::IsTag, r=smaug
authorAndrea Marchesini <amarchesini@mozilla.com>
Tue, 03 Mar 2015 11:09:00 +0000
changeset 247002 2c119ba8d267a38ed64e6772de73bd2dd07b0ae7
parent 247001 a1815f880a88048e3e9ec319ecd88aa860b6eda3
child 247003 a94a92b42ef901e67a5afd03aca15430f417c8fe
push id884
push userdburns@mozilla.com
push dateTue, 03 Mar 2015 15:29:12 +0000
reviewerssmaug
bugs1134280
milestone39.0a1
Bug 1134280 - Get rid of Tag() - patch 4 - Get rid of nsDocumentEncoder::IsTag, r=smaug
dom/base/nsDocumentEncoder.cpp
--- a/dom/base/nsDocumentEncoder.cpp
+++ b/dom/base/nsDocumentEncoder.cpp
@@ -129,18 +129,16 @@ protected:
         bool isVisible = frame->StyleVisibility()->IsVisible();
         if (!isVisible && aNode->IsNodeOfType(nsINode::eTEXT))
           return false;
       }
     }
     return true;
   }
 
-  static bool IsTag(nsIContent* aContent, nsIAtom* aAtom);
-  
   virtual bool IncludeInContext(nsINode *aNode);
 
   nsCOMPtr<nsIDocument>          mDocument;
   nsCOMPtr<nsISelection>         mSelection;
   nsRefPtr<nsRange>              mRange;
   nsCOMPtr<nsINode>              mNode;
   nsCOMPtr<nsIOutputStream>      mStream;
   nsCOMPtr<nsIContentSerializer> mSerializer;
@@ -536,22 +534,16 @@ nsDocumentEncoder::SerializeToStringIter
         }
       }
     }
   }
 
   return NS_OK;
 }
 
-bool 
-nsDocumentEncoder::IsTag(nsIContent* aContent, nsIAtom* aAtom)
-{
-  return aContent && aContent->NodeInfo()->NameAtom() == aAtom;
-}
-
 static nsresult
 ConvertAndWrite(const nsAString& aString,
                 nsIOutputStream* aStream,
                 nsIUnicodeEncoder* aEncoder)
 {
   NS_ENSURE_ARG_POINTER(aStream);
   NS_ENSURE_ARG_POINTER(aEncoder);
   nsresult rv;
@@ -1881,26 +1873,27 @@ nsHTMLCopyEncoder::GetNodeLocation(nsIDO
   }
   return result;
 }
 
 bool
 nsHTMLCopyEncoder::IsRoot(nsIDOMNode* aNode)
 {
   nsCOMPtr<nsIContent> content = do_QueryInterface(aNode);
-  if (content)
-  {
-    if (mIsTextWidget) 
-      return (IsTag(content, nsGkAtoms::div));
+  if (!content) {
+    return false;
+  }
 
-    return (IsTag(content, nsGkAtoms::body) ||
-            IsTag(content, nsGkAtoms::td)   ||
-            IsTag(content, nsGkAtoms::th));
+  if (mIsTextWidget) {
+    return content->IsHTMLElement(nsGkAtoms::div);
   }
-  return false;
+
+  return content->IsAnyOfHTMLElements(nsGkAtoms::body,
+                                      nsGkAtoms::td,
+                                      nsGkAtoms::th);
 }
 
 bool
 nsHTMLCopyEncoder::IsFirstNode(nsIDOMNode *aNode)
 {
   nsCOMPtr<nsIDOMNode> parent;
   int32_t offset, j=0;
   nsresult rv = GetNodeLocation(aNode, address_of(parent), &offset);