Bug 844457 - Move XSLTProcessor to WebIDL. r=peterv

--HG--
rename : dom/xslt/nsIXSLTProcessor.idl => dom/webidl/XSLTProcessor.webidl
rename : dom/xslt/xml/txXMLUtils.cpp => dom/xslt/base/txExpandedName.cpp
rename : dom/xslt/xml/txXMLUtils.h => dom/xslt/base/txExpandedName.h
This commit is contained in:
Tom Schuster 2014-10-10 14:21:54 +02:00
parent 91916fc55f
commit ced1cd1fbd
21 changed files with 430 additions and 157 deletions

View File

@ -78,8 +78,8 @@ function testVariablesAndPropertiesFiltering() {
"There should be 0 variables displayed in the with scope.");
is(functionScope.target.querySelectorAll(".variables-view-variable:not([unmatched])").length, 0,
"There should be 0 variables displayed in the function scope.");
isnot(globalScope.target.querySelectorAll(".variables-view-variable:not([unmatched])").length, 0,
"There should be some variables displayed in the global scope.");
is(globalScope.target.querySelectorAll(".variables-view-variable:not([unmatched])").length, 0,
"There should be 0 variables displayed in the global scope.");
is(withScope.target.querySelectorAll(".variables-view-property:not([unmatched])").length, 0,
"There should be 0 properties displayed in the with scope.");

View File

