/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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/. */
NS_IMETHODIMP
nsXMLFragmentContentSink::WillBuildModel(nsDTDMode aDTDMode) { if (mRoot) { return NS_OK;
}
mState = eXMLContentSinkState_InDocumentElement;
NS_ASSERTION(mTargetDocument, "Need a document!");
mRoot = new (mNodeInfoManager) DocumentFragment(mNodeInfoManager);
return NS_OK;
}
NS_IMETHODIMP
nsXMLFragmentContentSink::DidBuildModel(bool aTerminated) { // Drop our reference to the parser to get rid of a circular // reference.
mParser = nullptr;
bool nsXMLFragmentContentSink::SetDocElement(int32_t aNameSpaceID,
nsAtom* aTagName,
nsIContent* aContent) { // this is a fragment, not a document returnfalse;
}
nsresult nsXMLFragmentContentSink::CreateElement( const char16_t** aAtts, uint32_t aAttsCount,
mozilla::dom::NodeInfo* aNodeInfo, uint32_t aLineNumber,
uint32_t aColumnNumber, nsIContent** aResult, bool* aAppendContent,
FromParser /*aFromParser*/) { // Claim to not be coming from parser, since we don't do any of the // fancy CloseElement stuff.
nsresult rv = nsXMLContentSink::CreateElement(
aAtts, aAttsCount, aNodeInfo, aLineNumber, aColumnNumber, aResult,
aAppendContent, NOT_FROM_PARSER);
// When we aren't grabbing all of the content we, never open a doc // element, we run into trouble on the first element, so we don't append, // and simply push this onto the content stack. if (mContentStack.Length() == 0) {
*aAppendContent = false;
}
return rv;
}
nsresult nsXMLFragmentContentSink::CloseElement(nsIContent* aContent) { // don't do fancy stuff in nsXMLContentSink if (mPreventScriptExecution && (aContent->IsHTMLElement(nsGkAtoms::script) ||
aContent->IsSVGElement(nsGkAtoms::script))) {
nsCOMPtr<nsIScriptElement> sele = do_QueryInterface(aContent); if (sele) {
sele->PreventExecution();
} else {
NS_ASSERTION(nsNameSpaceManager::GetInstance()->mSVGDisabled, "Script did QI correctly, but wasn't a disabled SVG!");
}
} return NS_OK;
}
// The expat driver should report the error.
*_retval = true;
mParseError = true;
#ifdef DEBUG // Report the error to stderr.
fprintf(stderr, "\n%s\n%s\n\n", NS_LossyConvertUTF16toASCII(aErrorText).get(),
NS_LossyConvertUTF16toASCII(aSourceText).get()); #endif
// The following code is similar to the cleanup in // nsXMLContentSink::ReportError()
mState = eXMLContentSinkState_InProlog;
// Clear the current content while (mRoot->GetLastChild()) {
mRoot->GetLastChild()->Remove();
}
// 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.
mTextLength = 0;
NS_IMETHODIMP
nsXMLFragmentContentSink::DidBuildContent() { // 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();
}
PopContent();
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.