Bug 1029104 - Convert XPathExpression to WebIDL bindings, move files and rename class. r=bz.
authorPeter Van der Beken <peterv@propagandism.org>
Thu, 04 Jul 2013 17:40:10 +0200
changeset 191285 20fb9c5eefe1fbfe82b6933d280d660e7e1a866b
parent 191284 1d99047f17a5b138598b0aadaa3c1c313c4fb194
child 191286 88210c5bd6e6db8d6aca60012a6ddaa88dccb3ba
push id27041
push userphilringnalda@gmail.com
push dateSun, 29 Jun 2014 00:39:21 +0000
treeherdermozilla-central@afa67a2f7905 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs1029104
milestone33.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1029104 - Convert XPathExpression to WebIDL bindings, move files and rename class. r=bz.
dom/xslt/xpath/XPathEvaluator.cpp
dom/xslt/xpath/XPathExpression.cpp
dom/xslt/xpath/XPathExpression.h
dom/xslt/xpath/moz.build
dom/xslt/xpath/nsXPathExpression.cpp
dom/xslt/xpath/nsXPathExpression.h
--- a/dom/xslt/xpath/XPathEvaluator.cpp
+++ b/dom/xslt/xpath/XPathEvaluator.cpp
@@ -2,17 +2,17 @@
 /* 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 "mozilla/dom/XPathEvaluator.h"
 #include "mozilla/Move.h"
 #include "nsCOMPtr.h"
 #include "nsIAtom.h"
-#include "nsXPathExpression.h"
+#include "mozilla/dom/XPathExpression.h"
 #include "nsXPathNSResolver.h"
 #include "XPathResult.h"
 #include "nsContentCID.h"
 #include "txExpr.h"
 #include "txExprParser.h"
 #include "nsError.h"
 #include "txURIUtils.h"
 #include "nsIDocument.h"
@@ -124,17 +124,17 @@ XPathEvaluator::CreateExpression(const n
             return NS_ERROR_DOM_NAMESPACE_ERR;
         }
 
         return NS_ERROR_DOM_INVALID_EXPRESSION_ERR;
     }
 
     nsCOMPtr<nsIDOMDocument> document = do_QueryReferent(mDocument);
 
-    *aResult = new nsXPathExpression(Move(expression), mRecycler, document);
+    *aResult = new XPathExpression(Move(expression), mRecycler, document);
     if (!*aResult) {
         return NS_ERROR_OUT_OF_MEMORY;
     }
 
     NS_ADDREF(*aResult);
     return NS_OK;
 }
 
rename from dom/xslt/xpath/nsXPathExpression.cpp
rename to dom/xslt/xpath/XPathExpression.cpp
--- a/dom/xslt/xpath/nsXPathExpression.cpp
+++ b/dom/xslt/xpath/XPathExpression.cpp
@@ -1,67 +1,69 @@
 /* -*- 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 "mozilla/Move.h"
-#include "nsXPathExpression.h"
+#include "XPathExpression.h"
 #include "txExpr.h"
 #include "txExprResult.h"
 #include "nsError.h"
 #include "nsIDOMCharacterData.h"
 #include "nsDOMClassInfoID.h"
 #include "nsIDOMDocument.h"
 #include "XPathResult.h"
 #include "txURIUtils.h"
 #include "txXPathTreeWalker.h"
 
-using namespace mozilla::dom;
 using mozilla::Move;
 
-NS_IMPL_CYCLE_COLLECTION(nsXPathExpression, mDocument)
+DOMCI_DATA(XPathExpression, mozilla::dom::XPathExpression)
+ 
+namespace mozilla {
+namespace dom {
 
-NS_IMPL_CYCLE_COLLECTING_ADDREF(nsXPathExpression)
-NS_IMPL_CYCLE_COLLECTING_RELEASE(nsXPathExpression)
+NS_IMPL_CYCLE_COLLECTION(XPathExpression, mDocument)
 
-DOMCI_DATA(XPathExpression, nsXPathExpression)
+NS_IMPL_CYCLE_COLLECTING_ADDREF(XPathExpression)
+NS_IMPL_CYCLE_COLLECTING_RELEASE(XPathExpression)
 
-NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsXPathExpression)
+NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(XPathExpression)
   NS_INTERFACE_MAP_ENTRY(nsIDOMXPathExpression)
   NS_INTERFACE_MAP_ENTRY(nsIDOMNSXPathExpression)
   NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMXPathExpression)
   NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(XPathExpression)
 NS_INTERFACE_MAP_END
 
-nsXPathExpression::nsXPathExpression(nsAutoPtr<Expr>&& aExpression,
-                                     txResultRecycler* aRecycler,
-                                     nsIDOMDocument *aDocument)
+XPathExpression::XPathExpression(nsAutoPtr<Expr>&& aExpression,
+                                 txResultRecycler* aRecycler,
+                                 nsIDOMDocument *aDocument)
     : mExpression(Move(aExpression)),
       mRecycler(aRecycler),
       mDocument(aDocument)
 {
 }
 
 NS_IMETHODIMP
-nsXPathExpression::Evaluate(nsIDOMNode *aContextNode,
-                            uint16_t aType,
-                            nsISupports *aInResult,
-                            nsISupports **aResult)
+XPathExpression::Evaluate(nsIDOMNode *aContextNode,
+                          uint16_t aType,
+                          nsISupports *aInResult,
+                          nsISupports **aResult)
 {
     return EvaluateWithContext(aContextNode, 1, 1, aType, aInResult, aResult);
 }
 
 NS_IMETHODIMP
-nsXPathExpression::EvaluateWithContext(nsIDOMNode *aContextNode,
-                                       uint32_t aContextPosition,
-                                       uint32_t aContextSize,
-                                       uint16_t aType,
-                                       nsISupports *aInResult,
-                                       nsISupports **aResult)
+XPathExpression::EvaluateWithContext(nsIDOMNode *aContextNode,
+                                     uint32_t aContextPosition,
+                                     uint32_t aContextSize,
+                                     uint16_t aType,
+                                     nsISupports *aInResult,
+                                     nsISupports **aResult)
 {
     nsCOMPtr<nsINode> context = do_QueryInterface(aContextNode);
     NS_ENSURE_ARG(context);
 
     if (aContextPosition > aContextSize)
         return NS_ERROR_FAILURE;
 
     if (!nsContentUtils::CanCallerAccess(aContextNode))
@@ -145,58 +147,68 @@ nsXPathExpression::EvaluateWithContext(n
     }
     rv = xpathResult->SetExprResult(exprResult, resultType, context);
     NS_ENSURE_SUCCESS(rv, rv);
 
     return CallQueryInterface(xpathResult, aResult);
 }
 
 /*
- * Implementation of the txIEvalContext private to nsXPathExpression
+ * Implementation of the txIEvalContext private to XPathExpression
  * EvalContextImpl bases on only one context node and no variables
  */
 
 nsresult
