mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-14 20:22:00 +00:00
Bug 1452183 part 3. Stop using nsIDOMDocumentFragment in C++. r=mccr8
This commit is contained in:
parent
0ac1ce2e6b
commit
38ecaf4bb7
@ -3869,15 +3869,11 @@ Element::SetOuterHTML(const nsAString& aOuterHTML, ErrorResult& aError)
|
||||
context = NS_NewHTMLBodyElement(info.forget(), FROM_PARSER_FRAGMENT);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMDocumentFragment> df;
|
||||
aError = nsContentUtils::CreateContextualFragment(context,
|
||||
aOuterHTML,
|
||||
true,
|
||||
getter_AddRefs(df));
|
||||
RefPtr<DocumentFragment> fragment =
|
||||
nsContentUtils::CreateContextualFragment(context, aOuterHTML, true, aError);
|
||||
if (aError.Failed()) {
|
||||
return;
|
||||
}
|
||||
nsCOMPtr<nsINode> fragment = do_QueryInterface(df);
|
||||
parent->ReplaceChild(*fragment, *this, aError);
|
||||
}
|
||||
|
||||
@ -3954,17 +3950,12 @@ Element::InsertAdjacentHTML(const nsAString& aPosition, const nsAString& aText,
|
||||
}
|
||||
|
||||
// couldn't parse directly
|
||||
nsCOMPtr<nsIDOMDocumentFragment> df;
|
||||
aError = nsContentUtils::CreateContextualFragment(destination,
|
||||
aText,
|
||||
true,
|
||||
getter_AddRefs(df));
|
||||
RefPtr<DocumentFragment> fragment =
|
||||
nsContentUtils::CreateContextualFragment(destination, aText, true, aError);
|
||||
if (aError.Failed()) {
|
||||
return;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsINode> fragment = do_QueryInterface(df);
|
||||
|
||||
// Suppress assertion about node removal mutation events that can't have
|
||||
// listeners anyway, because no one has had the chance to register mutation
|
||||
// listeners on the fragment that comes from the parser.
|
||||
|
@ -4929,19 +4929,6 @@ nsContentUtils::IsValidNodeName(nsAtom *aLocalName, nsAtom *aPrefix,
|
||||
(aNamespaceID == kNameSpaceID_XML || aPrefix != nsGkAtoms::xml);
|
||||
}
|
||||
|
||||
/* static */
|
||||
nsresult
|
||||
nsContentUtils::CreateContextualFragment(nsINode* aContextNode,
|
||||
const nsAString& aFragment,
|
||||
bool aPreventScriptExecution,
|
||||
nsIDOMDocumentFragment** aReturn)
|
||||
{
|
||||
ErrorResult rv;
|
||||
*aReturn = CreateContextualFragment(aContextNode, aFragment,
|
||||
aPreventScriptExecution, rv).take();
|
||||
return rv.StealNSResult();
|
||||
}
|
||||
|
||||
already_AddRefed<DocumentFragment>
|
||||
nsContentUtils::CreateContextualFragment(nsINode* aContextNode,
|
||||
const nsAString& aFragment,
|
||||
|
@ -70,7 +70,6 @@ class nsIContentSecurityPolicy;
|
||||
class nsIDocShellTreeItem;
|
||||
class nsIDocumentLoaderFactory;
|
||||
class nsIDOMDocument;
|
||||
class nsIDOMDocumentFragment;
|
||||
class nsIDOMEvent;
|
||||
class nsIDOMNode;
|
||||
class nsIDragSession;
|
||||
@ -1630,10 +1629,6 @@ public:
|
||||
* @param aSanitize whether the fragment should be sanitized prior to
|
||||
* injection
|
||||
*/
|
||||
static nsresult CreateContextualFragment(nsINode* aContextNode,
|
||||
const nsAString& aFragment,
|
||||
bool aPreventScriptExecution,
|
||||
nsIDOMDocumentFragment** aReturn);
|
||||
static already_AddRefed<mozilla::dom::DocumentFragment>
|
||||
CreateContextualFragment(nsINode* aContextNode, const nsAString& aFragment,
|
||||
bool aPreventScriptExecution,
|
||||
|
@ -95,12 +95,6 @@ class txXPathNativeNode
|
||||
public:
|
||||
static txXPathNode* createXPathNode(nsINode* aNode,
|
||||
bool aKeepRootAlive = false);
|
||||
static txXPathNode* createXPathNode(nsIDOMNode* aNode,
|
||||
bool aKeepRootAlive = false)
|
||||
{
|
||||
nsCOMPtr<nsINode> node = do_QueryInterface(aNode);
|
||||
return createXPathNode(node, aKeepRootAlive);
|
||||
}
|
||||
static txXPathNode* createXPathNode(nsIContent* aContent,
|
||||
bool aKeepRootAlive = false);
|
||||
static txXPathNode* createXPathNode(nsIDOMDocument* aDocument);
|
||||
|
@ -62,7 +62,7 @@ convertRtfToNode(txIEvalContext *aContext, txResultTreeFragment *aRtf)
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMDocumentFragment> domFragment =
|
||||
RefPtr<DocumentFragment> domFragment =
|
||||
new DocumentFragment(doc->NodeInfoManager());
|
||||
|
||||
txOutputFormat format;
|
||||
|
@ -8,7 +8,6 @@
|
||||
#include "nsIContent.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIDOMDocument.h"
|
||||
#include "nsIDOMDocumentFragment.h"
|
||||
#include "nsIDocumentTransformer.h"
|
||||
#include "nsCharsetSource.h"
|
||||
#include "nsIPrincipal.h"
|
||||
@ -19,6 +18,7 @@
|
||||
#include "mozilla/Encoding.h"
|
||||
#include "nsTextNode.h"
|
||||
#include "nsNameSpaceManager.h"
|
||||
#include "mozilla/dom/DocumentFragment.h"
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::dom;
|
||||
@ -29,10 +29,10 @@ txMozillaTextOutput::txMozillaTextOutput(nsITransformObserver* aObserver)
|
||||
mObserver = do_GetWeakReference(aObserver);
|
||||
}
|
||||
|
||||
txMozillaTextOutput::txMozillaTextOutput(nsIDOMDocumentFragment* aDest)
|
||||
txMozillaTextOutput::txMozillaTextOutput(DocumentFragment* aDest)
|
||||
{
|
||||
MOZ_COUNT_CTOR(txMozillaTextOutput);
|
||||
mTextParent = do_QueryInterface(aDest);
|
||||
mTextParent = aDest;
|
||||
mDocument = mTextParent->OwnerDoc();
|
||||
}
|
||||
|
||||
|
@ -11,13 +11,13 @@
|
||||
#include "nsWeakPtr.h"
|
||||
#include "txOutputFormat.h"
|
||||
|
||||
class nsIDOMDocumentFragment;
|
||||
class nsITransformObserver;
|
||||
class nsIDocument;
|
||||
class nsIContent;
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
class DocumentFragment;
|
||||
class Element;
|
||||
}
|
||||
}
|
||||
@ -26,7 +26,7 @@ class txMozillaTextOutput : public txAOutputXMLEventHandler
|
||||
{
|
||||
public:
|
||||
explicit txMozillaTextOutput(nsITransformObserver* aObserver);
|
||||
explicit txMozillaTextOutput(nsIDOMDocumentFragment* aDest);
|
||||
explicit txMozillaTextOutput(mozilla::dom::DocumentFragment* aDest);
|
||||
virtual ~txMozillaTextOutput();
|
||||
|
||||
TX_DECL_TXAXMLEVENTHANDLER
|
||||
|
@ -18,7 +18,6 @@
|
||||
#include "nsGkAtoms.h"
|
||||
#include "txLog.h"
|
||||
#include "nsIConsoleService.h"
|
||||
#include "nsIDOMDocumentFragment.h"
|
||||
#include "nsNameSpaceManager.h"
|
||||
#include "txStringUtils.h"
|
||||
#include "txURIUtils.h"
|
||||
@ -28,6 +27,7 @@
|
||||
#include "mozilla/StyleSheetInlines.h"
|
||||
#include "mozilla/css/Loader.h"
|
||||
#include "mozilla/dom/DocumentType.h"
|
||||
#include "mozilla/dom/DocumentFragment.h"
|
||||
#include "mozilla/dom/Element.h"
|
||||
#include "mozilla/dom/ScriptLoader.h"
|
||||
#include "mozilla/Encoding.h"
|
||||
@ -74,7 +74,7 @@ txMozillaXMLOutput::txMozillaXMLOutput(txOutputFormat* aFormat,
|
||||
}
|
||||
|
||||
txMozillaXMLOutput::txMozillaXMLOutput(txOutputFormat* aFormat,
|
||||
nsIDOMDocumentFragment* aFragment,
|
||||
DocumentFragment* aFragment,
|
||||
bool aNoFixup)
|
||||
: mTreeDepth(0),
|
||||
mBadChildLevel(0),
|
||||
@ -88,7 +88,7 @@ txMozillaXMLOutput::txMozillaXMLOutput(txOutputFormat* aFormat,
|
||||
mOutputFormat.merge(*aFormat);
|
||||
mOutputFormat.setFromDefaults();
|
||||
|
||||
mCurrentNode = do_QueryInterface(aFragment);
|
||||
mCurrentNode = aFragment;
|
||||
mDocument = mCurrentNode->OwnerDoc();
|
||||
mNodeInfoManager = mDocument->NodeInfoManager();
|
||||
}
|
||||
|
@ -19,12 +19,17 @@
|
||||
class nsIContent;
|
||||
class nsIDOMDocument;
|
||||
class nsAtom;
|
||||
class nsIDOMDocumentFragment;
|
||||
class nsITransformObserver;
|
||||
class nsNodeInfoManager;
|
||||
class nsIDocument;
|
||||
class nsINode;
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
class DocumentFragment;
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
class txTransformNotifier final : public nsIScriptLoaderObserver,
|
||||
public nsICSSLoaderObserver
|
||||
{
|
||||
@ -63,7 +68,7 @@ public:
|
||||
txMozillaXMLOutput(txOutputFormat* aFormat,
|
||||
nsITransformObserver* aObserver);
|
||||
txMozillaXMLOutput(txOutputFormat* aFormat,
|
||||
nsIDOMDocumentFragment* aFragment,
|
||||
mozilla::dom::DocumentFragment* aFragment,
|
||||
bool aNoFixup);
|
||||
~txMozillaXMLOutput();
|
||||
|
||||
|
@ -11,7 +11,6 @@
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIDOMDocument.h"
|
||||
#include "nsIDOMDocumentFragment.h"
|
||||
#include "nsIDOMNodeList.h"
|
||||
#include "nsIIOService.h"
|
||||
#include "nsILoadGroup.h"
|
||||
@ -71,7 +70,7 @@ private:
|
||||
class txToFragmentHandlerFactory : public txAOutputHandlerFactory
|
||||
{
|
||||
public:
|
||||
explicit txToFragmentHandlerFactory(nsIDOMDocumentFragment* aFragment)
|
||||
explicit txToFragmentHandlerFactory(DocumentFragment* aFragment)
|
||||
: mFragment(aFragment)
|
||||
{
|
||||
}
|
||||
@ -79,7 +78,7 @@ public:
|
||||
TX_DECL_TXAOUTPUTHANDLERFACTORY
|
||||
|
||||
private:
|
||||
nsCOMPtr<nsIDOMDocumentFragment> mFragment;
|
||||
RefPtr<DocumentFragment> mFragment;
|
||||
};
|
||||
|
||||
nsresult
|
||||
@ -191,8 +190,7 @@ txToFragmentHandlerFactory::createHandlerWith(txOutputFormat* aFormat,
|
||||
{
|
||||
txOutputFormat format;
|
||||
format.merge(*aFormat);
|
||||
nsCOMPtr<nsINode> node = do_QueryInterface(mFragment);
|
||||
nsCOMPtr<nsIDocument> doc = node->OwnerDoc();
|
||||
nsCOMPtr<nsIDocument> doc = mFragment->OwnerDoc();
|
||||
|
||||
if (doc->IsHTMLDocument()) {
|
||||
format.mMethod = eHTMLOutput;
|
||||
@ -807,7 +805,7 @@ txMozillaXSLTProcessor::SetParameter(const nsAString& aNamespaceURI,
|
||||
nsresult rv = value->GetAsISupports(getter_AddRefs(supports));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIDOMNode> node = do_QueryInterface(supports);
|
||||
nsCOMPtr<nsINode> node = do_QueryInterface(supports);
|
||||
if (node) {
|
||||
if (!nsContentUtils::CanCallerAccess(node)) {
|
||||
return NS_ERROR_DOM_SECURITY_ERR;
|
||||
@ -1395,7 +1393,7 @@ txVariable::Convert(nsIVariant *aValue, txAExprResult** aResult)
|
||||
nsresult rv = aValue->GetAsISupports(getter_AddRefs(supports));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIDOMNode> node = do_QueryInterface(supports);
|
||||
nsCOMPtr<nsINode> node = do_QueryInterface(supports);
|
||||
if (node) {
|
||||
nsAutoPtr<txXPathNode> xpathNode(txXPathNativeNode::createXPathNode(node));
|
||||
if (!xpathNode) {
|
||||
@ -1493,7 +1491,7 @@ txVariable::Convert(nsIVariant *aValue, txAExprResult** aResult)
|
||||
uint32_t i;
|
||||
for (i = 0; i < count; ++i) {
|
||||
nsISupports *supports = values[i];
|
||||
nsCOMPtr<nsIDOMNode> node = do_QueryInterface(supports);
|
||||
nsCOMPtr<nsINode> node = do_QueryInterface(supports);
|
||||
NS_ASSERTION(node, "Huh, we checked this in SetParameter?");
|
||||
|
||||
nsAutoPtr<txXPathNode> xpathNode(
|
||||
|
@ -8,8 +8,8 @@
|
||||
#include "nsHtml5TreeBuilder.h"
|
||||
#include "nsHtml5TreeOpExecutor.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsIDOMDocumentFragment.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "mozilla/dom/DocumentFragment.h"
|
||||
|
||||
NS_IMPL_ISUPPORTS0(nsHtml5StringParser)
|
||||
|
||||
@ -45,9 +45,8 @@ nsHtml5StringParser::ParseFragment(const nsAString& aSourceBuffer,
|
||||
NS_ASSERTION(!aTargetNode->IsInUncomposedDoc(),
|
||||
"If script execution isn't prevented, "
|
||||
"the target node must not be in doc.");
|
||||
nsCOMPtr<nsIDOMDocumentFragment> domFrag = do_QueryInterface(aTargetNode);
|
||||
NS_ASSERTION(
|
||||
domFrag,
|
||||
aTargetNode->NodeType() == nsINode::DOCUMENT_FRAGMENT_NODE,
|
||||
"If script execution isn't prevented, must parse to DOM fragment.");
|
||||
}
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user