Bug 601590 - Make AppendElementStart, AppendElementEnd take Element. r=bzbarsky

This commit is contained in:
Ms2ger 2010-10-22 23:25:22 +02:00
Родитель f2b5cd1902
Коммит 2e2aa380f6
10 изменённых файлов: 59 добавлений и 38 удалений

Просмотреть файл

@ -35,8 +35,8 @@
*
* ***** END LICENSE BLOCK ***** */
#ifndef _nsIContentSerializer_h__
#define _nsIContentSerializer_h__
#ifndef nsIContentSerializer_h
#define nsIContentSerializer_h
#include "nsISupports.h"
@ -44,7 +44,11 @@ class nsIContent;
class nsIDocument;
class nsAString;
/* starting interface: nsIContentSerializer */
namespace mozilla {
namespace dom {
class Element;
} // namespace dom
} // namespace mozilla
#define NS_ICONTENTSERIALIZER_IID \
{ 0xb1ee32f2, 0xb8c4, 0x49b9, \
@ -77,11 +81,11 @@ class nsIContentSerializer : public nsISupports {
NS_IMETHOD AppendDoctype(nsIContent *aDoctype,
nsAString& aStr) = 0;
NS_IMETHOD AppendElementStart(nsIContent *aElement,
nsIContent *aOriginalElement,
NS_IMETHOD AppendElementStart(mozilla::dom::Element* aElement,
mozilla::dom::Element* aOriginalElement,
nsAString& aStr) = 0;
NS_IMETHOD AppendElementEnd(nsIContent *aElement,
NS_IMETHOD AppendElementEnd(mozilla::dom::Element* aElement,
nsAString& aStr) = 0;
NS_IMETHOD Flush(nsAString& aStr) = 0;
@ -100,4 +104,4 @@ NS_DEFINE_STATIC_IID_ACCESSOR(nsIContentSerializer, NS_ICONTENTSERIALIZER_IID)
#define NS_CONTENTSERIALIZER_CONTRACTID_PREFIX \
"@mozilla.org/layout/contentserializer;1?mimetype="
#endif /* __gen_nsIContentSerializer_h__ */
#endif /* nsIContentSerializer_h */

Просмотреть файл

@ -63,8 +63,9 @@
#include "nsIURI.h"
#include "nsNetUtil.h"
#include "nsEscape.h"
#include "mozilla/dom/Element.h"
//#define DEBUG_BenB
using namespace mozilla::dom;
static inline PRUnichar* escape(const nsString& source)
{
@ -241,8 +242,8 @@ mozSanitizingHTMLSerializer::AppendText(nsIContent* aText,
}
NS_IMETHODIMP
mozSanitizingHTMLSerializer::AppendElementStart(nsIContent *aElement,
nsIContent *aOriginalElement,
mozSanitizingHTMLSerializer::AppendElementStart(Element* aElement,
Element* aOriginalElement,
nsAString& aStr)
{
NS_ENSURE_ARG(aElement);
@ -270,7 +271,7 @@ mozSanitizingHTMLSerializer::AppendElementStart(nsIContent *aElement,
}
NS_IMETHODIMP
mozSanitizingHTMLSerializer::AppendElementEnd(nsIContent *aElement,
mozSanitizingHTMLSerializer::AppendElementEnd(Element* aElement,
nsAString& aStr)
{
NS_ENSURE_ARG(aElement);

Просмотреть файл

@ -89,10 +89,11 @@ public:
{ return NS_OK; }
NS_IMETHOD AppendDoctype(nsIContent *aDoctype, nsAString& aStr)
{ return NS_OK; }
NS_IMETHOD AppendElementStart(nsIContent *aElement,
nsIContent *aOriginalElement,
NS_IMETHOD AppendElementStart(mozilla::dom::Element* aElement,
mozilla::dom::Element* aOriginalElement,
nsAString& aStr);
NS_IMETHOD AppendElementEnd(nsIContent *aElement, nsAString& aStr);
NS_IMETHOD AppendElementEnd(mozilla::dom::Element* aElement,
nsAString& aStr);
NS_IMETHOD Flush(nsAString& aStr);
NS_IMETHOD AppendDocumentStart(nsIDocument *aDocument,
@ -150,7 +151,7 @@ protected:
PRUint32 mSkipLevel;
nsHashtable mAllowedTags;
nsCOMPtr<nsIContent> mContent;
nsRefPtr<mozilla::dom::Element> mContent;
nsAString* mOutputString;
nsIParserNode* mParserNode;
nsCOMPtr<nsIParserService> mParserService;

Просмотреть файл

@ -422,7 +422,7 @@ nsDocumentEncoder::SerializeNodeEnd(nsINode* aNode,
return NS_OK;
if (aNode->IsElement()) {
mSerializer->AppendElementEnd(static_cast<nsIContent*>(aNode), aStr);
mSerializer->AppendElementEnd(aNode->AsElement(), aStr);
}
return NS_OK;
}

Просмотреть файл

@ -72,6 +72,9 @@
#include "nsIEditorDocShell.h"
#include "nsIEditor.h"
#include "nsIHTMLEditor.h"
#include "mozilla/dom/Element.h"
using namespace mozilla::dom;
static const PRInt32 kLongLineLen = 128;
@ -228,8 +231,8 @@ nsHTMLContentSerializer::SerializeHTMLAttributes(nsIContent* aContent,
}
NS_IMETHODIMP
nsHTMLContentSerializer::AppendElementStart(nsIContent *aElement,
nsIContent *aOriginalElement,
nsHTMLContentSerializer::AppendElementStart(Element* aElement,
Element* aOriginalElement,
nsAString& aStr)
{
NS_ENSURE_ARG(aElement);
@ -342,7 +345,7 @@ nsHTMLContentSerializer::AppendElementStart(nsIContent *aElement,
}
NS_IMETHODIMP
nsHTMLContentSerializer::AppendElementEnd(nsIContent *aElement,
nsHTMLContentSerializer::AppendElementEnd(Element* aElement,
nsAString& aStr)
{
NS_ENSURE_ARG(aElement);

Просмотреть файл

@ -57,11 +57,11 @@ class nsHTMLContentSerializer : public nsXHTMLContentSerializer {
nsHTMLContentSerializer();
virtual ~nsHTMLContentSerializer();
NS_IMETHOD AppendElementStart(nsIContent *aElement,
nsIContent *aOriginalElement,
NS_IMETHOD AppendElementStart(mozilla::dom::Element* aElement,
mozilla::dom::Element* aOriginalElement,
nsAString& aStr);
NS_IMETHOD AppendElementEnd(nsIContent *aElement,
NS_IMETHOD AppendElementEnd(mozilla::dom::Element* aElement,
nsAString& aStr);
NS_IMETHOD AppendDocumentStart(nsIDocument *aDocument,

Просмотреть файл

@ -57,6 +57,9 @@
#include "nsUnicharUtils.h"
#include "nsCRT.h"
#include "nsIParserService.h"
#include "mozilla/dom/Element.h"
using namespace mozilla::dom;
#define PREF_STRUCTS "converter.html2txt.structs"
#define PREF_HEADER_STRATEGY "converter.html2txt.header_strategy"
@ -381,8 +384,8 @@ nsPlainTextSerializer::AppendCDATASection(nsIContent* aCDATASection,
}
NS_IMETHODIMP
nsPlainTextSerializer::AppendElementStart(nsIContent *aElement,
nsIContent *aOriginalElement,
nsPlainTextSerializer::AppendElementStart(Element* aElement,
Element* aOriginalElement,
nsAString& aStr)
{
NS_ENSURE_ARG(aElement);
@ -414,7 +417,7 @@ nsPlainTextSerializer::AppendElementStart(nsIContent *aElement,
}
NS_IMETHODIMP
nsPlainTextSerializer::AppendElementEnd(nsIContent *aElement,
nsPlainTextSerializer::AppendElementEnd(Element* aElement,
nsAString& aStr)
{
NS_ENSURE_ARG(aElement);

Просмотреть файл

@ -56,6 +56,12 @@
#include "nsIDocumentEncoder.h"
#include "nsTArray.h"
namespace mozilla {
namespace dom {
class Element;
} // namespace dom
} // namespace mozilla
class nsPlainTextSerializer : public nsIContentSerializer,
public nsIHTMLContentSink,
public nsIHTMLToTextSink
@ -84,10 +90,10 @@ public:
PRInt32 aEndOffset, nsAString& aStr) { return NS_OK; }
NS_IMETHOD AppendDoctype(nsIContent *aDoctype,
nsAString& aStr) { return NS_OK; }
NS_IMETHOD AppendElementStart(nsIContent *aElement,
nsIContent *aOriginalElement,
NS_IMETHOD AppendElementStart(mozilla::dom::Element* aElement,
mozilla::dom::Element* aOriginalElement,
nsAString& aStr);
NS_IMETHOD AppendElementEnd(nsIContent *aElement,
NS_IMETHOD AppendElementEnd(mozilla::dom::Element* aElement,
nsAString& aStr);
NS_IMETHOD Flush(nsAString& aStr);
@ -235,7 +241,7 @@ protected:
section.
mHeaderCounter[1] for <h1> etc. */
nsCOMPtr<nsIContent> mContent;
nsRefPtr<mozilla::dom::Element> mContent;
// For handling table rows
nsAutoTArray<PRPackedBool, 8> mHasWrittenCellsForRow;

Просмотреть файл

@ -64,6 +64,9 @@
#include "nsContentUtils.h"
#include "nsAttrName.h"
#include "nsILineBreaker.h"
#include "mozilla/dom/Element.h"
using namespace mozilla::dom;
static const char kMozStr[] = "moz";
@ -915,8 +918,8 @@ nsXMLContentSerializer::SerializeAttributes(nsIContent* aContent,
}
NS_IMETHODIMP
nsXMLContentSerializer::AppendElementStart(nsIContent *aElement,
nsIContent *aOriginalElement,
nsXMLContentSerializer::AppendElementStart(Element* aElement,
Element* aOriginalElement,
nsAString& aStr)
{
NS_ENSURE_ARG(aElement);
@ -1016,7 +1019,7 @@ nsXMLContentSerializer::AppendEndOfElementStart(nsIContent *aOriginalElement,
}
NS_IMETHODIMP
nsXMLContentSerializer::AppendElementEnd(nsIContent *aElement,
nsXMLContentSerializer::AppendElementEnd(Element* aElement,
nsAString& aStr)
{
NS_ENSURE_ARG(aElement);

Просмотреть файл

@ -88,11 +88,11 @@ class nsXMLContentSerializer : public nsIContentSerializer {
NS_IMETHOD AppendDoctype(nsIContent *aDoctype,
nsAString& aStr);
NS_IMETHOD AppendElementStart(nsIContent *aElement,
nsIContent *aOriginalElement,
NS_IMETHOD AppendElementStart(mozilla::dom::Element* aElement,
mozilla::dom::Element* aOriginalElement,
nsAString& aStr);
NS_IMETHOD AppendElementEnd(nsIContent *aElement,
NS_IMETHOD AppendElementEnd(mozilla::dom::Element* aElement,
nsAString& aStr);
NS_IMETHOD Flush(nsAString& aStr) { return NS_OK; }