-nsXPathExpression::EvalContextImpl::getVariable(int32_t aNamespace,
-                                                nsIAtom* aLName,
-                                                txAExprResult*& aResult)
+XPathExpression::EvalContextImpl::getVariable(int32_t aNamespace,
+                                              nsIAtom* aLName,
+                                              txAExprResult*& aResult)
 {
     aResult = 0;
     return NS_ERROR_INVALID_ARG;
 }
 
-bool nsXPathExpression::EvalContextImpl::isStripSpaceAllowed(const txXPathNode& aNode)
+bool
+XPathExpression::EvalContextImpl::isStripSpaceAllowed(const txXPathNode& aNode)
 {
     return false;
 }
 
-void* nsXPathExpression::EvalContextImpl::getPrivateContext()
+void*
+XPathExpression::EvalContextImpl::getPrivateContext()
 {
     // we don't have a private context here.
     return nullptr;
 }
 
-txResultRecycler* nsXPathExpression::EvalContextImpl::recycler()
+txResultRecycler*
+XPathExpression::EvalContextImpl::recycler()
 {
     return mRecycler;
 }
 
-void nsXPathExpression::EvalContextImpl::receiveError(const nsAString& aMsg,
-                                                      nsresult aRes)
+void
+XPathExpression::EvalContextImpl::receiveError(const nsAString& aMsg,
+                                               nsresult aRes)
 {
     mLastError = aRes;
     // forward aMsg to console service?
 }
 
-const txXPathNode& nsXPathExpression::EvalContextImpl::getContextNode()
+const txXPathNode&
+XPathExpression::EvalContextImpl::getContextNode()
 {
     return mContextNode;
 }
 
