2015-05-03 19:32:37 +00: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 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/. */
|
2004-09-30 22:27:45 +00:00
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsXMLContentSink.h"
|
|
|
|
#include "nsIFragmentContentSink.h"
|
|
|
|
#include "nsIXMLContentSink.h"
|
|
|
|
#include "nsContentSink.h"
|
|
|
|
#include "nsIExpatSink.h"
|
2009-06-23 21:22:16 +00:00
|
|
|
#include "nsIDTD.h"
|
2004-09-30 22:27:45 +00:00
|
|
|
#include "nsIDocument.h"
|
|
|
|
#include "nsIDOMDocumentFragment.h"
|
2007-02-09 00:15:14 +00:00
|
|
|
#include "nsIContent.h"
|
2006-12-26 17:47:52 +00:00
|
|
|
#include "nsGkAtoms.h"
|
2014-06-20 02:01:40 +00:00
|
|
|
#include "mozilla/dom/NodeInfo.h"
|
2004-09-30 22:27:45 +00:00
|
|
|
#include "nsContentCreatorFunctions.h"
|
2012-07-27 14:03:27 +00:00
|
|
|
#include "nsError.h"
|
2004-12-04 17:51:12 +00:00
|
|
|
#include "nsIConsoleService.h"
|
2006-08-25 16:34:57 +00:00
|
|
|
#include "nsIScriptError.h"
|
2006-08-12 04:46:43 +00:00
|
|
|
#include "nsTHashtable.h"
|
|
|
|
#include "nsHashKeys.h"
|
|
|
|
#include "nsTArray.h"
|
2008-02-08 22:07:51 +00:00
|
|
|
#include "nsCycleCollectionParticipant.h"
|
2011-08-01 07:48:24 +00:00
|
|
|
#include "nsIDocShell.h"
|
|
|
|
#include "nsScriptLoader.h"
|
|
|
|
#include "mozilla/css/Loader.h"
|
2013-04-10 14:15:54 +00:00
|
|
|
#include "mozilla/dom/DocumentFragment.h"
|
2013-04-04 12:01:11 +00:00
|
|
|
#include "mozilla/dom/ProcessingInstruction.h"
|
2004-09-30 22:27:45 +00:00
|
|
|
|
2010-10-25 12:17:38 +00:00
|
|
|
using namespace mozilla::dom;
|
|
|
|
|
2004-09-30 22:27:45 +00:00
|
|
|
class nsXMLFragmentContentSink : public nsXMLContentSink,
|
|
|
|
public nsIFragmentContentSink
|
|
|
|
{
|
|
|
|
public:
|
2011-08-01 07:48:24 +00:00
|
|
|
nsXMLFragmentContentSink();
|
2004-09-30 22:27:45 +00:00
|
|
|
|
2007-02-02 02:12:48 +00:00
|
|
|
NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW
|
|
|
|
|
2004-09-30 22:27:45 +00:00
|
|
|
// nsISupports
|
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
2008-02-08 22:07:51 +00:00
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED_NO_UNLINK(nsXMLFragmentContentSink,
|
|
|
|
nsXMLContentSink)
|
2004-09-30 22:27:45 +00:00
|
|
|
|
|
|
|
// nsIExpatSink
|
2015-01-07 00:54:15 +00:00
|
|
|
NS_IMETHOD HandleDoctypeDecl(const nsAString& aSubset,
|
|
|
|
const nsAString& aName,
|
|
|
|
const nsAString& aSystemId,
|
|
|
|
const nsAString& aPublicId,
|
2015-03-21 16:28:04 +00:00
|
|
|
nsISupports* aCatalogData) override;
|
2015-01-07 00:54:15 +00:00
|
|
|
NS_IMETHOD HandleProcessingInstruction(const char16_t* aTarget,
|
2015-03-21 16:28:04 +00:00
|
|
|
const char16_t* aData) override;
|
2015-01-07 00:54:15 +00:00
|
|
|
NS_IMETHOD HandleXMLDeclaration(const char16_t* aVersion,
|
|
|
|
const char16_t* aEncoding,
|
2015-03-21 16:28:04 +00:00
|
|
|
int32_t aStandalone) override;
|
2015-01-07 00:54:15 +00:00
|
|
|
NS_IMETHOD ReportError(const char16_t* aErrorText,
|
2014-01-04 15:02:17 +00:00
|
|
|
const char16_t* aSourceText,
|
2015-01-07 00:54:15 +00:00
|
|
|
nsIScriptError* aError,
|
2015-03-21 16:28:04 +00:00
|
|
|
bool* aRetval) override;
|
2004-09-30 22:27:45 +00:00
|
|
|
|
|
|
|
// nsIContentSink
|
2015-03-21 16:28:04 +00:00
|
|
|
NS_IMETHOD WillBuildModel(nsDTDMode aDTDMode) override;
|
|
|
|
NS_IMETHOD DidBuildModel(bool aTerminated) override;
|
|
|
|
NS_IMETHOD SetDocumentCharset(nsACString& aCharset) override;
|
|
|
|
virtual nsISupports* GetTarget() override;
|
2007-01-30 21:21:06 +00:00
|
|
|
NS_IMETHOD DidProcessATokenImpl();
|
2004-09-30 22:27:45 +00:00
|
|
|
|
|
|
|
// nsIXMLContentSink
|
|
|
|
|
|
|
|
// nsIFragmentContentSink
|
2015-03-21 16:28:04 +00:00
|
|
|
NS_IMETHOD FinishFragmentParsing(nsIDOMDocumentFragment** aFragment) override;
|
|
|
|
NS_IMETHOD SetTargetDocument(nsIDocument* aDocument) override;
|
|
|
|
NS_IMETHOD WillBuildContent() override;
|
|
|
|
NS_IMETHOD DidBuildContent() override;
|
|
|
|
NS_IMETHOD IgnoreFirstContainer() override;
|
|
|
|
NS_IMETHOD SetPreventScriptExecution(bool aPreventScriptExecution) override;
|
2004-09-30 22:27:45 +00:00
|
|
|
|
|
|
|
protected:
|
2014-07-08 21:23:16 +00:00
|
|
|
virtual ~nsXMLFragmentContentSink();
|
|
|
|
|
2015-01-07 00:54:15 +00:00
|
|
|
virtual bool SetDocElement(int32_t aNameSpaceID,
|
|
|
|
nsIAtom* aTagName,
|
2015-03-21 16:28:04 +00:00
|
|
|
nsIContent* aContent) override;
|
2014-01-04 15:02:17 +00:00
|
|
|
virtual nsresult CreateElement(const char16_t** aAtts, uint32_t aAttsCount,
|
2014-06-20 02:01:40 +00:00
|
|
|
mozilla::dom::NodeInfo* aNodeInfo, uint32_t aLineNumber,
|
2011-09-29 06:19:26 +00:00
|
|
|
nsIContent** aResult, bool* aAppendContent,
|
2015-03-21 16:28:04 +00:00
|
|
|
mozilla::dom::FromParser aFromParser) override;
|
|
|
|
virtual nsresult CloseElement(nsIContent* aContent) override;
|
2004-09-30 22:27:45 +00:00
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual void MaybeStartLayout(bool aIgnorePendingSheets) override;
|
2007-01-30 21:21:06 +00:00
|
|
|
|
2004-09-30 22:27:45 +00:00
|
|
|
// nsContentSink overrides
|
|
|
|
virtual nsresult ProcessStyleLink(nsIContent* aElement,
|
2005-03-30 00:36:57 +00:00
|
|
|
const nsSubstring& aHref,
|
2011-09-29 06:19:26 +00:00
|
|
|
bool aAlternate,
|
2005-03-30 00:36:57 +00:00
|
|
|
const nsSubstring& aTitle,
|
|
|
|
const nsSubstring& aType,
|
2015-03-21 16:28:04 +00:00
|
|
|
const nsSubstring& aMedia) override;
|
2004-09-30 22:27:45 +00:00
|
|
|
nsresult LoadXSLStyleSheet(nsIURI* aUrl);
|
|
|
|
void StartLayout();
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDocument> mTargetDocument;
|
|
|
|
// the fragment
|
|
|
|
nsCOMPtr<nsIContent> mRoot;
|
2011-09-29 06:19:26 +00:00
|
|
|
bool mParseError;
|
2004-09-30 22:27:45 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static nsresult
|
2011-08-01 07:48:24 +00:00
|
|
|
NewXMLFragmentContentSinkHelper(nsIFragmentContentSink** aResult)
|
2004-09-30 22:27:45 +00:00
|
|
|
{
|
2011-08-01 07:48:24 +00:00
|
|
|
nsXMLFragmentContentSink* it = new nsXMLFragmentContentSink();
|
2004-09-30 22:27:45 +00:00
|
|
|
|
|
|
|
NS_ADDREF(*aResult = it);
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
NS_NewXMLFragmentContentSink(nsIFragmentContentSink** aResult)
|
|
|
|
{
|
2011-08-01 07:48:24 +00:00
|
|
|
return NewXMLFragmentContentSinkHelper(aResult);
|
2004-09-30 22:27:45 +00:00
|
|
|
}
|
|
|
|
|
2011-08-01 07:48:24 +00:00
|
|
|
nsXMLFragmentContentSink::nsXMLFragmentContentSink()
|
2011-10-17 14:59:28 +00:00
|
|
|
: mParseError(false)
|
2004-09-30 22:27:45 +00:00
|
|
|
{
|
2012-01-20 12:03:49 +00:00
|
|
|
mRunsToCompletion = true;
|
2004-09-30 22:27:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsXMLFragmentContentSink::~nsXMLFragmentContentSink()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2008-02-08 22:07:51 +00:00
|
|
|
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(nsXMLFragmentContentSink)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIFragmentContentSink)
|
|
|
|
NS_INTERFACE_MAP_END_INHERITING(nsXMLContentSink)
|
|
|
|
|
|
|
|
NS_IMPL_ADDREF_INHERITED(nsXMLFragmentContentSink, nsXMLContentSink)
|
|
|
|
NS_IMPL_RELEASE_INHERITED(nsXMLFragmentContentSink, nsXMLContentSink)
|
|
|
|
|
2013-08-02 01:29:05 +00:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_CLASS(nsXMLFragmentContentSink)
|
|
|
|
|
2008-02-08 22:07:51 +00:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(nsXMLFragmentContentSink,
|
|
|
|
nsXMLContentSink)
|
2012-11-15 07:32:40 +00:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mTargetDocument)
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mRoot)
|
2008-02-08 22:07:51 +00:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
2004-09-30 22:27:45 +00:00
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2009-06-23 21:22:16 +00:00
|
|
|
nsXMLFragmentContentSink::WillBuildModel(nsDTDMode aDTDMode)
|
2004-09-30 22:27:45 +00:00
|
|
|
{
|
|
|
|
if (mRoot) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
mState = eXMLContentSinkState_InDocumentElement;
|
|
|
|
|
|
|
|
NS_ASSERTION(mTargetDocument, "Need a document!");
|
|
|
|
|
2013-04-10 14:15:54 +00:00
|
|
|
mRoot = new DocumentFragment(mNodeInfoManager);
|
2005-02-18 19:18:39 +00:00
|
|
|
|
2013-04-10 14:15:54 +00:00
|
|
|
return NS_OK;
|
2004-09-30 22:27:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2011-09-29 06:19:26 +00:00
|
|
|
nsXMLFragmentContentSink::DidBuildModel(bool aTerminated)
|
2004-09-30 22:27:45 +00:00
|
|
|
{
|
2015-10-18 05:24:48 +00:00
|
|
|
RefPtr<nsParserBase> kungFuDeathGrip(mParser);
|
2004-09-30 22:27:45 +00:00
|
|
|
|
|
|
|
// Drop our reference to the parser to get rid of a circular
|
|
|
|
// reference.
|
2012-07-30 14:20:58 +00:00
|
|
|
mParser = nullptr;
|
2004-09-30 22:27:45 +00:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsXMLFragmentContentSink::SetDocumentCharset(nsACString& aCharset)
|
|
|
|
{
|
|
|
|
NS_NOTREACHED("fragments shouldn't set charset");
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2004-11-02 19:52:32 +00:00
|
|
|
nsISupports *
|
|
|
|
nsXMLFragmentContentSink::GetTarget()
|
|
|
|
{
|
|
|
|
return mTargetDocument;
|
|
|
|
}
|
|
|
|
|
2004-09-30 22:27:45 +00:00
|
|
|
////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool
|
2012-08-22 15:56:38 +00:00
|
|
|
nsXMLFragmentContentSink::SetDocElement(int32_t aNameSpaceID,
|
2004-09-30 22:27:45 +00:00
|
|
|
nsIAtom* aTagName,
|
|
|
|
nsIContent *aContent)
|
|
|
|
{
|
|
|
|
// this is a fragment, not a document
|
2011-10-17 14:59:28 +00:00
|
|
|
return false;
|
2004-09-30 22:27:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
2014-01-04 15:02:17 +00:00
|
|
|
nsXMLFragmentContentSink::CreateElement(const char16_t** aAtts, uint32_t aAttsCount,
|
2014-06-20 02:01:40 +00:00
|
|
|
mozilla::dom::NodeInfo* aNodeInfo, uint32_t aLineNumber,
|
2011-09-29 06:19:26 +00:00
|
|
|
nsIContent** aResult, bool* aAppendContent,
|
2010-10-25 12:17:38 +00:00
|
|
|
FromParser /*aFromParser*/)
|
2004-09-30 22:27:45 +00:00
|
|
|
{
|
2008-09-25 16:58:11 +00:00
|
|
|
// Claim to not be coming from parser, since we don't do any of the
|
|
|
|
// fancy CloseElement stuff.
|
2004-09-30 22:27:45 +00:00
|
|
|
nsresult rv = nsXMLContentSink::CreateElement(aAtts, aAttsCount,
|
2008-09-25 16:58:11 +00:00
|
|
|
aNodeInfo, aLineNumber,
|
|
|
|
aResult, aAppendContent,
|
2010-10-25 12:17:38 +00:00
|
|
|
NOT_FROM_PARSER);
|
2004-09-30 22:27:45 +00:00
|
|
|
|
2006-11-04 05:45:02 +00:00
|
|
|
// When we aren't grabbing all of the content we, never open a doc
|
2005-02-18 19:18:39 +00:00
|
|
|
// element, we run into trouble on the first element, so we don't append,
|
|
|
|
// and simply push this onto the content stack.
|
2011-08-01 07:48:24 +00:00
|
|
|
if (mContentStack.Length() == 0) {
|
2011-10-17 14:59:28 +00:00
|
|
|
*aAppendContent = false;
|
2005-02-18 19:18:39 +00:00
|
|
|
}
|
|
|
|
|
2004-09-30 22:27:45 +00:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
2006-11-04 05:45:02 +00:00
|
|
|
nsXMLFragmentContentSink::CloseElement(nsIContent* aContent)
|
2004-09-30 22:27:45 +00:00
|
|
|
{
|
|
|
|
// don't do fancy stuff in nsXMLContentSink
|
2015-03-03 11:09:00 +00:00
|
|
|
if (mPreventScriptExecution &&
|
|
|
|
(aContent->IsHTMLElement(nsGkAtoms::script),
|
|
|
|
aContent->IsSVGElement(nsGkAtoms::script))) {
|
2011-08-01 07:48:28 +00:00
|
|
|
nsCOMPtr<nsIScriptElement> sele = do_QueryInterface(aContent);
|
|
|
|
NS_ASSERTION(sele, "script did QI correctly!");
|
|
|
|
sele->PreventExecution();
|
|
|
|
}
|
2004-09-30 22:27:45 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2007-01-30 21:21:06 +00:00
|
|
|
void
|
2011-09-29 06:19:26 +00:00
|
|
|
nsXMLFragmentContentSink::MaybeStartLayout(bool aIgnorePendingSheets)
|
2007-01-30 21:21:06 +00:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2004-09-30 22:27:45 +00:00
|
|
|
////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsXMLFragmentContentSink::HandleDoctypeDecl(const nsAString & aSubset,
|
|
|
|
const nsAString & aName,
|
|
|
|
const nsAString & aSystemId,
|
|
|
|
const nsAString & aPublicId,
|
|
|
|
nsISupports* aCatalogData)
|
|
|
|
{
|
|
|
|
NS_NOTREACHED("fragments shouldn't have doctype declarations");
|
2006-08-12 04:46:43 +00:00
|
|
|
|
2004-09-30 22:27:45 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2014-01-04 15:02:17 +00:00
|
|
|
nsXMLFragmentContentSink::HandleProcessingInstruction(const char16_t *aTarget,
|
|
|
|
const char16_t *aData)
|
2004-09-30 22:27:45 +00:00
|
|
|
{
|
|
|
|
FlushText();
|
|
|
|
|
|
|
|
const nsDependentString target(aTarget);
|
|
|
|
const nsDependentString data(aData);
|
|
|
|
|
2015-10-18 05:24:48 +00:00
|
|
|
RefPtr<ProcessingInstruction> node =
|
2013-04-04 12:01:11 +00:00
|
|
|
NS_NewXMLProcessingInstruction(mNodeInfoManager, target, data);
|
2004-09-30 22:27:45 +00:00
|
|
|
|
2013-04-04 12:01:11 +00:00
|
|
|
// no special processing here. that should happen when the fragment moves into the document
|
|
|
|
return AddContentAsLeaf(node);
|
2004-09-30 22:27:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2014-01-04 15:02:17 +00:00
|
|
|
nsXMLFragmentContentSink::HandleXMLDeclaration(const char16_t *aVersion,
|
|
|
|
const char16_t *aEncoding,
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t aStandalone)
|
2004-09-30 22:27:45 +00:00
|
|
|
{
|
|
|
|
NS_NOTREACHED("fragments shouldn't have XML declarations");
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2014-01-04 15:02:17 +00:00
|
|
|
nsXMLFragmentContentSink::ReportError(const char16_t* aErrorText,
|
|
|
|
const char16_t* aSourceText,
|
2006-08-25 16:34:57 +00:00
|
|
|
nsIScriptError *aError,
|
2011-09-29 06:19:26 +00:00
|
|
|
bool *_retval)
|
2004-09-30 22:27:45 +00:00
|
|
|
{
|
2006-08-25 16:34:57 +00:00
|
|
|
NS_PRECONDITION(aError && aSourceText && aErrorText, "Check arguments!!!");
|
2004-12-04 17:51:12 +00:00
|
|
|
|
2006-08-25 16:34:57 +00:00
|
|
|
// The expat driver should report the error.
|
2011-10-17 14:59:28 +00:00
|
|
|
*_retval = true;
|
2006-08-25 16:34:57 +00:00
|
|
|
|
2011-10-17 14:59:28 +00:00
|
|
|
mParseError = true;
|
2004-12-04 17:51:12 +00:00
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
// Report the error to stderr.
|
|
|
|
fprintf(stderr,
|
|
|
|
"\n%s\n%s\n\n",
|
2006-02-03 14:18:39 +00:00
|
|
|
NS_LossyConvertUTF16toASCII(aErrorText).get(),
|
|
|
|
NS_LossyConvertUTF16toASCII(aSourceText).get());
|
2004-12-04 17:51:12 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
// The following code is similar to the cleanup in nsXMLContentSink::ReportError()
|
|
|
|
mState = eXMLContentSinkState_InProlog;
|
|
|
|
|
|
|
|
// Clear the current content
|
2004-09-30 22:27:45 +00:00
|
|
|
nsCOMPtr<nsIDOMNode> node(do_QueryInterface(mRoot));
|
2004-12-04 17:51:12 +00:00
|
|
|
if (node) {
|
|
|
|
for (;;) {
|
|
|
|
nsCOMPtr<nsIDOMNode> child, dummy;
|
|
|
|
node->GetLastChild(getter_AddRefs(child));
|
|
|
|
if (!child)
|
|
|
|
break;
|
|
|
|
node->RemoveChild(child, getter_AddRefs(dummy));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-04-06 06:28:28 +00:00
|
|
|
// Clear any buffered-up text we have. It's enough to set the length to 0.
|
|
|
|
// The buffer itself is allocated when we're created and deleted in our
|
|
|
|
// destructor, so don't mess with it.
|
2005-04-05 03:40:36 +00:00
|
|
|
mTextLength = 0;
|
|
|
|
|
2004-12-04 17:51:12 +00:00
|
|
|
return NS_OK;
|
2004-09-30 22:27:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsXMLFragmentContentSink::ProcessStyleLink(nsIContent* aElement,
|
2005-03-30 00:36:57 +00:00
|
|
|
const nsSubstring& aHref,
|
2011-09-29 06:19:26 +00:00
|
|
|
bool aAlternate,
|
2005-03-30 00:36:57 +00:00
|
|
|
const nsSubstring& aTitle,
|
|
|
|
const nsSubstring& aType,
|
|
|
|
const nsSubstring& aMedia)
|
2004-09-30 22:27:45 +00:00
|
|
|
{
|
|
|
|
// don't process until moved to document
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsXMLFragmentContentSink::LoadXSLStyleSheet(nsIURI* aUrl)
|
|
|
|
{
|
|
|
|
NS_NOTREACHED("fragments shouldn't have XSL style sheets");
|
|
|
|
return NS_ERROR_UNEXPECTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsXMLFragmentContentSink::StartLayout()
|
|
|
|
{
|
|
|
|
NS_NOTREACHED("fragments shouldn't layout");
|
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2011-08-01 07:48:24 +00:00
|
|
|
nsXMLFragmentContentSink::FinishFragmentParsing(nsIDOMDocumentFragment** aFragment)
|
2004-09-30 22:27:45 +00:00
|
|
|
{
|
2012-07-30 14:20:58 +00:00
|
|
|
*aFragment = nullptr;
|
|
|
|
mTargetDocument = nullptr;
|
|
|
|
mNodeInfoManager = nullptr;
|
|
|
|
mScriptLoader = nullptr;
|
|
|
|
mCSSLoader = nullptr;
|
2011-08-01 07:48:24 +00:00
|
|
|
mContentStack.Clear();
|
2012-07-30 14:20:58 +00:00
|
|
|
mDocumentURI = nullptr;
|
|
|
|
mDocShell = nullptr;
|
2014-04-10 09:20:00 +00:00
|
|
|
mDocElement = nullptr;
|
|
|
|
mCurrentHead = nullptr;
|
2004-12-04 17:51:12 +00:00
|
|
|
if (mParseError) {
|
|
|
|
//XXX PARSE_ERR from DOM3 Load and Save would be more appropriate
|
2012-07-30 14:20:58 +00:00
|
|
|
mRoot = nullptr;
|
2011-10-17 14:59:28 +00:00
|
|
|
mParseError = false;
|
2004-12-04 17:51:12 +00:00
|
|
|
return NS_ERROR_DOM_SYNTAX_ERR;
|
|
|
|
} else if (mRoot) {
|
2008-03-06 20:14:33 +00:00
|
|
|
nsresult rv = CallQueryInterface(mRoot, aFragment);
|
2012-07-30 14:20:58 +00:00
|
|
|
mRoot = nullptr;
|
2008-03-06 20:14:33 +00:00
|
|
|
return rv;
|
2004-12-04 17:51:12 +00:00
|
|
|
} else {
|
|
|
|
return NS_OK;
|
2004-09-30 22:27:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsXMLFragmentContentSink::SetTargetDocument(nsIDocument* aTargetDocument)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aTargetDocument);
|
|
|
|
|
|
|
|
mTargetDocument = aTargetDocument;
|
|
|
|
mNodeInfoManager = aTargetDocument->NodeInfoManager();
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2005-02-18 19:18:39 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsXMLFragmentContentSink::WillBuildContent()
|
|
|
|
{
|
2011-08-01 07:48:24 +00:00
|
|
|
PushContent(mRoot);
|
2005-02-18 19:18:39 +00:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsXMLFragmentContentSink::DidBuildContent()
|
|
|
|
{
|
2011-08-01 07:48:24 +00:00
|
|
|
// Note: we need to FlushText() here because if we don't, we might not get
|
|
|
|
// an end element to do it for us, so make sure.
|
|
|
|
if (!mParseError) {
|
|
|
|
FlushText();
|
2005-02-18 19:18:39 +00:00
|
|
|
}
|
2011-08-01 07:48:24 +00:00
|
|
|
PopContent();
|
2005-02-18 19:18:39 +00:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2005-06-16 18:59:59 +00:00
|
|
|
|
2007-01-30 21:21:06 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsXMLFragmentContentSink::DidProcessATokenImpl()
|
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2005-06-16 18:59:59 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsXMLFragmentContentSink::IgnoreFirstContainer()
|
|
|
|
{
|
|
|
|
NS_NOTREACHED("XML isn't as broken as HTML");
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
2011-08-01 07:48:28 +00:00
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2011-09-29 06:19:26 +00:00
|
|
|
nsXMLFragmentContentSink::SetPreventScriptExecution(bool aPrevent)
|
2011-08-01 07:48:28 +00:00
|
|
|
{
|
|
|
|
mPreventScriptExecution = aPrevent;
|
|
|
|
return NS_OK;
|
|
|
|
}
|