From 01ae744c0b9daa717d5e0ae7c6085c53b8c3bfca Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Fri, 10 Feb 2012 11:04:45 +0100 Subject: [PATCH] Bug 716208 - Simplify nsHTMLCopyEncoder::IsMozBR; r=peterv --- content/base/src/nsDocumentEncoder.cpp | 27 ++++++++++---------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/content/base/src/nsDocumentEncoder.cpp b/content/base/src/nsDocumentEncoder.cpp index 4060d99d09c..4410b11b526 100644 --- a/content/base/src/nsDocumentEncoder.cpp +++ b/content/base/src/nsDocumentEncoder.cpp @@ -84,6 +84,9 @@ #include "nsStringBuffer.h" #include "mozilla/dom/Element.h" +using namespace mozilla; +using namespace mozilla::dom; + nsresult NS_NewDomSelection(nsISelection **aDomSelection); enum nsRangeIterationDirection { @@ -378,7 +381,7 @@ nsDocumentEncoder::SerializeNodeStart(nsINode* aNode, node = aNode; if (node->IsElement()) { - mozilla::dom::Element* originalElement = + Element* originalElement = aOriginalNode && aOriginalNode->IsElement() ? aOriginalNode->AsElement() : nsnull; mSerializer->AppendElementStart(node->AsElement(), @@ -1795,22 +1798,12 @@ nsHTMLCopyEncoder::GetChildAt(nsIDOMNode *aParent, PRInt32 aOffset) bool nsHTMLCopyEncoder::IsMozBR(nsIDOMNode* aNode) { - nsCOMPtr content = do_QueryInterface(aNode); - if (IsTag(content, nsGkAtoms::br)) - { - nsCOMPtr elem = do_QueryInterface(aNode); - if (elem) - { - nsAutoString typeAttrName(NS_LITERAL_STRING("type")); - nsAutoString typeAttrVal; - nsresult rv = elem->GetAttribute(typeAttrName, typeAttrVal); - ToLowerCase(typeAttrVal); - if (NS_SUCCEEDED(rv) && (typeAttrVal.EqualsLiteral("_moz"))) - return true; - } - return false; - } - return false; + MOZ_ASSERT(aNode); + nsCOMPtr element = do_QueryInterface(aNode); + return element && + element->IsHTML(nsGkAtoms::br) && + element->AttrValueIs(kNameSpaceID_None, nsGkAtoms::type, + NS_LITERAL_STRING("_moz"), eIgnoreCase); } nsresult