-uint32_t nsXPathExpression::EvalContextImpl::size()
+uint32_t
+XPathExpression::EvalContextImpl::size()
 {
     return mContextSize;
 }
 
-uint32_t nsXPathExpression::EvalContextImpl::position()
+uint32_t
+XPathExpression::EvalContextImpl::position()
 {
     return mContextPosition;
 }
+
+} // namespace dom
+} // namespace mozilla
rename from dom/xslt/xpath/nsXPathExpression.h
rename to dom/xslt/xpath/XPathExpression.h
--- a/dom/xslt/xpath/nsXPathExpression.h
+++ b/dom/xslt/xpath/XPathExpression.h
@@ -1,40 +1,43 @@
 /* -*- 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 nsXPathExpression_h__
-#define nsXPathExpression_h__
+#ifndef mozilla_dom_XPathExpression_h
+#define mozilla_dom_XPathExpression_h
 
 #include "nsIDOMXPathExpression.h"
 #include "nsIDOMNSXPathExpression.h"
 #include "txIXPathContext.h"
 #include "txResultRecycler.h"
 #include "nsAutoPtr.h"
 #include "nsCycleCollectionParticipant.h"
 #include "mozilla/Attributes.h"
 
 class Expr;
 class txXPathNode;
 
+namespace mozilla {
+namespace dom {
+
 /**
  * A class for evaluating an XPath expression string
  */
-class nsXPathExpression MOZ_FINAL : public nsIDOMXPathExpression,
-                                    public nsIDOMNSXPathExpression
+class XPathExpression MOZ_FINAL : public nsIDOMXPathExpression,
+                                  public nsIDOMNSXPathExpression
 {
 public:
-    nsXPathExpression(nsAutoPtr<Expr>&& aExpression, txResultRecycler* aRecycler,
-                      nsIDOMDocument *aDocument);
+    XPathExpression(nsAutoPtr<Expr>&& aExpression, txResultRecycler* aRecycler,
+                    nsIDOMDocument *aDocument);
 
     // nsISupports interface
     NS_DECL_CYCLE_COLLECTING_ISUPPORTS
-    NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsXPathExpression,
+    NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(XPathExpression,
                                              nsIDOMXPathExpression)
 
     // nsIDOMXPathExpression interface
     NS_DECL_NSIDOMXPATHEXPRESSION
 
     // nsIDOMNSXPathExpression interface
     NS_DECL_NSIDOMNSXPATHEXPRESSION
 
@@ -70,9 +73,12 @@ private:
         const txXPathNode& mContextNode;
         uint32_t mContextPosition;
         uint32_t mContextSize;
         nsresult mLastError;
         nsRefPtr<txResultRecycler> mRecycler;
     };
 };
 
-#endif
+} // namespace dom
+} // namespace mozilla
+
+#endif /* mozilla_dom_XPathExpression_h */
--- a/dom/xslt/xpath/moz.build
+++ b/dom/xslt/xpath/moz.build
@@ -1,21 +1,21 @@
 # -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=python:
 # 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/.
 
 EXPORTS.mozilla.dom += [
     'XPathEvaluator.h',
+    'XPathExpression.h',
     'XPathResult.h',
 ]
 
 UNIFIED_SOURCES += [
-    'nsXPathExpression.cpp',
     'nsXPathNSResolver.cpp',
     'txBooleanExpr.cpp',
     'txBooleanResult.cpp',
     'txCoreFunctionCall.cpp',
     'txErrorExpr.cpp',
     'txExpr.cpp',
     'txExprLexer.cpp',
     'txExprParser.cpp',
@@ -42,16 +42,17 @@ UNIFIED_SOURCES += [
     'txStringResult.cpp',
     'txUnaryExpr.cpp',
     'txUnionExpr.cpp',
     'txUnionNodeTest.cpp',
     'txVariableRefExpr.cpp',
     'txXPathOptimizer.cpp',
     'txXPCOMExtensionFunction.cpp',
     'XPathEvaluator.cpp',
+    'XPathExpression.cpp',
     'XPathResult.cpp',
 ]
 
 FAIL_ON_WARNINGS = True
 
 LOCAL_INCLUDES += [
     '../base',
     '../xml',