Bug 716208 - Simplify nsHTMLCopyEncoder::IsMozBR; r=peterv

This commit is contained in:
Ms2ger 2012-02-10 11:04:45 +01:00
parent e177d90345
commit 01ae744c0b

View File

@ -84,6 +84,9 @@
#include "nsStringBuffer.h" #include "nsStringBuffer.h"
#include "mozilla/dom/Element.h" #include "mozilla/dom/Element.h"
using namespace mozilla;
using namespace mozilla::dom;
nsresult NS_NewDomSelection(nsISelection **aDomSelection); nsresult NS_NewDomSelection(nsISelection **aDomSelection);
enum nsRangeIterationDirection { enum nsRangeIterationDirection {
@ -378,7 +381,7 @@ nsDocumentEncoder::SerializeNodeStart(nsINode* aNode,
node = aNode; node = aNode;
if (node->IsElement()) { if (node->IsElement()) {
mozilla::dom::Element* originalElement = Element* originalElement =
aOriginalNode && aOriginalNode->IsElement() ? aOriginalNode && aOriginalNode->IsElement() ?
aOriginalNode->AsElement() : nsnull; aOriginalNode->AsElement() : nsnull;
mSerializer->AppendElementStart(node->AsElement(), mSerializer->AppendElementStart(node->AsElement(),
@ -1795,22 +1798,12 @@ nsHTMLCopyEncoder::GetChildAt(nsIDOMNode *aParent, PRInt32 aOffset)
bool bool
nsHTMLCopyEncoder::IsMozBR(nsIDOMNode* aNode) nsHTMLCopyEncoder::IsMozBR(nsIDOMNode* aNode)
{ {
nsCOMPtr<nsIContent> content = do_QueryInterface(aNode); MOZ_ASSERT(aNode);
if (IsTag(content, nsGkAtoms::br)) nsCOMPtr<Element> element = do_QueryInterface(aNode);
{ return element &&
nsCOMPtr<nsIDOMElement> elem = do_QueryInterface(aNode); element->IsHTML(nsGkAtoms::br) &&
if (elem) element->AttrValueIs(kNameSpaceID_None, nsGkAtoms::type,
{ NS_LITERAL_STRING("_moz"), eIgnoreCase);
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;
} }
nsresult nsresult