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/. */
|
2017-03-28 05:41:50 +03:00
|
|
|
|
2004-10-01 02:27:45 +04:00
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsXMLContentSink.h"
|
|
|
|
#include "nsIFragmentContentSink.h"
|
|
|
|
#include "nsIXMLContentSink.h"
|
|
|
|
#include "nsContentSink.h"
|
|
|
|
#include "nsIExpatSink.h"
|
2009-06-24 01:22:16 +04:00
|
|
|
#include "nsIDTD.h"
|
2004-10-01 02:27:45 +04:00
|
|
|
#include "nsIDocument.h"
|
|
|
|
#include "nsIDOMDocumentFragment.h"
|
2007-02-09 03:15:14 +03:00
|
|
|
#include "nsIContent.h"
|
2006-12-26 20:47:52 +03:00
|
|
|
#include "nsGkAtoms.h"
|
2014-06-20 06:01:40 +04:00
|
|
|
#include "mozilla/dom/NodeInfo.h"
|
2004-10-01 02:27:45 +04:00
|
|
|
#include "nsContentCreatorFunctions.h"
|
2012-07-27 18:03:27 +04:00
|
|
|
#include "nsError.h"
|
2004-12-04 20:51:12 +03:00
|
|
|
#include "nsIConsoleService.h"
|
2006-08-25 20:34:57 +04:00
|
|
|
#include "nsIScriptError.h"
|
2006-08-12 08:46:43 +04:00
|
|
|
#include "nsTHashtable.h"
|
|
|
|
#include "nsHashKeys.h"
|
|
|
|
#include "nsTArray.h"
|
2008-02-09 01:07:51 +03:00
|
|
|
#include "nsCycleCollectionParticipant.h"
|
2011-08-01 11:48:24 +04:00
|
|
|
#include "nsIDocShell.h"
|
|
|
|
#include "mozilla/css/Loader.h"
|
2013-04-10 18:15:54 +04:00
|
|
|
#include "mozilla/dom/DocumentFragment.h"
|
2013-04-04 16:01:11 +04:00
|
|
|
#include "mozilla/dom/ProcessingInstruction.h"
|
2017-05-08 09:24:22 +03:00
|
|
|
#include "mozilla/dom/ScriptLoader.h"
|
2004-10-01 02:27:45 +04:00
|
|
|
|
2010-10-25 16:17:38 +04:00
|
|
|
using namespace mozilla::dom;
|
|
|
|
|
2004-10-01 02:27:45 +04:00
|
|
|
class nsXMLFragmentContentSink : public nsXMLContentSink,
|
|
|
|
public nsIFragmentContentSink
|
|
|
|
{
|
|
|
|
public:
|
2011-08-01 11:48:24 +04:00
|
|
|
nsXMLFragmentContentSink();
|
2004-10-01 02:27:45 +04:00
|
|
|
|
|
|
|
// nsISupports
|
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
2008-02-09 01:07:51 +03:00
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED_NO_UNLINK(nsXMLFragmentContentSink,
|
|
|
|
nsXMLContentSink)
|
2004-10-01 02:27:45 +04:00
|
|
|
|
|
|
|
// nsIExpatSink
|
2015-01-07 03:54:15 +03:00
|
|
|
NS_IMETHOD HandleDoctypeDecl(const nsAString& aSubset,
|
|
|
|
const nsAString& aName,
|
|
|
|
const nsAString& aSystemId,
|
|
|
|
const nsAString& aPublicId,
|
2015-03-21 19:28:04 +03:00
|
|
|
nsISupports* aCatalogData) override;
|
2015-01-07 03:54:15 +03:00
|
|
|
NS_IMETHOD HandleProcessingInstruction(const char16_t* aTarget,
|
2015-03-21 19:28:04 +03:00
|
|
|
const char16_t* aData) override;
|
2015-01-07 03:54:15 +03:00
|
|
|
NS_IMETHOD HandleXMLDeclaration(const char16_t* aVersion,
|
|
|
|
const char16_t* aEncoding,
|
2015-03-21 19:28:04 +03:00
|
|
|
int32_t aStandalone) override;
|
2015-01-07 03:54:15 +03:00
|
|
|
NS_IMETHOD ReportError(const char16_t* aErrorText,
|
2014-01-04 19:02:17 +04:00
|
|
|
const char16_t* aSourceText,
|
2015-01-07 03:54:15 +03:00
|
|
|
nsIScriptError* aError,
|
2015-03-21 19:28:04 +03:00
|
|
|
bool* aRetval) override;
|
2004-10-01 02:27:45 +04:00
|
|
|
|
|
|
|
// nsIContentSink
|
2015-03-21 19:28:04 +03:00
|
|
|
NS_IMETHOD WillBuildModel(nsDTDMode aDTDMode) override;
|
|
|
|
NS_IMETHOD DidBuildModel(bool aTerminated) override;
|
2017-06-18 14:37:50 +03:00
|
|
|
virtual void SetDocumentCharset(NotNull<const Encoding*> aEncoding) override;
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual nsISupports* GetTarget() override;
|
2007-01-31 00:21:06 +03:00
|
|
|
NS_IMETHOD DidProcessATokenImpl();
|
2004-10-01 02:27:45 +04:00
|
|
|
|
|
|
|
// nsIXMLContentSink
|
|
|
|
|
|
|
|
// nsIFragmentContentSink
|
2015-03-21 19:28:04 +03: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-10-01 02:27:45 +04:00
|
|
|
|
|
|
|
protected:
|
2014-07-09 01:23:16 +04:00
|
|
|
virtual ~nsXMLFragmentContentSink();
|
|
|
|
|
2015-01-07 03:54:15 +03:00
|
|
|
virtual bool SetDocElement(int32_t aNameSpaceID,
|
2017-10-03 01:05:19 +03:00
|
|
|
nsAtom* aTagName,
|
2015-03-21 19:28:04 +03:00
|
|
|
nsIContent* aContent) override;
|
2014-01-04 19:02:17 +04:00
|
|
|
virtual nsresult CreateElement(const char16_t** aAtts, uint32_t aAttsCount,
|
2014-06-20 06:01:40 +04:00
|
|
|
mozilla::dom::NodeInfo* aNodeInfo, uint32_t aLineNumber,
|
2011-09-29 10:19:26 +04:00
|
|
|
nsIContent** aResult, bool* aAppendContent,
|
2015-03-21 19:28:04 +03:00
|
|
|
mozilla::dom::FromParser aFromParser) override;
|
|
|
|
virtual nsresult CloseElement(nsIContent* aContent) override;
|
2004-10-01 02:27:45 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void MaybeStartLayout(bool aIgnorePendingSheets) override;
|
2007-01-31 00:21:06 +03:00
|
|
|
|
2004-10-01 02:27:45 +04:00
|
|
|
// nsContentSink overrides
|
2017-12-22 00:43:24 +03:00
|
|
|
virtual nsresult ProcessStyleLinkFromHeader(
|
|
|
|
const nsAString& aHref,
|
|
|
|
bool aAlternate,
|
|
|
|
const nsAString& aTitle,
|
|
|
|
const nsAString& aType,
|
|
|
|
const nsAString& aMedia,
|
|
|
|
const nsAString& aReferrerPolicy) override;
|
2017-08-15 07:05:00 +03:00
|
|
|
|
2017-12-22 00:43:24 +03:00
|
|
|
// nsXMLContentSink overrides
|
|
|
|
virtual nsresult MaybeProcessXSLTLink(
|
2017-12-22 00:43:24 +03:00
|
|
|
ProcessingInstruction* aProcessingInstruction,
|
2017-12-22 00:43:24 +03:00
|
|
|
const nsAString& aHref,
|
|
|
|
bool aAlternate,
|
|
|
|
const nsAString& aTitle,
|
|
|
|
const nsAString& aType,
|
|
|
|
const nsAString& aMedia,
|
|
|
|
const nsAString& aReferrerPolicy,
|
|
|
|
bool* aWasXSLT = nullptr) override;
|
2004-10-01 02:27:45 +04:00
|
|
|
|
|
|
|
nsCOMPtr<nsIDocument> mTargetDocument;
|
|
|
|
// the fragment
|
|
|
|
nsCOMPtr<nsIContent> mRoot;
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mParseError;
|
2004-10-01 02:27:45 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
static nsresult
|
2011-08-01 11:48:24 +04:00
|
|
|
NewXMLFragmentContentSinkHelper(nsIFragmentContentSink** aResult)
|
2004-10-01 02:27:45 +04:00
|
|
|
{
|
2011-08-01 11:48:24 +04:00
|
|
|
nsXMLFragmentContentSink* it = new nsXMLFragmentContentSink();
|
2017-07-06 15:00:35 +03:00
|
|
|
|
2004-10-01 02:27:45 +04:00
|
|
|
NS_ADDREF(*aResult = it);
|
2017-07-06 15:00:35 +03:00
|
|
|
|
2004-10-01 02:27:45 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
NS_NewXMLFragmentContentSink(nsIFragmentContentSink** aResult)
|
|
|
|
{
|
2011-08-01 11:48:24 +04:00
|
|
|
return NewXMLFragmentContentSinkHelper(aResult);
|
2004-10-01 02:27:45 +04:00
|
|
|
}
|
|
|
|
|
2011-08-01 11:48:24 +04:00
|
|
|
nsXMLFragmentContentSink::nsXMLFragmentContentSink()
|
2011-10-17 18:59:28 +04:00
|
|
|
: mParseError(false)
|
2004-10-01 02:27:45 +04:00
|
|
|
{
|
2012-01-20 16:03:49 +04:00
|
|
|
mRunsToCompletion = true;
|
2004-10-01 02:27:45 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsXMLFragmentContentSink::~nsXMLFragmentContentSink()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2017-08-30 02:02:48 +03:00
|
|
|
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsXMLFragmentContentSink)
|
2008-02-09 01:07:51 +03:00
|
|
|
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 05:29:05 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_CLASS(nsXMLFragmentContentSink)
|
|
|
|
|
2008-02-09 01:07:51 +03:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(nsXMLFragmentContentSink,
|
|
|
|
nsXMLContentSink)
|
2012-11-15 11:32:40 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mTargetDocument)
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mRoot)
|
2008-02-09 01:07:51 +03:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
2004-10-01 02:27:45 +04:00
|
|
|
|
2017-07-06 15:00:35 +03:00
|
|
|
NS_IMETHODIMP
|
2009-06-24 01:22:16 +04:00
|
|
|
nsXMLFragmentContentSink::WillBuildModel(nsDTDMode aDTDMode)
|
2004-10-01 02:27:45 +04:00
|
|
|
{
|
|
|
|
if (mRoot) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
mState = eXMLContentSinkState_InDocumentElement;
|
|
|
|
|
|
|
|
NS_ASSERTION(mTargetDocument, "Need a document!");
|
|
|
|
|
2013-04-10 18:15:54 +04:00
|
|
|
mRoot = new DocumentFragment(mNodeInfoManager);
|
2017-07-06 15:00:35 +03:00
|
|
|
|
2013-04-10 18:15:54 +04:00
|
|
|
return NS_OK;
|
2004-10-01 02:27:45 +04:00
|
|
|
}
|
|
|
|
|
2017-07-06 15:00:35 +03:00
|
|
|
NS_IMETHODIMP
|
2011-09-29 10:19:26 +04:00
|
|
|
nsXMLFragmentContentSink::DidBuildModel(bool aTerminated)
|
2004-10-01 02:27:45 +04:00
|
|
|
{
|
|
|
|
// Drop our reference to the parser to get rid of a circular
|
|
|
|
// reference.
|
2012-07-30 18:20:58 +04:00
|
|
|
mParser = nullptr;
|
2004-10-01 02:27:45 +04:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2017-07-06 15:00:35 +03:00
|
|
|
void
|
2017-06-18 14:37:50 +03:00
|
|
|
nsXMLFragmentContentSink::SetDocumentCharset(
|
|
|
|
NotNull<const Encoding*> aEncoding)
|
2004-10-01 02:27:45 +04:00
|
|
|
{
|
|
|
|
NS_NOTREACHED("fragments shouldn't set charset");
|
|
|
|
}
|
|
|
|
|
2004-11-02 22:52:32 +03:00
|
|
|
nsISupports *
|
|
|
|
nsXMLFragmentContentSink::GetTarget()
|
|
|
|
{
|
|
|
|
return mTargetDocument;
|
|
|
|
}
|
|
|
|
|
2004-10-01 02:27:45 +04:00
|
|
|
////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2012-08-22 19:56:38 +04:00
|
|
|
nsXMLFragmentContentSink::SetDocElement(int32_t aNameSpaceID,
|
2017-10-03 01:05:19 +03:00
|
|
|
nsAtom* aTagName,
|
2004-10-01 02:27:45 +04:00
|
|
|
nsIContent *aContent)
|
|
|
|
{
|
|
|
|
// this is a fragment, not a document
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2004-10-01 02:27:45 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
2014-01-04 19:02:17 +04:00
|
|
|
nsXMLFragmentContentSink::CreateElement(const char16_t** aAtts, uint32_t aAttsCount,
|
2014-06-20 06:01:40 +04:00
|
|
|
mozilla::dom::NodeInfo* aNodeInfo, uint32_t aLineNumber,
|
2011-09-29 10:19:26 +04:00
|
|
|
nsIContent** aResult, bool* aAppendContent,
|
2010-10-25 16:17:38 +04:00
|
|
|
FromParser /*aFromParser*/)
|
2004-10-01 02:27:45 +04:00
|
|
|
{
|
2008-09-25 20:58:11 +04:00
|
|
|
// Claim to not be coming from parser, since we don't do any of the
|
|
|
|
// fancy CloseElement stuff.
|
2004-10-01 02:27:45 +04:00
|
|
|
nsresult rv = nsXMLContentSink::CreateElement(aAtts, aAttsCount,
|
2008-09-25 20:58:11 +04:00
|
|
|
aNodeInfo, aLineNumber,
|
|
|
|
aResult, aAppendContent,
|
2010-10-25 16:17:38 +04:00
|
|
|
NOT_FROM_PARSER);
|
2004-10-01 02:27:45 +04:00
|
|
|
|
2006-11-04 08:45:02 +03:00
|
|
|
// When we aren't grabbing all of the content we, never open a doc
|
2005-02-18 22:18:39 +03: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 11:48:24 +04:00
|
|
|
if (mContentStack.Length() == 0) {
|
2011-10-17 18:59:28 +04:00
|
|
|
*aAppendContent = false;
|
2005-02-18 22:18:39 +03:00
|
|
|
}
|
|
|
|
|
2004-10-01 02:27:45 +04:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
2006-11-04 08:45:02 +03:00
|
|
|
nsXMLFragmentContentSink::CloseElement(nsIContent* aContent)
|
2004-10-01 02:27:45 +04:00
|
|
|
{
|
|
|
|
// don't do fancy stuff in nsXMLContentSink
|
2015-03-03 14:09:00 +03:00
|
|
|
if (mPreventScriptExecution &&
|
2017-03-28 05:41:50 +03:00
|
|
|
(aContent->IsHTMLElement(nsGkAtoms::script) ||
|
2015-03-03 14:09:00 +03:00
|
|
|
aContent->IsSVGElement(nsGkAtoms::script))) {
|
2011-08-01 11:48:28 +04:00
|
|
|
nsCOMPtr<nsIScriptElement> sele = do_QueryInterface(aContent);
|
2017-01-11 19:29:13 +03:00
|
|
|
if (sele) {
|
|
|
|
sele->PreventExecution();
|
|
|
|
} else {
|
|
|
|
NS_ASSERTION(nsNameSpaceManager::GetInstance()->mSVGDisabled, "Script did QI correctly, but wasn't a disabled SVG!");
|
|
|
|
}
|
2011-08-01 11:48:28 +04:00
|
|
|
}
|
2004-10-01 02:27:45 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2007-01-31 00:21:06 +03:00
|
|
|
void
|
2011-09-29 10:19:26 +04:00
|
|
|
nsXMLFragmentContentSink::MaybeStartLayout(bool aIgnorePendingSheets)
|
2007-01-31 00:21:06 +03:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2004-10-01 02:27:45 +04:00
|
|
|
////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2017-07-06 15:00:35 +03:00
|
|
|
nsXMLFragmentContentSink::HandleDoctypeDecl(const nsAString & aSubset,
|
|
|
|
const nsAString & aName,
|
|
|
|
const nsAString & aSystemId,
|
2004-10-01 02:27:45 +04:00
|
|
|
const nsAString & aPublicId,
|
|
|
|
nsISupports* aCatalogData)
|
|
|
|
{
|
|
|
|
NS_NOTREACHED("fragments shouldn't have doctype declarations");
|
2006-08-12 08:46:43 +04:00
|
|
|
|
2004-10-01 02:27:45 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2017-07-06 15:00:35 +03:00
|
|
|
nsXMLFragmentContentSink::HandleProcessingInstruction(const char16_t *aTarget,
|
2014-01-04 19:02:17 +04:00
|
|
|
const char16_t *aData)
|
2004-10-01 02:27:45 +04:00
|
|
|
{
|
|
|
|
FlushText();
|
|
|
|
|
|
|
|
const nsDependentString target(aTarget);
|
|
|
|
const nsDependentString data(aData);
|
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<ProcessingInstruction> node =
|
2013-04-04 16:01:11 +04:00
|
|
|
NS_NewXMLProcessingInstruction(mNodeInfoManager, target, data);
|
2004-10-01 02:27:45 +04:00
|
|
|
|
2013-04-04 16:01:11 +04:00
|
|
|
// no special processing here. that should happen when the fragment moves into the document
|
|
|
|
return AddContentAsLeaf(node);
|
2004-10-01 02:27:45 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2014-01-04 19:02:17 +04:00
|
|
|
nsXMLFragmentContentSink::HandleXMLDeclaration(const char16_t *aVersion,
|
|
|
|
const char16_t *aEncoding,
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t aStandalone)
|
2004-10-01 02:27:45 +04:00
|
|
|
{
|
|
|
|
NS_NOTREACHED("fragments shouldn't have XML declarations");
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2017-07-06 15:00:35 +03:00
|
|
|
nsXMLFragmentContentSink::ReportError(const char16_t* aErrorText,
|
2014-01-04 19:02:17 +04:00
|
|
|
const char16_t* aSourceText,
|
2006-08-25 20:34:57 +04:00
|
|
|
nsIScriptError *aError,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool *_retval)
|
2004-10-01 02:27:45 +04:00
|
|
|
{
|
2006-08-25 20:34:57 +04:00
|
|
|
NS_PRECONDITION(aError && aSourceText && aErrorText, "Check arguments!!!");
|
2004-12-04 20:51:12 +03:00
|
|
|
|
2006-08-25 20:34:57 +04:00
|
|
|
// The expat driver should report the error.
|
2011-10-17 18:59:28 +04:00
|
|
|
*_retval = true;
|
2006-08-25 20:34:57 +04:00
|
|
|
|
2011-10-17 18:59:28 +04:00
|
|
|
mParseError = true;
|
2004-12-04 20:51:12 +03:00
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
// Report the error to stderr.
|
|
|
|
fprintf(stderr,
|
|
|
|
"\n%s\n%s\n\n",
|
2006-02-03 17:18:39 +03:00
|
|
|
NS_LossyConvertUTF16toASCII(aErrorText).get(),
|
|
|
|
NS_LossyConvertUTF16toASCII(aSourceText).get());
|
2004-12-04 20:51:12 +03:00
|
|
|
#endif
|
|
|
|
|
|
|
|
// The following code is similar to the cleanup in nsXMLContentSink::ReportError()
|
|
|
|
mState = eXMLContentSinkState_InProlog;
|
|
|
|
|
|
|
|
// Clear the current content
|
2004-10-01 02:27:45 +04:00
|
|
|
nsCOMPtr<nsIDOMNode> node(do_QueryInterface(mRoot));
|
2004-12-04 20:51:12 +03: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 10:28:28 +04: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 07:40:36 +04:00
|
|
|
mTextLength = 0;
|
|
|
|
|
2017-07-06 15:00:35 +03:00
|
|
|
return NS_OK;
|
2004-10-01 02:27:45 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
2017-12-22 00:43:24 +03:00
|
|
|
nsXMLFragmentContentSink::ProcessStyleLinkFromHeader(
|
|
|
|
const nsAString& aHref,
|
|
|
|
bool aAlternate,
|
|
|
|
const nsAString& aTitle,
|
|
|
|
const nsAString& aType,
|
|
|
|
const nsAString& aMedia,
|
|
|
|
const nsAString& aReferrerPolicy)
|
2017-08-15 07:05:00 +03:00
|
|
|
|
2004-10-01 02:27:45 +04:00
|
|
|
{
|
2017-12-22 00:43:24 +03:00
|
|
|
NS_NOTREACHED("Shouldn't have headers for a fragment sink");
|
2004-10-01 02:27:45 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
2017-12-22 00:43:24 +03:00
|
|
|
nsXMLFragmentContentSink::MaybeProcessXSLTLink(
|
|
|
|
ProcessingInstruction* aProcessingInstruction,
|
|
|
|
const nsAString& aHref,
|
|
|
|
bool aAlternate,
|
|
|
|
const nsAString& aTitle,
|
|
|
|
const nsAString& aType,
|
|
|
|
const nsAString& aMedia,
|
|
|
|
const nsAString& aReferrerPolicy,
|
|
|
|
bool* aWasXSLT)
|
2004-10-01 02:27:45 +04:00
|
|
|
{
|
2017-12-22 00:43:24 +03:00
|
|
|
MOZ_ASSERT(!aWasXSLT, "Our one caller doesn't care about whether we're XSLT");
|
|
|
|
return NS_OK;
|
2004-10-01 02:27:45 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2017-07-06 15:00:35 +03:00
|
|
|
NS_IMETHODIMP
|
2011-08-01 11:48:24 +04:00
|
|
|
nsXMLFragmentContentSink::FinishFragmentParsing(nsIDOMDocumentFragment** aFragment)
|
2004-10-01 02:27:45 +04:00
|
|
|
{
|
2012-07-30 18:20:58 +04:00
|
|
|
*aFragment = nullptr;
|
|
|
|
mTargetDocument = nullptr;
|
|
|
|
mNodeInfoManager = nullptr;
|
|
|
|
mScriptLoader = nullptr;
|
|
|
|
mCSSLoader = nullptr;
|
2011-08-01 11:48:24 +04:00
|
|
|
mContentStack.Clear();
|
2012-07-30 18:20:58 +04:00
|
|
|
mDocumentURI = nullptr;
|
|
|
|
mDocShell = nullptr;
|
2014-04-10 13:20:00 +04:00
|
|
|
mDocElement = nullptr;
|
|
|
|
mCurrentHead = nullptr;
|
2004-12-04 20:51:12 +03:00
|
|
|
if (mParseError) {
|
|
|
|
//XXX PARSE_ERR from DOM3 Load and Save would be more appropriate
|
2012-07-30 18:20:58 +04:00
|
|
|
mRoot = nullptr;
|
2011-10-17 18:59:28 +04:00
|
|
|
mParseError = false;
|
2004-12-04 20:51:12 +03:00
|
|
|
return NS_ERROR_DOM_SYNTAX_ERR;
|
|
|
|
} else if (mRoot) {
|
2008-03-06 23:14:33 +03:00
|
|
|
nsresult rv = CallQueryInterface(mRoot, aFragment);
|
2012-07-30 18:20:58 +04:00
|
|
|
mRoot = nullptr;
|
2008-03-06 23:14:33 +03:00
|
|
|
return rv;
|
2004-12-04 20:51:12 +03:00
|
|
|
} else {
|
|
|
|
return NS_OK;
|
2004-10-01 02:27:45 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsXMLFragmentContentSink::SetTargetDocument(nsIDocument* aTargetDocument)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aTargetDocument);
|
|
|
|
|
|
|
|
mTargetDocument = aTargetDocument;
|
|
|
|
mNodeInfoManager = aTargetDocument->NodeInfoManager();
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2005-02-18 22:18:39 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsXMLFragmentContentSink::WillBuildContent()
|
|
|
|
{
|
2011-08-01 11:48:24 +04:00
|
|
|
PushContent(mRoot);
|
2005-02-18 22:18:39 +03:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsXMLFragmentContentSink::DidBuildContent()
|
|
|
|
{
|
2011-08-01 11:48:24 +04: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 22:18:39 +03:00
|
|
|
}
|
2011-08-01 11:48:24 +04:00
|
|
|
PopContent();
|
2005-02-18 22:18:39 +03:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2005-06-16 22:59:59 +04:00
|
|
|
|
2007-01-31 00:21:06 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsXMLFragmentContentSink::DidProcessATokenImpl()
|
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2005-06-16 22:59:59 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsXMLFragmentContentSink::IgnoreFirstContainer()
|
|
|
|
{
|
|
|
|
NS_NOTREACHED("XML isn't as broken as HTML");
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
2011-08-01 11:48:28 +04:00
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2011-09-29 10:19:26 +04:00
|
|
|
nsXMLFragmentContentSink::SetPreventScriptExecution(bool aPrevent)
|
2011-08-01 11:48:28 +04:00
|
|
|
{
|
|
|
|
mPreventScriptExecution = aPrevent;
|
|
|
|
return NS_OK;
|
|
|
|
}
|