168168#include " nsSVGFeatures.h"
169169#include " MediaDecoder.h"
170170#include " DecoderTraits.h"
171- #include " mozilla/dom/DocumentFragment.h"
172171
173172#include " nsWrapperCacheInlines.h"
174173#include " nsViewportInfo.h"
@@ -1589,15 +1588,6 @@ nsContentUtils::CanCallerAccess(nsIPrincipal* aSubjectPrincipal,
15891588// static
15901589bool
15911590nsContentUtils::CanCallerAccess (nsIDOMNode *aNode)
1592- {
1593- nsCOMPtr<nsINode> node = do_QueryInterface (aNode);
1594- NS_ENSURE_TRUE (node, false );
1595- return CanCallerAccess (node);
1596- }
1597-
1598- // static
1599- bool
1600- nsContentUtils::CanCallerAccess (nsINode* aNode)
16011591{
16021592 // XXXbz why not check the IsCapabilityEnabled thing up front, and not bother
16031593 // with the system principal games? But really, there should be a simpler
@@ -1612,7 +1602,10 @@ nsContentUtils::CanCallerAccess(nsINode* aNode)
16121602 return true ;
16131603 }
16141604
1615- return CanCallerAccess (subjectPrincipal, aNode->NodePrincipal ());
1605+ nsCOMPtr<nsINode> node = do_QueryInterface (aNode);
1606+ NS_ENSURE_TRUE (node, false );
1607+
1608+ return CanCallerAccess (subjectPrincipal, node->NodePrincipal ());
16161609}
16171610
16181611// static
@@ -4052,22 +4045,8 @@ nsContentUtils::CreateContextualFragment(nsINode* aContextNode,
40524045 bool aPreventScriptExecution,
40534046 nsIDOMDocumentFragment** aReturn)
40544047{
4055- ErrorResult rv;
4056- *aReturn = CreateContextualFragment (aContextNode, aFragment,
4057- aPreventScriptExecution, rv).get ();
4058- return rv.ErrorCode ();
4059- }
4060-
4061- already_AddRefed<DocumentFragment>
4062- nsContentUtils::CreateContextualFragment (nsINode* aContextNode,
4063- const nsAString& aFragment,
4064- bool aPreventScriptExecution,
4065- ErrorResult& aRv)
4066- {
4067- if (!aContextNode) {
4068- aRv.Throw (NS_ERROR_INVALID_ARG );
4069- return nullptr ;
4070- }
4048+ *aReturn = nullptr ;
4049+ NS_ENSURE_ARG (aContextNode);
40714050
40724051 // If we don't have a document here, we can't get the right security context
40734052 // for compiling event handlers... so just bail out.
@@ -4079,8 +4058,8 @@ nsContentUtils::CreateContextualFragment(nsINode* aContextNode,
40794058#endif
40804059
40814060 if (isHTML) {
4082- nsRefPtr<DocumentFragment > frag =
4083- NS_NewDocumentFragment (document->NodeInfoManager (), aRv );
4061+ nsCOMPtr<nsIDOMDocumentFragment > frag;
4062+ NS_NewDocumentFragment (getter_AddRefs(frag), document->NodeInfoManager());
40844063
40854064 nsCOMPtr<nsIContent> contextAsContent = do_QueryInterface (aContextNode);
40864065 if (contextAsContent && !contextAsContent->IsElement ()) {
@@ -4091,23 +4070,28 @@ nsContentUtils::CreateContextualFragment(nsINode* aContextNode,
40914070 }
40924071 }
40934072
4073+ nsresult rv;
4074+ nsCOMPtr<nsIContent> fragment = do_QueryInterface (frag);
40944075 if (contextAsContent && !contextAsContent->IsHTML (nsGkAtoms::html)) {
4095- aRv = ParseFragmentHTML (aFragment, frag,
4096- contextAsContent->Tag (),
4097- contextAsContent->GetNameSpaceID (),
4098- (document->GetCompatibilityMode () ==
4076+ rv = ParseFragmentHTML (aFragment,
4077+ fragment,
4078+ contextAsContent->Tag (),
4079+ contextAsContent->GetNameSpaceID (),
4080+ (document->GetCompatibilityMode () ==
40994081 eCompatibility_NavQuirks),
4100- aPreventScriptExecution);
4082+ aPreventScriptExecution);
41014083 } else {
4102- aRv = ParseFragmentHTML (aFragment, frag,
4103- nsGkAtoms::body,
4104- kNameSpaceID_XHTML ,
4105- (document->GetCompatibilityMode () ==
4084+ rv = ParseFragmentHTML (aFragment,
4085+ fragment,
4086+ nsGkAtoms::body,
4087+ kNameSpaceID_XHTML ,
4088+ (document->GetCompatibilityMode () ==
41064089 eCompatibility_NavQuirks),
4107- aPreventScriptExecution);
4090+ aPreventScriptExecution);
41084091 }
41094092
4110- return frag.forget ();
4093+ frag.forget (aReturn);
4094+ return rv;
41114095 }
41124096
41134097 nsAutoTArray<nsString, 32 > tagStack;
@@ -4119,10 +4103,7 @@ nsContentUtils::CreateContextualFragment(nsINode* aContextNode,
41194103
41204104 while (content && content->IsElement ()) {
41214105 nsString& tagName = *tagStack.AppendElement ();
4122- if (!&tagName) {
4123- aRv.Throw (NS_ERROR_OUT_OF_MEMORY );
4124- return nullptr ;
4125- }
4106+ NS_ENSURE_TRUE (&tagName, NS_ERROR_OUT_OF_MEMORY );
41264107
41274108 tagName = content->NodeInfo ()->QualifiedName ();
41284109
@@ -4168,10 +4149,11 @@ nsContentUtils::CreateContextualFragment(nsINode* aContextNode,
41684149 content = content->GetParent ();
41694150 }
41704151
4171- nsCOMPtr<nsIDOMDocumentFragment> frag;
4172- aRv = ParseFragmentXML (aFragment, document, tagStack,
4173- aPreventScriptExecution, getter_AddRefs (frag));
4174- return static_cast <DocumentFragment*>(frag.forget ().get ());
4152+ return ParseFragmentXML (aFragment,
4153+ document,
4154+ tagStack,
4155+ aPreventScriptExecution,
4156+ aReturn);
41754157}
41764158
41774159/* static */
0 commit comments