@ -72,10 +72,6 @@
#include "nsAutoPtr.h"
#include "nsMemory.h"
// Tranformiix
#include "nsIXSLTProcessor.h"
#include "nsIXSLTProcessorPrivate.h"
// includes needed for the prototype chain interfaces
#include "nsIDOMCSSCharsetRule.h"
#include "nsIDOMCSSImportRule.h"
@ -283,9 +279,6 @@ static nsDOMClassInfoData sClassInfoData[] = {
NS_DEFINE_CLASSINFO_DATA(CSSSupportsRule, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(XSLTProcessor, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(XPathNSResolver, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
@ -336,36 +329,6 @@ static nsDOMClassInfoData sClassInfoData[] = {
DOM_DEFAULT_SCRIPTABLE_FLAGS)
};
#define NS_DEFINE_CONTRACT_CTOR(_class, _contract_id) \
static nsresult \
_class##Ctor(nsISupports** aInstancePtrResult) \
{ \
nsresult rv = NS_OK; \
nsCOMPtr<nsISupports> native = do_CreateInstance(_contract_id, &rv); \
native.forget(aInstancePtrResult); \
return rv; \
}
NS_DEFINE_CONTRACT_CTOR(XSLTProcessor,
"@mozilla.org/document-transformer;1?type=xslt")
#undef NS_DEFINE_CONTRACT_CTOR
struct nsConstructorFuncMapData
{
int32_t mDOMClassInfoID;
nsDOMConstructorFunc mConstructorFunc;
};
#define NS_DEFINE_CONSTRUCTOR_FUNC_DATA(_class, _func) \
{ eDOMClassInfo_##_class##_id, _func },
static const nsConstructorFuncMapData kConstructorFuncMap[] =
{
NS_DEFINE_CONSTRUCTOR_FUNC_DATA(XSLTProcessor, XSLTProcessorCtor)
};
#undef NS_DEFINE_CONSTRUCTOR_FUNC_DATA
nsIXPConnect *nsDOMClassInfo::sXPConnect = nullptr;
bool nsDOMClassInfo::sIsInitialized = false;
@ -774,11 +737,6 @@ nsDOMClassInfo::Init()
DOM_CLASSINFO_MAP_ENTRY(nsIDOMCSSSupportsRule)
DOM_CLASSINFO_MAP_END
DOM_CLASSINFO_MAP_BEGIN(XSLTProcessor, nsIXSLTProcessor)
DOM_CLASSINFO_MAP_ENTRY(nsIXSLTProcessor)
DOM_CLASSINFO_MAP_ENTRY(nsIXSLTProcessorPrivate)
DOM_CLASSINFO_MAP_END
DOM_CLASSINFO_MAP_BEGIN(XPathNSResolver, nsIDOMXPathNSResolver)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMXPathNSResolver)
DOM_CLASSINFO_MAP_END
@ -1437,12 +1395,6 @@ nsDOMClassInfo::ShutDown()
static nsDOMConstructorFunc
FindConstructorFunc(const nsDOMClassInfoData *aDOMClassInfoData)
{
for (uint32_t i = 0; i < ArrayLength(kConstructorFuncMap); ++i) {
if (&sClassInfoData[kConstructorFuncMap[i].mDOMClassInfoID] ==
aDOMClassInfoData) {
return kConstructorFuncMap[i].mConstructorFunc;
}
}
return nullptr;
}

View File

@ -37,9 +37,6 @@ DOMCI_CLASS(TreeColumn)
DOMCI_CLASS(CSSMozDocumentRule)
DOMCI_CLASS(CSSSupportsRule)
// XSLTProcessor
DOMCI_CLASS(XSLTProcessor)
// DOM Level 3 XPath objects
DOMCI_CLASS(XPathNSResolver)

View File

@ -1533,6 +1533,10 @@ DOMInterfaces = {
'nativeOwnership': 'owned',
},
'XSLTProcessor': {
'nativeType': 'txMozillaXSLTProcessor',
},
'XULDocument': {
'headerFile': 'XULDocument.h'
},

View File

@ -0,0 +1,109 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* 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/. */
interface nsIVariant;
[Constructor]
interface XSLTProcessor {
/**
* 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.
*/
[Throws]
void importStylesheet(Node style);
/**
* Transforms the node source applying the stylesheet given by
* the importStylesheet() function. The owner document of the output node
* owns the returned document fragment.
*
* @param source The node to be transformed
* @param output This document is used to generate the output
* @return DocumentFragment The result of the transformation
*/
[Throws]
DocumentFragment transformToFragment(Node source,
Document output);
/**
* Transforms the node source applying the stylesheet given by the
* importStylesheet() function.
*
* @param source The node to be transformed
* @return Document The result of the transformation
*/
[Throws]
Document transformToDocument(Node source);
/**
* Sets a parameter to be used in subsequent transformations with this
* nsIXSLTProcessor. If the parameter doesn't exist in the stylesheet the
* parameter will be ignored.
*
* @param namespaceURI The namespaceURI of the XSLT parameter
* @param localName The local name of the XSLT parameter
* @param value The new value of the XSLT parameter
*/
[Throws]
void setParameter([TreatNullAs=EmptyString] DOMString namespaceURI,
DOMString localName,
any value);
/**
* Gets a parameter if previously set by setParameter. Returns null
* otherwise.
*
* @param namespaceURI The namespaceURI of the XSLT parameter
* @param localName The local name of the XSLT parameter
* @return nsIVariant The value of the XSLT parameter
*/
[Throws]
nsIVariant? getParameter([TreatNullAs=EmptyString] DOMString namespaceURI,
DOMString localName);
/**
* Removes a parameter, if set. This will make the processor use the
* default-value for the parameter as specified in the stylesheet.
*
* @param namespaceURI The namespaceURI of the XSLT parameter
* @param localName The local name of the XSLT parameter
*/
[Throws]
void removeParameter([TreatNullAs=EmptyString] DOMString namespaceURI,
DOMString localName);
/**
* Removes all set parameters from this nsIXSLTProcessor. This will make
* the processor use the default-value for all parameters as specified in
* the stylesheet.
*/
void clearParameters();
/**
* Remove all parameters and stylesheets from this nsIXSLTProcessor.
*/
void reset();
/**
* Disables all loading of external documents, such as from
* <xsl:import> and document()
* Defaults to off and is *not* reset by calls to reset()
*/
[ChromeOnly]
const unsigned long DISABLE_ALL_LOADS = 1;
/**
* Flags for this processor. Defaults to 0. See individual flags above
* for documentation for effect of reset()
*/
[ChromeOnly]
attribute unsigned long flags;
};

View File

@ -528,6 +528,7 @@ WEBIDL_FILES = [
'XPathEvaluator.webidl',
'XPathExpression.webidl',
'XPathResult.webidl',
'XSLTProcessor.webidl',
'XULCommandEvent.webidl',
'XULDocument.webidl',
'XULElement.webidl',

View File

@ -6,6 +6,7 @@
UNIFIED_SOURCES += [
'txDouble.cpp',
'txExpandedName.cpp',
'txExpandedNameMap.cpp',
'txList.cpp',
'txNamespaceMap.cpp',

View File

@ -0,0 +1,41 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* 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/. */
#include "txExpandedName.h"
#include "nsString.h"
#include "nsReadableUtils.h"
#include "txStringUtils.h"
#include "txNamespaceMap.h"
#include "txXMLUtils.h"
nsresult
txExpandedName::init(const nsAString& aQName, txNamespaceMap* aResolver,
bool aUseDefault)
{
const nsAFlatString& qName = PromiseFlatString(aQName);
const char16_t* colon;
bool valid = XMLUtils::isValidQName(qName, &colon);
if (!valid) {
return NS_ERROR_FAILURE;
}
if (colon) {
nsCOMPtr<nsIAtom> prefix = do_GetAtom(Substring(qName.get(), colon));
int32_t namespaceID = aResolver->lookupNamespace(prefix);
if (namespaceID == kNameSpaceID_Unknown)
return NS_ERROR_FAILURE;
mNamespaceID = namespaceID;
const char16_t *end;
qName.EndReading(end);
mLocalName = do_GetAtom(Substring(colon + 1, end));
}
else {
mNamespaceID = aUseDefault ? aResolver->lookupNamespace(nullptr) :
kNameSpaceID_None;
mLocalName = do_GetAtom(aQName);
}
return NS_OK;
}

View File

@ -0,0 +1,70 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* 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/. */
#ifndef TRANSFRMX_EXPANDEDNAME_H
#define TRANSFRMX_EXPANDEDNAME_H
#include "nsCOMPtr.h"
#include "nsIAtom.h"
#include "mozilla/dom/NameSpaceConstants.h"
class txNamespaceMap;
class txExpandedName {
public:
txExpandedName() : mNamespaceID(kNameSpaceID_None)
{
}
txExpandedName(int32_t aNsID,
nsIAtom* aLocalName) : mNamespaceID(aNsID),
mLocalName(aLocalName)
{
}
txExpandedName(const txExpandedName& aOther) :
mNamespaceID(aOther.mNamespaceID),
mLocalName(aOther.mLocalName)
{
}
nsresult init(const nsAString& aQName, txNamespaceMap* aResolver,
bool aUseDefault);
void reset()
{
mNamespaceID = kNameSpaceID_None;
mLocalName = nullptr;
}
bool isNull()
{
return mNamespaceID == kNameSpaceID_None && !mLocalName;
}
txExpandedName& operator = (const txExpandedName& rhs)
{
mNamespaceID = rhs.mNamespaceID;
mLocalName = rhs.mLocalName;
return *this;
}
bool operator == (const txExpandedName& rhs) const
{
return ((mLocalName == rhs.mLocalName) &&
(mNamespaceID == rhs.mNamespaceID));
}
bool operator != (const txExpandedName& rhs) const
{
return ((mLocalName != rhs.mLocalName) ||
(mNamespaceID != rhs.mNamespaceID));
}
int32_t mNamespaceID;
nsCOMPtr<nsIAtom> mLocalName;
};
#endif

View File

@ -6,8 +6,9 @@
#ifndef TRANSFRMX_EXPANDEDNAMEMAP_H
#define TRANSFRMX_EXPANDEDNAMEMAP_H
#include "nsAutoPtr.h"
#include "nsError.h"
#include "txXMLUtils.h"
#include "txExpandedName.h"
#include "nsTArray.h"
class txExpandedNameMap_base {

View File

@ -15,3 +15,4 @@
[test_bug616774.html]
[test_bug667315.html]
[test_exslt_regex.html]
[test_parameter.html]

View File

@ -0,0 +1,31 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Test for setParameter/getParameter</title>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<p id="display"></p>
<div id="content" style="display: none"></div>
<pre id="test">
<script>
var processor = new XSLTProcessor();
processor.setParameter(null, "test", "hello");
is(processor.getParameter(null, "test"), "hello", "null namespace works");
processor.setParameter("foo", "bar", "foobar");
is(processor.getParameter("foo", "bar"), "foobar", "non-null namespace works");
processor.setParameter(null, "test", 123);
is(processor.getParameter(null, "test"), 123, "number value works");
processor.removeParameter(null, "test");
is(processor.getParameter(null, "test"), null, "removeParameter works");
is(processor.getParameter(null, "not-here"), null, "nonexistant parameter");
</script>
</pre>
</body>
</html>

View File

@ -16,38 +16,8 @@
#include "txXPathTreeWalker.h"
#include "nsContentUtils.h"
nsresult
txExpandedName::init(const nsAString& aQName, txNamespaceMap* aResolver,
bool aUseDefault)
{
const nsAFlatString& qName = PromiseFlatString(aQName);
const char16_t* colon;
bool valid = XMLUtils::isValidQName(qName, &colon);
if (!valid) {
return NS_ERROR_FAILURE;
}
if (colon) {
nsCOMPtr<nsIAtom> prefix = do_GetAtom(Substring(qName.get(), colon));
int32_t namespaceID = aResolver->lookupNamespace(prefix);
if (namespaceID == kNameSpaceID_Unknown)
return NS_ERROR_FAILURE;
mNamespaceID = namespaceID;
const char16_t *end;
qName.EndReading(end);
mLocalName = do_GetAtom(Substring(colon + 1, end));
}
else {
mNamespaceID = aUseDefault ? aResolver->lookupNamespace(nullptr) :
kNameSpaceID_None;
mLocalName = do_GetAtom(aQName);
}
return NS_OK;
}
//------------------------------/
//- Implementation of XMLUtils -/
//------------------------------/
//- Implementation of XMLUtils -/
//------------------------------/
// static

View File

@ -11,9 +11,7 @@
#define MITRE_XMLUTILS_H
#include "txCore.h"
#include "nsCOMPtr.h"
#include "nsDependentSubstring.h"
#include "nsIAtom.h"
#include "txXPathNode.h"
#define kExpatSeparatorChar 0xFFFF
@ -22,62 +20,6 @@ extern "C" int MOZ_XMLIsLetter(const char* ptr);
extern "C" int MOZ_XMLIsNCNameChar(const char* ptr);
class nsIAtom;
class txNamespaceMap;
class txExpandedName {
public:
txExpandedName() : mNamespaceID(kNameSpaceID_None)
{
}
txExpandedName(int32_t aNsID,
nsIAtom* aLocalName) : mNamespaceID(aNsID),
mLocalName(aLocalName)
{
}
txExpandedName(const txExpandedName& aOther) :
mNamespaceID(aOther.mNamespaceID),
mLocalName(aOther.mLocalName)
{
}
nsresult init(const nsAString& aQName, txNamespaceMap* aResolver,
bool aUseDefault);
void reset()
{
mNamespaceID = kNameSpaceID_None;
mLocalName = nullptr;
}
bool isNull()
{
return mNamespaceID == kNameSpaceID_None && !mLocalName;
}
txExpandedName& operator = (const txExpandedName& rhs)
{
mNamespaceID = rhs.mNamespaceID;
mLocalName = rhs.mLocalName;
return *this;
}
bool operator == (const txExpandedName& rhs) const
{
return ((mLocalName == rhs.mLocalName) &&
(mNamespaceID == rhs.mNamespaceID));
}
bool operator != (const txExpandedName& rhs) const
{
return ((mLocalName != rhs.mLocalName) ||
(mNamespaceID != rhs.mNamespaceID));
}
int32_t mNamespaceID;
nsCOMPtr<nsIAtom> mLocalName;
};
class XMLUtils {

View File

@ -4,6 +4,10 @@
# 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/.
EXPORTS.mozilla.dom += [
'txMozillaXSLTProcessor.h'
]
UNIFIED_SOURCES += [
'txBufferingHandler.cpp',
'txCurrentFunctionCall.cpp',

View File

@ -10,6 +10,7 @@
#include "txCore.h"
#include "nsString.h"
#include "txXMLUtils.h"
#include "txExpandedName.h"
#include "txNamespaceMap.h"
#include "nsAutoPtr.h"
#include "txXSLTNumber.h"

View File

@ -11,7 +11,6 @@
#include "nsIDOMElement.h"
#include "nsIDOMText.h"
#include "nsIDocument.h"
#include "nsDOMClassInfoID.h"
#include "nsIDOMDocument.h"
#include "nsIDOMDocumentFragment.h"
#include "nsIDOMNodeList.h"
@ -36,6 +35,8 @@
#include "nsIScriptSecurityManager.h"
#include "nsJSUtils.h"
#include "nsIXPConnect.h"
#include "mozilla/dom/DocumentFragment.h"
#include "mozilla/dom/XSLTProcessorBinding.h"
using namespace mozilla::dom;
@ -326,27 +327,37 @@ ImplCycleCollectionTraverse(nsCycleCollectionTraversalCallback& aCallback,
* txMozillaXSLTProcessor
*/
NS_IMPL_CYCLE_COLLECTION(txMozillaXSLTProcessor, mEmbeddedStylesheetRoot,
mSource, mVariables)
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(txMozillaXSLTProcessor,
mOwner, mEmbeddedStylesheetRoot,
mSource, mVariables)
NS_IMPL_CYCLE_COLLECTING_ADDREF(txMozillaXSLTProcessor)
NS_IMPL_CYCLE_COLLECTING_RELEASE(txMozillaXSLTProcessor)
DOMCI_DATA(XSLTProcessor, txMozillaXSLTProcessor)
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(txMozillaXSLTProcessor)
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
NS_INTERFACE_MAP_ENTRY(nsIXSLTProcessor)
NS_INTERFACE_MAP_ENTRY(nsIXSLTProcessorPrivate)
NS_INTERFACE_MAP_ENTRY(nsIDocumentTransformer)
NS_INTERFACE_MAP_ENTRY(nsIMutationObserver)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIXSLTProcessor)
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(XSLTProcessor)
NS_INTERFACE_MAP_END
txMozillaXSLTProcessor::txMozillaXSLTProcessor() : mStylesheetDocument(nullptr),
mTransformResult(NS_OK),
mCompileResult(NS_OK),
mFlags(0)
txMozillaXSLTProcessor::txMozillaXSLTProcessor()
: mOwner(nullptr),
mStylesheetDocument(nullptr),
mTransformResult(NS_OK),
mCompileResult(NS_OK),
mFlags(0)
{
}
txMozillaXSLTProcessor::txMozillaXSLTProcessor(nsISupports* aOwner)
: mOwner(aOwner),
mStylesheetDocument(nullptr),
mTransformResult(NS_OK),
mCompileResult(NS_OK),
mFlags(0)
{
}
@ -1262,6 +1273,80 @@ txMozillaXSLTProcessor::ContentRemoved(nsIDocument* aDocument,
mStylesheet = nullptr;
}
/* virtual */ JSObject*
txMozillaXSLTProcessor::WrapObject(JSContext* aCx)
{
return XSLTProcessorBinding::Wrap(aCx, this);
}
/* static */ already_AddRefed<txMozillaXSLTProcessor>
txMozillaXSLTProcessor::Constructor(const GlobalObject& aGlobal,
mozilla::ErrorResult& aRv)
{
nsRefPtr<txMozillaXSLTProcessor> processor =
new txMozillaXSLTProcessor(aGlobal.GetAsSupports());
return processor.forget();
}
void
txMozillaXSLTProcessor::ImportStylesheet(nsINode& stylesheet,
mozilla::ErrorResult& aRv)
{
aRv = ImportStylesheet(stylesheet.AsDOMNode());
}
already_AddRefed<DocumentFragment>
txMozillaXSLTProcessor::TransformToFragment(nsINode& source,
nsIDocument& docVal,
mozilla::ErrorResult& aRv)
{
nsCOMPtr<nsIDOMDocumentFragment> fragment;
nsCOMPtr<nsIDOMDocument> domDoc = do_QueryInterface(&docVal);
if (!domDoc) {
aRv.Throw(NS_ERROR_FAILURE);
return nullptr;
}
aRv = TransformToFragment(source.AsDOMNode(), domDoc, getter_AddRefs(fragment));
return fragment.forget().downcast<DocumentFragment>();
}
already_AddRefed<nsIDocument>
txMozillaXSLTProcessor::TransformToDocument(nsINode& source,
mozilla::ErrorResult& aRv)
{
nsCOMPtr<nsIDOMDocument> document;
aRv = TransformToDocument(source.AsDOMNode(), getter_AddRefs(document));
nsCOMPtr<nsIDocument> domDoc = do_QueryInterface(document);
return domDoc.forget();
}
void
txMozillaXSLTProcessor::SetParameter(JSContext* aCx,
const nsAString& aNamespaceURI,
const nsAString& aLocalName,
JS::Handle<JS::Value> aValue,
mozilla::ErrorResult& aRv)
{
nsCOMPtr<nsIVariant> val;
aRv = nsContentUtils::XPConnect()->JSToVariant(aCx, aValue,
getter_AddRefs(val));
if (aRv.Failed()) {
return;
}
aRv = SetParameter(aNamespaceURI, aLocalName, val);
}
nsIVariant*
txMozillaXSLTProcessor::GetParameter(const nsAString& aNamespaceURI,
const nsAString& aLocalName,
mozilla::ErrorResult& aRv)
{
nsCOMPtr<nsIVariant> val;
aRv = GetParameter(aNamespaceURI, aLocalName, getter_AddRefs(val));
return val;
}
/* static*/
nsresult
txMozillaXSLTProcessor::Startup()

View File

@ -14,8 +14,11 @@
#include "txExpandedNameMap.h"
#include "txNamespaceMap.h"
#include "nsCycleCollectionParticipant.h"
#include "nsWrapperCache.h"
#include "mozilla/Attributes.h"
#include "mozilla/ErrorResult.h"
class nsINode;
class nsIDOMNode;
class nsIURI;
class nsIXMLContentSink;
@ -23,6 +26,16 @@ class txStylesheet;
class txResultRecycler;
class txIGlobalParameter;
namespace mozilla {
namespace dom {
class Document;
class DocumentFragment;
class GlobalObject;
}
}
/* bacd8ad0-552f-11d3-a9f7-000064657374 */
#define TRANSFORMIIX_XSLT_PROCESSOR_CID \
{ 0x618ee71d, 0xd7a7, 0x41a1, {0xa3, 0xfb, 0xc2, 0xbe, 0xdc, 0x6a, 0x21, 0x7e} }
@ -38,7 +51,8 @@ class txIGlobalParameter;
class txMozillaXSLTProcessor MOZ_FINAL : public nsIXSLTProcessor,
public nsIXSLTProcessorPrivate,
public nsIDocumentTransformer,
public nsStubMutationObserver
public nsStubMutationObserver,
public nsWrapperCache
{
public:
/**
@ -48,8 +62,8 @@ public:
// nsISupports interface
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(txMozillaXSLTProcessor,
nsIXSLTProcessor)
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_AMBIGUOUS(txMozillaXSLTProcessor,
nsIXSLTProcessor)
// nsIXSLTProcessor interface
NS_DECL_NSIXSLTPROCESSOR
@ -78,6 +92,49 @@ public:
NS_DECL_NSIMUTATIONOBSERVER_CONTENTREMOVED
NS_DECL_NSIMUTATIONOBSERVER_NODEWILLBEDESTROYED
// nsWrapperCache
virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE;
// WebIDL
nsISupports*
GetParentObject() const
{
return mOwner;
}
static already_AddRefed<txMozillaXSLTProcessor>
Constructor(const mozilla::dom::GlobalObject& aGlobal,
mozilla::ErrorResult& aRv);
void ImportStylesheet(nsINode& stylesheet,
mozilla::ErrorResult& aRv);
already_AddRefed<mozilla::dom::DocumentFragment>
TransformToFragment(nsINode& source, nsIDocument& docVal, mozilla::ErrorResult& aRv);
already_AddRefed<nsIDocument>
TransformToDocument(nsINode& source, mozilla::ErrorResult& aRv);
void SetParameter(JSContext* aCx,
const nsAString& aNamespaceURI,
const nsAString& aLocalName,
JS::Handle<JS::Value> aValue,
mozilla::ErrorResult& aRv);
nsIVariant* GetParameter(const nsAString& aNamespaceURI,
const nsAString& aLocalName,
mozilla::ErrorResult& aRv);
void RemoveParameter(const nsAString& aNamespaceURI,
const nsAString& aLocalName,
mozilla::ErrorResult& aRv)
{
aRv = RemoveParameter(aNamespaceURI, aLocalName);
}
uint32_t Flags()
{
uint32_t flags;
GetFlags(&flags);
return flags;
}
nsresult setStylesheet(txStylesheet* aStylesheet);
void reportError(nsresult aResult, const char16_t *aErrorText,
const char16_t *aSourceText);
@ -99,6 +156,7 @@ public:
static void Shutdown();
private:
txMozillaXSLTProcessor(nsISupports* aOwner);
/**
* Default destructor for txMozillaXSLTProcessor
*/
@ -108,6 +166,8 @@ private:
void notifyError();
nsresult ensureStylesheet();
nsCOMPtr<nsISupports> mOwner;
nsRefPtr<txStylesheet> mStylesheet;
nsIDocument* mStylesheetDocument; // weak
nsCOMPtr<nsIContent> mEmbeddedStylesheetRoot;

View File

@ -5,6 +5,7 @@
#include "txOutputFormat.h"
#include "txXMLUtils.h"
#include "txExpandedName.h"
txOutputFormat::txOutputFormat() : mMethod(eMethodNotSet),
mOmitXMLDeclaration(eNotSet),

View File

@ -8,6 +8,7 @@
#include "nsError.h"
#include "txXMLUtils.h"
#include "txXSLTFunctions.h"
#include "txExpandedName.h"
#include "txNamespaceMap.h"
nsresult

View File

@ -7,6 +7,7 @@
#define TX_XSLT_PATTERNS_H
#include "mozilla/Attributes.h"
#include "txExpandedName.h"
#include "txExpr.h"
#include "txXMLUtils.h"