Bug 1435430 part 3. Remove nsIXSLTProcessor::ImportStylesheet. r=mystor

MozReview-Commit-ID: Csqh40GjqJn
This commit is contained in:
Boris Zbarsky 2018-02-05 16:00:04 -05:00
parent 594dedafaa
commit daa2640fb6
3 changed files with 30 additions and 50 deletions

View File

@ -113,10 +113,13 @@ nsXMLPrettyPrinter::PrettyPrint(nsIDocument* aDocument,
// Transform the document
RefPtr<txMozillaXSLTProcessor> transformer = new txMozillaXSLTProcessor();
rv = transformer->ImportStylesheet(xslDocument);
NS_ENSURE_SUCCESS(rv, rv);
ErrorResult err;
nsCOMPtr<nsIDocument> xslDoc = do_QueryInterface(xslDocument);
transformer->ImportStylesheet(*xslDoc, err);
if (NS_WARN_IF(err.Failed())) {
return err.StealNSResult();
}
RefPtr<DocumentFragment> resultFragment =
transformer->TransformToFragment(*aDocument, *aDocument, err);
if (NS_WARN_IF(err.Failed())) {

View File

@ -10,19 +10,6 @@ interface nsIVariant;
[scriptable, uuid(4a91aeb3-4100-43ee-a21e-9866268757c5)]
interface nsIXSLTProcessor : nsISupports
{
/**
* Import the stylesheet into this XSLTProcessor for transformations.
*
* @param style The root-node of a XSLT stylesheet. This can be either
* a document node or an element node. If a document node
* then the document can contain either a XSLT stylesheet
* or a LRE stylesheet.
* If the argument is an element node it must be the
* xsl:stylesheet (or xsl:transform) element of an XSLT
* stylesheet.
*/
void importStylesheet(in nsIDOMNode style);
/**
* Transforms the node source applying the stylesheet given by the
* importStylesheet() function.

View File

@ -595,44 +595,41 @@ txMozillaXSLTProcessor::DoTransform()
return rv;
}
NS_IMETHODIMP
txMozillaXSLTProcessor::ImportStylesheet(nsIDOMNode *aStyle)
void
txMozillaXSLTProcessor::ImportStylesheet(nsINode& aStyle,
mozilla::ErrorResult& aRv)
{
NS_ENSURE_TRUE(aStyle, NS_ERROR_NULL_POINTER);
// We don't support importing multiple stylesheets yet.
NS_ENSURE_TRUE(!mStylesheetDocument && !mStylesheet,
NS_ERROR_NOT_IMPLEMENTED);
nsCOMPtr<nsINode> node = do_QueryInterface(aStyle);
if (!node || !nsContentUtils::SubjectPrincipalOrSystemIfNativeCaller()->Subsumes(node->NodePrincipal())) {
return NS_ERROR_DOM_SECURITY_ERR;
if (NS_WARN_IF(mStylesheetDocument || mStylesheet)) {
aRv.Throw(NS_ERROR_NOT_IMPLEMENTED);
return;
}
nsCOMPtr<nsINode> styleNode = do_QueryInterface(aStyle);
NS_ENSURE_TRUE(styleNode &&
(styleNode->IsElement() ||
styleNode->IsNodeOfType(nsINode::eDOCUMENT)),
NS_ERROR_INVALID_ARG);
if (!nsContentUtils::SubjectPrincipalOrSystemIfNativeCaller()->Subsumes(aStyle.NodePrincipal())) {
aRv.Throw(NS_ERROR_DOM_SECURITY_ERR);
return;
}
nsresult rv = TX_CompileStylesheet(styleNode, this,
if (NS_WARN_IF(!aStyle.IsElement() &&
!aStyle.IsNodeOfType(nsINode::eDOCUMENT))) {
aRv.Throw(NS_ERROR_INVALID_ARG);
return;
}
nsresult rv = TX_CompileStylesheet(&aStyle, this,
getter_AddRefs(mStylesheet));
// XXX set up exception context, bug 204658
NS_ENSURE_SUCCESS(rv, rv);
if (styleNode->IsElement()) {
mStylesheetDocument = styleNode->OwnerDoc();
NS_ENSURE_TRUE(mStylesheetDocument, NS_ERROR_UNEXPECTED);
mEmbeddedStylesheetRoot = static_cast<nsIContent*>(styleNode.get());
if (NS_WARN_IF(NS_FAILED(rv))) {
aRv.Throw(rv);
return;
}
else {
mStylesheetDocument = static_cast<nsIDocument*>(styleNode.get());
mStylesheetDocument = aStyle.OwnerDoc();
if (aStyle.IsElement()) {
mEmbeddedStylesheetRoot = aStyle.AsElement();
}
mStylesheetDocument->AddMutationObserver(this);
return NS_OK;
}
NS_IMETHODIMP
@ -1282,13 +1279,6 @@ txMozillaXSLTProcessor::Constructor(const GlobalObject& aGlobal,
return processor.forget();
}
void
txMozillaXSLTProcessor::ImportStylesheet(nsINode& stylesheet,
mozilla::ErrorResult& aRv)
{
aRv = ImportStylesheet(stylesheet.AsDOMNode());
}
already_AddRefed<nsIDocument>
txMozillaXSLTProcessor::TransformToDocument(nsINode& source,
mozilla::ErrorResult& aRv)