2015-05-03 22:32:37 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
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/. */
|
2006-04-20 07:36:57 +04:00
|
|
|
|
2013-08-30 21:16:32 +04:00
|
|
|
#ifndef mozilla_dom_DOMParser_h_
|
|
|
|
#define mozilla_dom_DOMParser_h_
|
2006-04-20 07:36:57 +04:00
|
|
|
|
|
|
|
#include "nsCOMPtr.h"
|
2012-01-20 16:03:49 +04:00
|
|
|
#include "nsIDocument.h"
|
2012-12-04 05:26:16 +04:00
|
|
|
#include "nsWrapperCache.h"
|
|
|
|
#include "mozilla/ErrorResult.h"
|
2018-04-21 06:01:25 +03:00
|
|
|
#include "mozilla/Span.h"
|
2012-12-04 05:26:16 +04:00
|
|
|
#include "mozilla/dom/DOMParserBinding.h"
|
|
|
|
#include "mozilla/dom/TypedArray.h"
|
2006-04-20 07:37:35 +04:00
|
|
|
|
2013-03-22 04:05:19 +04:00
|
|
|
class nsIDocument;
|
2018-04-21 06:04:45 +03:00
|
|
|
class nsIGlobalObject;
|
2013-03-22 04:05:19 +04:00
|
|
|
|
2013-08-30 21:16:32 +04:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
2018-04-21 06:04:46 +03:00
|
|
|
class DOMParser final : public nsISupports, public nsWrapperCache {
|
2013-08-23 09:17:08 +04:00
|
|
|
typedef mozilla::dom::GlobalObject GlobalObject;
|
2014-06-25 06:09:15 +04:00
|
|
|
|
|
|
|
virtual ~DOMParser();
|
|
|
|
|
2017-07-06 15:00:35 +03:00
|
|
|
public:
|
2012-12-04 05:26:16 +04:00
|
|
|
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
2018-04-21 06:04:46 +03:00
|
|
|
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(DOMParser)
|
2006-04-20 07:36:57 +04:00
|
|
|
|
2012-12-04 05:26:16 +04:00
|
|
|
// WebIDL API
|
2013-08-23 09:17:08 +04:00
|
|
|
static already_AddRefed<DOMParser> Constructor(const GlobalObject& aOwner,
|
2012-12-03 20:07:49 +04:00
|
|
|
mozilla::ErrorResult& rv);
|
2012-12-04 05:26:16 +04:00
|
|
|
|
2018-04-21 06:01:25 +03:00
|
|
|
already_AddRefed<nsIDocument> ParseFromString(const nsAString& aStr,
|
|
|
|
SupportedType aType,
|
|
|
|
ErrorResult& aRv);
|
2012-12-04 05:26:16 +04:00
|
|
|
|
2018-04-21 06:01:25 +03:00
|
|
|
// Sequence converts to Span, so we can use this overload for both
|
|
|
|
// the Sequence case and our internal uses.
|
|
|
|
already_AddRefed<nsIDocument> ParseFromBuffer(Span<const uint8_t> aBuf,
|
2018-04-21 06:01:25 +03:00
|
|
|
SupportedType aType,
|
|
|
|
ErrorResult& aRv);
|
2012-12-04 05:26:16 +04:00
|
|
|
|
2018-04-21 06:01:25 +03:00
|
|
|
already_AddRefed<nsIDocument> ParseFromBuffer(const Uint8Array& aBuf,
|
|
|
|
SupportedType aType,
|
|
|
|
ErrorResult& aRv);
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2012-12-04 05:26:16 +04:00
|
|
|
already_AddRefed<nsIDocument> ParseFromStream(nsIInputStream* aStream,
|
|
|
|
const nsAString& aCharset,
|
2018-04-21 06:01:25 +03:00
|
|
|
int32_t aContentLength,
|
2018-04-21 06:01:25 +03:00
|
|
|
SupportedType aType,
|
|
|
|
ErrorResult& aRv);
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2018-04-21 06:01:24 +03:00
|
|
|
void ForceEnableXULXBL() { mForceEnableXULXBL = true; }
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2018-04-21 06:04:45 +03:00
|
|
|
nsIGlobalObject* GetParentObject() const { return mOwner; }
|
2012-12-04 05:26:16 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual JSObject* WrapObject(JSContext* aCx,
|
|
|
|
JS::Handle<JSObject*> aGivenProto) override {
|
2018-06-26 00:20:54 +03:00
|
|
|
return mozilla::dom::DOMParser_Binding::Wrap(aCx, this, aGivenProto);
|
2012-12-04 05:26:16 +04:00
|
|
|
}
|
|
|
|
|
2018-04-21 06:04:46 +03:00
|
|
|
// A way to create a non-global-associated DOMParser from C++.
|
|
|
|
static already_AddRefed<DOMParser> CreateWithoutGlobal(ErrorResult& aRv);
|
|
|
|
|
2006-04-20 07:37:01 +04:00
|
|
|
private:
|
2018-04-21 06:04:45 +03:00
|
|
|
DOMParser(nsIGlobalObject* aOwner, nsIPrincipal* aDocPrincipal,
|
|
|
|
nsIURI* aDocumentURI, nsIURI* aBaseURI);
|
2018-04-21 06:01:24 +03:00
|
|
|
|
2018-04-21 06:01:25 +03:00
|
|
|
already_AddRefed<nsIDocument> SetUpDocument(DocumentFlavor aFlavor,
|
|
|
|
ErrorResult& aRv);
|
2012-12-05 08:15:47 +04:00
|
|
|
|
2018-04-21 06:04:45 +03:00
|
|
|
nsCOMPtr<nsIGlobalObject> mOwner;
|
2006-09-09 08:54:03 +04:00
|
|
|
nsCOMPtr<nsIPrincipal> mPrincipal;
|
|
|
|
nsCOMPtr<nsIURI> mDocumentURI;
|
2006-04-20 07:37:01 +04:00
|
|
|
nsCOMPtr<nsIURI> mBaseURI;
|
2017-02-03 00:57:51 +03:00
|
|
|
|
2018-04-21 06:01:24 +03:00
|
|
|
bool mForceEnableXULXBL;
|
2006-04-20 07:36:57 +04:00
|
|
|
};
|
|
|
|
|
2013-08-30 21:16:32 +04:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
2006-04-20 07:36:57 +04:00
|
|
|
#endif
|