2002-01-09 04:37:50 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2002-01-09 04:37:50 +03:00
|
|
|
|
|
|
|
#ifndef NS_EXPAT_DRIVER__
|
|
|
|
#define NS_EXPAT_DRIVER__
|
|
|
|
|
2004-12-15 18:37:23 +03:00
|
|
|
#include "expat_config.h"
|
|
|
|
#include "expat.h"
|
2004-05-08 18:07:18 +04:00
|
|
|
#include "nsCOMPtr.h"
|
2002-01-09 04:37:50 +03:00
|
|
|
#include "nsString.h"
|
|
|
|
#include "nsIDTD.h"
|
|
|
|
#include "nsITokenizer.h"
|
2003-03-15 04:04:32 +03:00
|
|
|
#include "nsIInputStream.h"
|
2007-01-31 00:21:06 +03:00
|
|
|
#include "nsIParser.h"
|
2008-02-09 01:07:51 +03:00
|
|
|
#include "nsCycleCollectionParticipant.h"
|
2002-01-09 04:37:50 +03:00
|
|
|
|
|
|
|
class nsIExpatSink;
|
2002-03-15 12:45:31 +03:00
|
|
|
struct nsCatalogData;
|
2002-01-09 04:37:50 +03:00
|
|
|
|
|
|
|
class nsExpatDriver : public nsIDTD, public nsITokenizer {
|
2014-06-27 22:41:03 +04:00
|
|
|
virtual ~nsExpatDriver();
|
|
|
|
|
2002-01-09 04:37:50 +03:00
|
|
|
public:
|
2008-02-09 01:07:51 +03:00
|
|
|
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
2002-01-09 04:37:50 +03:00
|
|
|
NS_DECL_NSIDTD
|
|
|
|
NS_DECL_NSITOKENIZER
|
2008-02-09 01:07:51 +03:00
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsExpatDriver, nsIDTD)
|
2002-01-09 04:37:50 +03:00
|
|
|
|
|
|
|
nsExpatDriver();
|
|
|
|
|
2014-01-04 19:02:17 +04:00
|
|
|
int HandleExternalEntityRef(const char16_t* aOpenEntityNames,
|
|
|
|
const char16_t* aBase, const char16_t* aSystemId,
|
|
|
|
const char16_t* aPublicId);
|
2019-05-21 21:24:02 +03:00
|
|
|
static void HandleStartElement(void* aUserData, const char16_t* aName,
|
|
|
|
const char16_t** aAtts);
|
|
|
|
static void HandleStartElementForSystemPrincipal(void* aUserData,
|
|
|
|
const char16_t* aName,
|
|
|
|
const char16_t** aAtts);
|
|
|
|
static void HandleEndElement(void* aUserData, const char16_t* aName);
|
|
|
|
static void HandleEndElementForSystemPrincipal(void* aUserData,
|
|
|
|
const char16_t* aName);
|
2014-01-04 19:02:17 +04:00
|
|
|
nsresult HandleCharacterData(const char16_t* aCData, const uint32_t aLength);
|
|
|
|
nsresult HandleComment(const char16_t* aName);
|
|
|
|
nsresult HandleProcessingInstruction(const char16_t* aTarget,
|
|
|
|
const char16_t* aData);
|
|
|
|
nsresult HandleXMLDeclaration(const char16_t* aVersion,
|
|
|
|
const char16_t* aEncoding, int32_t aStandalone);
|
|
|
|
nsresult HandleDefault(const char16_t* aData, const uint32_t aLength);
|
2002-01-09 04:37:50 +03:00
|
|
|
nsresult HandleStartCdataSection();
|
|
|
|
nsresult HandleEndCdataSection();
|
2014-01-04 19:02:17 +04:00
|
|
|
nsresult HandleStartDoctypeDecl(const char16_t* aDoctypeName,
|
|
|
|
const char16_t* aSysid,
|
|
|
|
const char16_t* aPubid,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool aHasInternalSubset);
|
2002-01-09 04:37:50 +03:00
|
|
|
nsresult HandleEndDoctypeDecl();
|
|
|
|
|
2004-05-08 18:07:18 +04:00
|
|
|
private:
|
2002-03-15 12:45:31 +03:00
|
|
|
// Load up an external stream to get external entity information
|
2014-01-04 19:02:17 +04:00
|
|
|
nsresult OpenInputStreamFromExternalDTD(const char16_t* aFPIStr,
|
|
|
|
const char16_t* aURLStr,
|
|
|
|
const char16_t* aBaseURL,
|
2004-05-08 18:07:18 +04:00
|
|
|
nsIInputStream** aStream,
|
2003-01-31 22:21:24 +03:00
|
|
|
nsAString& aAbsURL);
|
2002-03-15 12:45:31 +03:00
|
|
|
|
2006-01-27 17:47:23 +03:00
|
|
|
/**
|
|
|
|
* Pass a buffer to Expat. If Expat is blocked aBuffer should be null and
|
|
|
|
* aLength should be 0. The result of the call will be stored in
|
|
|
|
* mInternalState. Expat will parse as much of the buffer as it can and store
|
|
|
|
* the rest in its internal buffer.
|
|
|
|
*
|
|
|
|
* @param aBuffer the buffer to pass to Expat. May be null.
|
|
|
|
* @param aLength the length of the buffer to pass to Expat (in number of
|
2014-01-04 19:02:17 +04:00
|
|
|
* char16_t's). Must be 0 if aBuffer is null and > 0 if
|
2006-01-27 17:47:23 +03:00
|
|
|
* aBuffer is not null.
|
|
|
|
* @param aIsFinal whether there will definitely not be any more new buffers
|
|
|
|
* passed in to ParseBuffer
|
|
|
|
* @param aConsumed [out] the number of PRUnichars that Expat consumed. This
|
|
|
|
* doesn't include the PRUnichars that Expat stored in
|
|
|
|
* its buffer but didn't parse yet.
|
|
|
|
*/
|
2014-01-04 19:02:17 +04:00
|
|
|
void ParseBuffer(const char16_t* aBuffer, uint32_t aLength, bool aIsFinal,
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t* aConsumed);
|
2005-07-26 17:09:19 +04:00
|
|
|
nsresult HandleError();
|
2002-01-09 04:37:50 +03:00
|
|
|
|
2007-11-19 13:57:29 +03:00
|
|
|
void MaybeStopParser(nsresult aState);
|
2007-01-31 00:21:06 +03:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool BlockedOrInterrupted() {
|
2007-01-31 00:21:06 +03:00
|
|
|
return mInternalState == NS_ERROR_HTMLPARSER_BLOCK ||
|
|
|
|
mInternalState == NS_ERROR_HTMLPARSER_INTERRUPTED;
|
|
|
|
}
|
|
|
|
|
2004-05-08 18:07:18 +04:00
|
|
|
XML_Parser mExpatParser;
|
2002-01-25 01:15:58 +03:00
|
|
|
nsString mLastLine;
|
|
|
|
nsString mCDataText;
|
2005-05-13 23:45:43 +04:00
|
|
|
// Various parts of a doctype
|
|
|
|
nsString mDoctypeName;
|
|
|
|
nsString mSystemID;
|
|
|
|
nsString mPublicID;
|
|
|
|
nsString mInternalSubset;
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mInCData;
|
|
|
|
bool mInInternalSubset;
|
|
|
|
bool mInExternalDTD;
|
|
|
|
bool mMadeFinalCallToExpat;
|
2005-07-26 17:09:19 +04:00
|
|
|
|
2006-01-27 17:47:23 +03:00
|
|
|
// Whether we're sure that we won't be getting more buffers to parse from
|
|
|
|
// Necko
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mIsFinalChunk;
|
2006-01-27 17:47:23 +03:00
|
|
|
|
2002-01-25 01:15:58 +03:00
|
|
|
nsresult mInternalState;
|
2005-07-26 17:09:19 +04:00
|
|
|
|
2006-01-27 17:47:23 +03:00
|
|
|
// The length of the data in Expat's buffer (in number of PRUnichars).
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t mExpatBuffered;
|
2006-01-27 17:47:23 +03:00
|
|
|
|
2019-12-13 20:53:41 +03:00
|
|
|
uint16_t mTagDepth;
|
|
|
|
|
2009-06-24 01:22:17 +04:00
|
|
|
// These sinks all refer the same conceptual object. mOriginalSink is
|
|
|
|
// identical with the nsIContentSink* passed to WillBuildModel, and exists
|
|
|
|
// only to avoid QI-ing back to nsIContentSink*.
|
|
|
|
nsCOMPtr<nsIContentSink> mOriginalSink;
|
2004-05-08 18:07:18 +04:00
|
|
|
nsCOMPtr<nsIExpatSink> mSink;
|
2009-06-24 01:22:17 +04:00
|
|
|
|
2002-03-15 12:45:31 +03:00
|
|
|
const nsCatalogData* mCatalogData; // weak
|
2005-06-23 05:54:42 +04:00
|
|
|
nsString mURISpec;
|
2010-12-20 19:21:58 +03:00
|
|
|
|
|
|
|
// Used for error reporting.
|
2012-08-22 19:56:38 +04:00
|
|
|
uint64_t mInnerWindowID;
|
2004-05-07 17:22:39 +04:00
|
|
|
};
|
2004-05-08 18:07:18 +04:00
|
|
|
|
2002-01-09 04:37:50 +03:00
|
|
|
#endif
|