mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-26 06:11:37 +00:00
Bug 908997 - Simplify XPathEvaluator - remove aggregation from XPathEvaluator. r=bz.
--HG-- rename : content/xslt/src/xpath/nsXPathEvaluator.cpp => content/xslt/src/xpath/XPathEvaluator.cpp rename : content/xslt/src/xpath/nsXPathEvaluator.h => content/xslt/src/xpath/XPathEvaluator.h extra : rebase_source : 163d25a36f52f8f8fa8b6952bcf1bc83de14230b
This commit is contained in:
parent
ce2858be5f
commit
41bff5a09a
@ -108,6 +108,7 @@ class ProcessingInstruction;
|
||||
class Touch;
|
||||
class TreeWalker;
|
||||
class UndoManager;
|
||||
class XPathEvaluator;
|
||||
template<typename> class OwningNonNull;
|
||||
template<typename> class Sequence;
|
||||
|
||||
@ -2171,6 +2172,8 @@ protected:
|
||||
return mContentType;
|
||||
}
|
||||
|
||||
mozilla::dom::XPathEvaluator* XPathEvaluator();
|
||||
|
||||
nsCString mReferrer;
|
||||
nsString mLastModified;
|
||||
|
||||
@ -2426,6 +2429,8 @@ protected:
|
||||
uint8_t mDefaultElementType;
|
||||
|
||||
uint32_t mInSyncOperationCount;
|
||||
|
||||
nsRefPtr<mozilla::dom::XPathEvaluator> mXPathEvaluator;
|
||||
};
|
||||
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(nsIDocument, NS_IDOCUMENT_IID)
|
||||
|
@ -27,6 +27,7 @@ LOCAL_INCLUDES += \
|
||||
-I$(topsrcdir)/content/xbl/src \
|
||||
-I$(topsrcdir)/content/xml/content/src \
|
||||
-I$(topsrcdir)/content/xml/document/src \
|
||||
-I$(topsrcdir)/content/xslt/src/xpath \
|
||||
-I$(topsrcdir)/content/xul/content/src \
|
||||
-I$(topsrcdir)/content/xul/document/src \
|
||||
-I$(topsrcdir)/dom/base \
|
||||
|
@ -99,7 +99,6 @@
|
||||
#include "nsBidiUtils.h"
|
||||
|
||||
#include "nsIDOMUserDataHandler.h"
|
||||
#include "nsIDOMXPathEvaluator.h"
|
||||
#include "nsIDOMXPathExpression.h"
|
||||
#include "nsIDOMXPathNSResolver.h"
|
||||
#include "nsIParserService.h"
|
||||
@ -212,6 +211,7 @@
|
||||
#include "nsIHttpChannelInternal.h"
|
||||
#include "nsISecurityConsoleMessage.h"
|
||||
#include "nsCharSeparatedTokenizer.h"
|
||||
#include "mozilla/dom/XPathEvaluator.h"
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::dom;
|
||||
@ -1581,22 +1581,11 @@ NS_INTERFACE_TABLE_HEAD(nsDocument)
|
||||
NS_INTERFACE_TABLE_ENTRY(nsDocument, nsIMutationObserver)
|
||||
NS_INTERFACE_TABLE_ENTRY(nsDocument, nsIApplicationCacheContainer)
|
||||
NS_INTERFACE_TABLE_ENTRY(nsDocument, nsIObserver)
|
||||
NS_INTERFACE_TABLE_ENTRY(nsDocument, nsIDOMXPathEvaluator)
|
||||
NS_INTERFACE_TABLE_END
|
||||
NS_INTERFACE_TABLE_TO_MAP_SEGUE_CYCLE_COLLECTION(nsDocument)
|
||||
NS_INTERFACE_MAP_ENTRY_TEAROFF(nsIDOMXPathNSResolver,
|
||||
new nsNode3Tearoff(this))
|
||||
if (aIID.Equals(NS_GET_IID(nsIDOMXPathEvaluator))) {
|
||||
if (!mXPathEvaluatorTearoff) {
|
||||
nsresult rv;
|
||||
mXPathEvaluatorTearoff =
|
||||
do_CreateInstance(NS_XPATH_EVALUATOR_CONTRACTID,
|
||||
static_cast<nsIDocument *>(this), &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
return mXPathEvaluatorTearoff->QueryInterface(aIID, aInstancePtr);
|
||||
}
|
||||
else
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
|
||||
@ -1782,7 +1771,7 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INTERNAL(nsDocument)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mChannel)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mStyleAttrStyleSheet)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mXPathEvaluatorTearoff)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mXPathEvaluator)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mLayoutHistoryState)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mOnloadBlocker)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mFirstBaseNodeWithHref)
|
||||
@ -1869,7 +1858,7 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsDocument)
|
||||
}
|
||||
tmp->mFirstChild = nullptr;
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mXPathEvaluatorTearoff)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mXPathEvaluator)
|
||||
tmp->mCachedRootElement = nullptr; // Avoid a dangling pointer
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mDisplayDocument)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mFirstBaseNodeWithHref)
|
||||
@ -11288,31 +11277,14 @@ nsIDocument::CreateExpression(const nsAString& aExpression,
|
||||
nsIDOMXPathNSResolver* aResolver,
|
||||
ErrorResult& rv)
|
||||
{
|
||||
nsCOMPtr<nsIDOMXPathEvaluator> evaluator = do_QueryInterface(this);
|
||||
if (!evaluator) {
|
||||
rv.Throw(NS_ERROR_FAILURE);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMXPathExpression> expr;
|
||||
rv = evaluator->CreateExpression(aExpression, aResolver, getter_AddRefs(expr));
|
||||
return expr.forget();
|
||||
return XPathEvaluator()->CreateExpression(aExpression, aResolver, rv);
|
||||
}
|
||||
|
||||
already_AddRefed<nsIDOMXPathNSResolver>
|
||||
nsIDocument::CreateNSResolver(nsINode* aNodeResolver,
|
||||
ErrorResult& rv)
|
||||
{
|
||||
nsCOMPtr<nsIDOMXPathEvaluator> evaluator = do_QueryInterface(this);
|
||||
if (!evaluator) {
|
||||
rv.Throw(NS_ERROR_FAILURE);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMNode> nodeResolver = do_QueryInterface(aNodeResolver);
|
||||
nsCOMPtr<nsIDOMXPathNSResolver> res;
|
||||
rv = evaluator->CreateNSResolver(nodeResolver, getter_AddRefs(res));
|
||||
return res.forget();
|
||||
return XPathEvaluator()->CreateNSResolver(aNodeResolver, rv);
|
||||
}
|
||||
|
||||
already_AddRefed<nsISupports>
|
||||
@ -11320,19 +11292,34 @@ nsIDocument::Evaluate(const nsAString& aExpression, nsINode* aContextNode,
|
||||
nsIDOMXPathNSResolver* aResolver, uint16_t aType,
|
||||
nsISupports* aResult, ErrorResult& rv)
|
||||
{
|
||||
nsCOMPtr<nsIDOMXPathEvaluator> evaluator = do_QueryInterface(this);
|
||||
if (!evaluator) {
|
||||
rv.Throw(NS_ERROR_FAILURE);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMNode> contextNode = do_QueryInterface(aContextNode);
|
||||
nsCOMPtr<nsISupports> res;
|
||||
rv = evaluator->Evaluate(aExpression, contextNode, aResolver, aType,
|
||||
aResult, getter_AddRefs(res));
|
||||
return res.forget();
|
||||
return XPathEvaluator()->Evaluate(aExpression, aContextNode, aResolver, aType,
|
||||
aResult, rv);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocument::CreateExpression(const nsAString& aExpression,
|
||||
nsIDOMXPathNSResolver* aResolver,
|
||||
nsIDOMXPathExpression** aResult)
|
||||
{
|
||||
return XPathEvaluator()->CreateExpression(aExpression, aResolver, aResult);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocument::CreateNSResolver(nsIDOMNode* aNodeResolver,
|
||||
nsIDOMXPathNSResolver** aResult)
|
||||
{
|
||||
return XPathEvaluator()->CreateNSResolver(aNodeResolver, aResult);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocument::Evaluate(const nsAString& aExpression, nsIDOMNode* aContextNode,
|
||||
nsIDOMXPathNSResolver* aResolver, uint16_t aType,
|
||||
nsISupports* aInResult, nsISupports** aResult)
|
||||
{
|
||||
return XPathEvaluator()->Evaluate(aExpression, aContextNode, aResolver, aType,
|
||||
aInResult, aResult);
|
||||
}
|
||||
|
||||
// This is just a hack around the fact that window.document is not
|
||||
// [Unforgeable] yet.
|
||||
JSObject*
|
||||
@ -11384,6 +11371,15 @@ nsIDocument::WrapObject(JSContext *aCx, JS::Handle<JSObject*> aScope)
|
||||
return obj;
|
||||
}
|
||||
|
||||
XPathEvaluator*
|
||||
nsIDocument::XPathEvaluator()
|
||||
{
|
||||
if (!mXPathEvaluator) {
|
||||
mXPathEvaluator = new dom::XPathEvaluator(this);
|
||||
}
|
||||
return mXPathEvaluator;
|
||||
}
|
||||
|
||||
bool
|
||||
MarkDocumentTreeToBeInSyncOperation(nsIDocument* aDoc, void* aData)
|
||||
{
|
||||
|
@ -68,6 +68,7 @@
|
||||
#include "nsDataHashtable.h"
|
||||
#include "mozilla/TimeStamp.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "nsIDOMXPathEvaluator.h"
|
||||
|
||||
#define XML_DECLARATION_BITS_DECLARATION_EXISTS (1 << 0)
|
||||
#define XML_DECLARATION_BITS_ENCODING_EXISTS (1 << 1)
|
||||
@ -504,7 +505,8 @@ class nsDocument : public nsIDocument,
|
||||
public nsIRadioGroupContainer,
|
||||
public nsIApplicationCacheContainer,
|
||||
public nsStubMutationObserver,
|
||||
public nsIObserver
|
||||
public nsIObserver,
|
||||
public nsIDOMXPathEvaluator
|
||||
{
|
||||
public:
|
||||
typedef mozilla::dom::Element Element;
|
||||
@ -786,6 +788,8 @@ public:
|
||||
// nsIObserver
|
||||
NS_DECL_NSIOBSERVER
|
||||
|
||||
NS_DECL_NSIDOMXPATHEVALUATOR
|
||||
|
||||
virtual nsresult Init();
|
||||
|
||||
virtual nsresult CreateElem(const nsAString& aName, nsIAtom *aPrefix,
|
||||
@ -1345,8 +1349,6 @@ private:
|
||||
nsDocument(const nsDocument& aOther);
|
||||
nsDocument& operator=(const nsDocument& aOther);
|
||||
|
||||
nsCOMPtr<nsISupports> mXPathEvaluatorTearoff;
|
||||
|
||||
// The layout history state that should be used by nodes in this
|
||||
// document. We only actually store a pointer to it when:
|
||||
// 1) We have no script global object.
|
||||
|
@ -3,7 +3,7 @@
|
||||
* 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 "XPathEvaluator.h"
|
||||
#include "mozilla/dom/XPathEvaluator.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIAtom.h"
|
||||
#include "nsXPathExpression.h"
|
||||
@ -58,15 +58,11 @@ private:
|
||||
bool mIsCaseSensitive;
|
||||
};
|
||||
|
||||
NS_IMPL_AGGREGATED(XPathEvaluator)
|
||||
NS_INTERFACE_MAP_BEGIN_AGGREGATED(XPathEvaluator)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMXPathEvaluator)
|
||||
NS_INTERFACE_MAP_END
|
||||
NS_IMPL_ISUPPORTS1(XPathEvaluator, nsIDOMXPathEvaluator)
|
||||
|
||||
XPathEvaluator::XPathEvaluator(nsISupports *aOuter)
|
||||
: mDocument(do_GetWeakReference(aOuter))
|
||||
XPathEvaluator::XPathEvaluator(nsIDocument* aDocument)
|
||||
: mDocument(do_GetWeakReference(aDocument))
|
||||
{
|
||||
NS_INIT_AGGREGATED(aOuter);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -10,12 +10,12 @@
|
||||
#include "nsIWeakReference.h"
|
||||
#include "nsAutoPtr.h"
|
||||
#include "nsString.h"
|
||||
#include "txResultRecycler.h"
|
||||
#include "nsAgg.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/ErrorResult.h"
|
||||
#include "nsIDocument.h"
|
||||
|
||||
class nsINode;
|
||||
class txResultRecycler;
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
@ -28,18 +28,20 @@ class GlobalObject;
|
||||
class XPathEvaluator MOZ_FINAL : public nsIDOMXPathEvaluator
|
||||
{
|
||||
public:
|
||||
XPathEvaluator(nsISupports *aOuter);
|
||||
XPathEvaluator(nsIDocument* aDocument = nullptr);
|
||||
|
||||
nsresult Init();
|
||||
|
||||
// nsISupports interface (support aggregation)
|
||||
NS_DECL_AGGREGATED
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIDOMXPathEvaluator interface
|
||||
NS_DECL_NSIDOMXPATHEVALUATOR
|
||||
|
||||
// WebIDL API
|
||||
JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope);
|
||||
already_AddRefed<nsIDocument> GetParentObject()
|
||||
{
|
||||
nsCOMPtr<nsIDocument> doc = do_QueryReferent(mDocument);
|
||||
return doc.forget();
|
||||
}
|
||||
static already_AddRefed<XPathEvaluator>
|
||||
Constructor(const GlobalObject& aGlobal, ErrorResult& rv);
|
||||
already_AddRefed<nsIDOMXPathExpression>
|
||||
|
@ -262,7 +262,7 @@ using mozilla::dom::time::TimeService;
|
||||
|
||||
// Factory Constructor
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(txMozillaXSLTProcessor)
|
||||
NS_GENERIC_AGGREGATED_CONSTRUCTOR(XPathEvaluator)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(XPathEvaluator)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(txNodeSetAdaptor, Init)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsDOMSerializer)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsXMLHttpRequest, Init)
|
||||
|
Loading…
Reference in New Issue
Block a user