2006-04-20 03:37:39 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 11:12:37 +00: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/. */
|
2006-04-20 03:36:57 +00:00
|
|
|
|
2013-08-30 17:16:32 +00:00
|
|
|
#ifndef mozilla_dom_DOMParser_h_
|
|
|
|
#define mozilla_dom_DOMParser_h_
|
2006-04-20 03:36:57 +00:00
|
|
|
|
|
|
|
#include "nsCOMPtr.h"
|
2012-01-20 12:03:49 +00:00
|
|
|
#include "nsIDocument.h"
|
2013-03-22 00:05:19 +00:00
|
|
|
#include "nsIDOMParser.h"
|
|
|
|
#include "nsWeakReference.h"
|
2012-12-04 01:26:16 +00:00
|
|
|
#include "nsWrapperCache.h"
|
|
|
|
#include "mozilla/ErrorResult.h"
|
|
|
|
#include "mozilla/dom/DOMParserBinding.h"
|
|
|
|
#include "mozilla/dom/TypedArray.h"
|
2006-04-20 03:37:35 +00:00
|
|
|
|
2013-03-22 00:05:19 +00:00
|
|
|
class nsIDocument;
|
|
|
|
|
2013-08-30 17:16:32 +00:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
|
|
|
class DOMParser MOZ_FINAL : public nsIDOMParser,
|
|
|
|
public nsSupportsWeakReference,
|
|
|
|
public nsWrapperCache
|
2006-04-20 03:36:57 +00:00
|
|
|
{
|
2013-08-23 05:17:08 +00:00
|
|
|
typedef mozilla::dom::GlobalObject GlobalObject;
|
2014-06-25 02:09:15 +00:00
|
|
|
|
|
|
|
virtual ~DOMParser();
|
|
|
|
|
2006-04-20 03:36:57 +00:00
|
|
|
public:
|
2013-08-30 17:16:32 +00:00
|
|
|
DOMParser();
|
2006-04-20 03:36:57 +00:00
|
|
|
|
2012-12-04 01:26:16 +00:00
|
|
|
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
2013-08-30 17:16:32 +00:00
|
|
|
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_AMBIGUOUS(DOMParser,
|
2012-12-04 01:26:16 +00:00
|
|
|
nsIDOMParser)
|
2006-04-20 03:36:57 +00:00
|
|
|
|
|
|
|
// nsIDOMParser
|
2006-04-20 03:37:01 +00:00
|
|
|
NS_DECL_NSIDOMPARSER
|
2006-04-20 03:36:57 +00:00
|
|
|
|
2012-12-04 01:26:16 +00:00
|
|
|
// WebIDL API
|
2013-08-30 17:16:32 +00:00
|
|
|
static already_AddRefed<DOMParser>
|
2013-08-23 05:17:08 +00:00
|
|
|
Constructor(const GlobalObject& aOwner,
|
2012-12-03 16:07:49 +00:00
|
|
|
mozilla::ErrorResult& rv);
|
2012-12-04 01:26:16 +00:00
|
|
|
|
2013-08-30 17:16:32 +00:00
|
|
|
static already_AddRefed<DOMParser>
|
2013-08-23 05:17:08 +00:00
|
|
|
Constructor(const GlobalObject& aOwner,
|
2012-12-03 16:07:49 +00:00
|
|
|
nsIPrincipal* aPrincipal, nsIURI* aDocumentURI, nsIURI* aBaseURI,
|
2012-12-04 01:26:16 +00:00
|
|
|
mozilla::ErrorResult& rv);
|
|
|
|
|
|
|
|
already_AddRefed<nsIDocument>
|
|
|
|
ParseFromString(const nsAString& aStr, mozilla::dom::SupportedType aType,
|
|
|
|
mozilla::ErrorResult& rv);
|
|
|
|
|
|
|
|
already_AddRefed<nsIDocument>
|
|
|
|
ParseFromBuffer(const mozilla::dom::Sequence<uint8_t>& aBuf,
|
|
|
|
uint32_t aBufLen, mozilla::dom::SupportedType aType,
|
|
|
|
mozilla::ErrorResult& rv);
|
|
|
|
|
|
|
|
already_AddRefed<nsIDocument>
|
|
|
|
ParseFromBuffer(const mozilla::dom::Uint8Array& aBuf, uint32_t aBufLen,
|
|
|
|
mozilla::dom::SupportedType aType,
|
|
|
|
mozilla::ErrorResult& rv);
|
|
|
|
|
|
|
|
already_AddRefed<nsIDocument>
|
|
|
|
ParseFromStream(nsIInputStream* aStream, const nsAString& aCharset,
|
|
|
|
int32_t aContentLength, mozilla::dom::SupportedType aType,
|
|
|
|
mozilla::ErrorResult& rv);
|
|
|
|
|
|
|
|
void Init(nsIPrincipal* aPrincipal, nsIURI* aDocumentURI,
|
2012-12-04 01:26:16 +00:00
|
|
|
nsIURI* aBaseURI, mozilla::ErrorResult& rv);
|
2012-12-04 01:26:16 +00:00
|
|
|
|
|
|
|
nsISupports* GetParentObject() const
|
|
|
|
{
|
|
|
|
return mOwner;
|
|
|
|
}
|
|
|
|
|
2014-04-08 22:27:18 +00:00
|
|
|
virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE
|
2012-12-04 01:26:16 +00:00
|
|
|
{
|
Bug 991742 part 6. Remove the "aScope" argument of binding Wrap() methods. r=bholley
This patch was mostly generated with this command:
find . -name "*.h" -o -name "*.cpp" | xargs sed -e 's/Binding::Wrap(aCx, aScope, this/Binding::Wrap(aCx, this/' -e 's/Binding_workers::Wrap(aCx, aScope, this/Binding_workers::Wrap(aCx, this/' -e 's/Binding::Wrap(cx, scope, this/Binding::Wrap(cx, this/' -i ""
plus a few manual fixes to dom/bindings/Codegen.py, js/xpconnect/src/event_impl_gen.py, and a few C++ files that were not caught in the search-and-replace above.
2014-04-08 22:27:17 +00:00
|
|
|
return mozilla::dom::DOMParserBinding::Wrap(aCx, this);
|
2012-12-04 01:26:16 +00:00
|
|
|
}
|
|
|
|
|
2006-04-20 03:37:01 +00:00
|
|
|
private:
|
2014-09-02 00:49:25 +00:00
|
|
|
explicit DOMParser(nsISupports* aOwner) : mOwner(aOwner), mAttemptedInit(false)
|
2012-12-04 01:26:16 +00:00
|
|
|
{
|
|
|
|
MOZ_ASSERT(aOwner);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult InitInternal(nsISupports* aOwner, nsIPrincipal* prin,
|
|
|
|
nsIURI* documentURI, nsIURI* baseURI);
|
|
|
|
|
2012-01-20 12:03:49 +00:00
|
|
|
nsresult SetUpDocument(DocumentFlavor aFlavor, nsIDOMDocument** aResult);
|
|
|
|
|
2012-12-05 04:15:47 +00:00
|
|
|
// Helper for ParseFromString
|
|
|
|
nsresult ParseFromString(const nsAString& str, const char *contentType,
|
|
|
|
nsIDOMDocument **aResult);
|
|
|
|
|
2006-09-09 04:54:03 +00:00
|
|
|
class AttemptedInitMarker {
|
|
|
|
public:
|
2014-09-02 00:49:25 +00:00
|
|
|
explicit AttemptedInitMarker(bool* aAttemptedInit) :
|
2006-09-09 04:54:03 +00:00
|
|
|
mAttemptedInit(aAttemptedInit)
|
|
|
|
{}
|
|
|
|
|
|
|
|
~AttemptedInitMarker() {
|
2011-10-17 14:59:28 +00:00
|
|
|
*mAttemptedInit = true;
|
2006-09-09 04:54:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2011-09-29 06:19:26 +00:00
|
|
|
bool* mAttemptedInit;
|
2006-09-09 04:54:03 +00:00
|
|
|
};
|
2012-12-04 01:26:16 +00:00
|
|
|
|
|
|
|
nsCOMPtr<nsISupports> mOwner;
|
2006-09-09 04:54:03 +00:00
|
|
|
nsCOMPtr<nsIPrincipal> mPrincipal;
|
2008-03-28 03:46:15 +00:00
|
|
|
nsCOMPtr<nsIPrincipal> mOriginalPrincipal;
|
2006-09-09 04:54:03 +00:00
|
|
|
nsCOMPtr<nsIURI> mDocumentURI;
|
2006-04-20 03:37:01 +00:00
|
|
|
nsCOMPtr<nsIURI> mBaseURI;
|
2007-10-01 10:02:32 +00:00
|
|
|
nsWeakPtr mScriptHandlingObject;
|
2006-09-09 04:54:03 +00:00
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool mAttemptedInit;
|
2006-04-20 03:36:57 +00:00
|
|
|
};
|
|
|
|
|
2013-08-30 17:16:32 +00:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
2006-04-20 03:36:57 +00:00
|
|
|
#endif
|