Bug 1446599 part 1. Stop using nsIDOMProcessingInstruction in serializers. r=mystor

MozReview-Commit-ID: loUmk0rNYV
This commit is contained in:
Boris Zbarsky 2018-03-19 15:15:39 -04:00
parent 4fa4d2a7f5
commit 12ef963787
5 changed files with 14 additions and 13 deletions

View File

@ -21,7 +21,6 @@
#include "mozilla/Encoding.h" #include "mozilla/Encoding.h"
#include "nsIOutputStream.h" #include "nsIOutputStream.h"
#include "nsIDOMElement.h" #include "nsIDOMElement.h"
#include "nsIDOMProcessingInstruction.h"
#include "nsIDOMNodeList.h" #include "nsIDOMNodeList.h"
#include "nsRange.h" #include "nsRange.h"
#include "nsIDOMRange.h" #include "nsIDOMRange.h"
@ -45,6 +44,7 @@
#include "mozilla/dom/Comment.h" #include "mozilla/dom/Comment.h"
#include "mozilla/dom/DocumentType.h" #include "mozilla/dom/DocumentType.h"
#include "mozilla/dom/Element.h" #include "mozilla/dom/Element.h"
#include "mozilla/dom/ProcessingInstruction.h"
#include "mozilla/dom/ShadowRoot.h" #include "mozilla/dom/ShadowRoot.h"
#include "nsLayoutUtils.h" #include "nsLayoutUtils.h"
#include "mozilla/ScopeExit.h" #include "mozilla/ScopeExit.h"
@ -417,7 +417,7 @@ nsDocumentEncoder::SerializeNodeStart(nsINode* aNode,
} }
case nsINode::PROCESSING_INSTRUCTION_NODE: case nsINode::PROCESSING_INSTRUCTION_NODE:
{ {
mSerializer->AppendProcessingInstruction(static_cast<nsIContent*>(node), mSerializer->AppendProcessingInstruction(static_cast<ProcessingInstruction*>(node),
aStartOffset, aEndOffset, aStr); aStartOffset, aEndOffset, aStr);
break; break;
} }

View File

@ -19,6 +19,7 @@ namespace dom {
class Comment; class Comment;
class DocumentType; class DocumentType;
class Element; class Element;
class ProcessingInstruction;
} // namespace dom } // namespace dom
} // namespace mozilla } // namespace mozilla
@ -45,7 +46,7 @@ class nsIContentSerializer : public nsISupports {
int32_t aStartOffset, int32_t aEndOffset, int32_t aStartOffset, int32_t aEndOffset,
nsAString& aStr) = 0; nsAString& aStr) = 0;
NS_IMETHOD AppendProcessingInstruction(nsIContent* aPI, NS_IMETHOD AppendProcessingInstruction(mozilla::dom::ProcessingInstruction* aPI,
int32_t aStartOffset, int32_t aStartOffset,
int32_t aEndOffset, int32_t aEndOffset,
nsAString& aStr) = 0; nsAString& aStr) = 0;

View File

@ -55,10 +55,13 @@ public:
NS_IMETHOD AppendCDATASection(nsIContent* aCDATASection, NS_IMETHOD AppendCDATASection(nsIContent* aCDATASection,
int32_t aStartOffset, int32_t aEndOffset, int32_t aStartOffset, int32_t aEndOffset,
nsAString& aStr) override; nsAString& aStr) override;
NS_IMETHOD AppendProcessingInstruction(nsIContent* aPI, NS_IMETHOD AppendProcessingInstruction(mozilla::dom::ProcessingInstruction* aPI,
int32_t aStartOffset, int32_t aStartOffset,
int32_t aEndOffset, int32_t aEndOffset,
nsAString& aStr) override { return NS_OK; } nsAString& aStr) override
{
return NS_OK;
}
NS_IMETHOD AppendComment(mozilla::dom::Comment* aComment, NS_IMETHOD AppendComment(mozilla::dom::Comment* aComment,
int32_t aStartOffset, int32_t aStartOffset,
int32_t aEndOffset, nsAString& aStr) override int32_t aEndOffset, nsAString& aStr) override

View File

@ -13,7 +13,6 @@
#include "nsXMLContentSerializer.h" #include "nsXMLContentSerializer.h"
#include "nsGkAtoms.h" #include "nsGkAtoms.h"
#include "nsIDOMProcessingInstruction.h"
#include "nsIContent.h" #include "nsIContent.h"
#include "nsIContentInlines.h" #include "nsIContentInlines.h"
#include "nsIDocument.h" #include "nsIDocument.h"
@ -30,6 +29,7 @@
#include "mozilla/dom/Comment.h" #include "mozilla/dom/Comment.h"
#include "mozilla/dom/DocumentType.h" #include "mozilla/dom/DocumentType.h"
#include "mozilla/dom/Element.h" #include "mozilla/dom/Element.h"
#include "mozilla/dom/ProcessingInstruction.h"
#include "mozilla/intl/LineBreaker.h" #include "mozilla/intl/LineBreaker.h"
#include "nsParserConstants.h" #include "nsParserConstants.h"
#include "mozilla/Encoding.h" #include "mozilla/Encoding.h"
@ -254,22 +254,19 @@ nsXMLContentSerializer::AppendCDATASection(nsIContent* aCDATASection,
} }
NS_IMETHODIMP NS_IMETHODIMP
nsXMLContentSerializer::AppendProcessingInstruction(nsIContent* aPI, nsXMLContentSerializer::AppendProcessingInstruction(ProcessingInstruction* aPI,
int32_t aStartOffset, int32_t aStartOffset,
int32_t aEndOffset, int32_t aEndOffset,
nsAString& aStr) nsAString& aStr)
{ {
nsCOMPtr<nsIDOMProcessingInstruction> pi = do_QueryInterface(aPI);
NS_ENSURE_ARG(pi);
nsresult rv; nsresult rv;
nsAutoString target, data, start; nsAutoString target, data, start;
NS_ENSURE_TRUE(MaybeAddNewlineForRootNode(aStr), NS_ERROR_OUT_OF_MEMORY); NS_ENSURE_TRUE(MaybeAddNewlineForRootNode(aStr), NS_ERROR_OUT_OF_MEMORY);
rv = pi->GetTarget(target); aPI->GetTarget(target);
if (NS_FAILED(rv)) return NS_ERROR_FAILURE;
rv = pi->GetData(data); rv = aPI->GetData(data);
if (NS_FAILED(rv)) return NS_ERROR_FAILURE; if (NS_FAILED(rv)) return NS_ERROR_FAILURE;
NS_ENSURE_TRUE(start.AppendLiteral("<?", mozilla::fallible), NS_ERROR_OUT_OF_MEMORY); NS_ENSURE_TRUE(start.AppendLiteral("<?", mozilla::fallible), NS_ERROR_OUT_OF_MEMORY);

View File

@ -50,7 +50,7 @@ class nsXMLContentSerializer : public nsIContentSerializer {
int32_t aStartOffset, int32_t aEndOffset, int32_t aStartOffset, int32_t aEndOffset,
nsAString& aStr) override; nsAString& aStr) override;
NS_IMETHOD AppendProcessingInstruction(nsIContent* aPI, NS_IMETHOD AppendProcessingInstruction(mozilla::dom::ProcessingInstruction* aPI,
int32_t aStartOffset, int32_t aStartOffset,
int32_t aEndOffset, int32_t aEndOffset,
nsAString& aStr) override; nsAString& aStr) override;