mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 22:01:30 +00:00
Bug 1614174. Stop using NS_ERROR_DOM_TYPE_ERR in XPath. r=peterv
Differential Revision: https://phabricator.services.mozilla.com/D62157 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
c41ef3c07e
commit
eb4285b299
@ -164,7 +164,10 @@ already_AddRefed<XPathResult> XPathExpression::EvaluateWithContext(
|
|||||||
xpathResult = new XPathResult(&aContextNode);
|
xpathResult = new XPathResult(&aContextNode);
|
||||||
}
|
}
|
||||||
|
|
||||||
aRv = xpathResult->SetExprResult(exprResult, resultType, &aContextNode);
|
xpathResult->SetExprResult(exprResult, resultType, &aContextNode, aRv);
|
||||||
|
if (aRv.Failed()) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
return xpathResult.forget();
|
return xpathResult.forget();
|
||||||
}
|
}
|
||||||
|
@ -79,7 +79,7 @@ void XPathResult::RemoveObserver() {
|
|||||||
|
|
||||||
nsINode* XPathResult::IterateNext(ErrorResult& aRv) {
|
nsINode* XPathResult::IterateNext(ErrorResult& aRv) {
|
||||||
if (!isIterator()) {
|
if (!isIterator()) {
|
||||||
aRv.Throw(NS_ERROR_DOM_TYPE_ERR);
|
aRv.ThrowTypeError(u"Result is not an iterator");
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -88,7 +88,7 @@ nsINode* XPathResult::IterateNext(ErrorResult& aRv) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (mInvalidIteratorState) {
|
if (mInvalidIteratorState) {
|
||||||
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
|
aRv.ThrowInvalidStateError("The document has been mutated since the result was returned");
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -126,9 +126,9 @@ void XPathResult::ContentRemoved(nsIContent* aChild,
|
|||||||
Invalidate(aChild->GetParent());
|
Invalidate(aChild->GetParent());
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult XPathResult::SetExprResult(txAExprResult* aExprResult,
|
void XPathResult::SetExprResult(txAExprResult* aExprResult,
|
||||||
uint16_t aResultType,
|
uint16_t aResultType, nsINode* aContextNode,
|
||||||
nsINode* aContextNode) {
|
ErrorResult& aRv) {
|
||||||
MOZ_ASSERT(aExprResult);
|
MOZ_ASSERT(aExprResult);
|
||||||
|
|
||||||
if ((isSnapshot(aResultType) || isIterator(aResultType) ||
|
if ((isSnapshot(aResultType) || isIterator(aResultType) ||
|
||||||
@ -137,7 +137,8 @@ nsresult XPathResult::SetExprResult(txAExprResult* aExprResult,
|
|||||||
// The DOM spec doesn't really say what should happen when reusing an
|
// The DOM spec doesn't really say what should happen when reusing an
|
||||||
// XPathResult and an error is thrown. Let's not touch the XPathResult
|
// XPathResult and an error is thrown. Let's not touch the XPathResult
|
||||||
// in that case.
|
// in that case.
|
||||||
return NS_ERROR_DOM_TYPE_ERR;
|
aRv.ThrowTypeError(u"Result type mismatch");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
mResultType = aResultType;
|
mResultType = aResultType;
|
||||||
@ -184,7 +185,7 @@ nsresult XPathResult::SetExprResult(txAExprResult* aExprResult,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!isIterator()) {
|
if (!isIterator()) {
|
||||||
return NS_OK;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
mCurrentPos = 0;
|
mCurrentPos = 0;
|
||||||
@ -199,8 +200,6 @@ nsresult XPathResult::SetExprResult(txAExprResult* aExprResult,
|
|||||||
mDocument->AddMutationObserver(this);
|
mDocument->AddMutationObserver(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void XPathResult::Invalidate(const nsIContent* aChangeRoot) {
|
void XPathResult::Invalidate(const nsIContent* aChangeRoot) {
|
||||||
|
@ -31,9 +31,9 @@ class txAExprResult;
|
|||||||
class nsIXPathResult : public nsISupports {
|
class nsIXPathResult : public nsISupports {
|
||||||
public:
|
public:
|
||||||
NS_DECLARE_STATIC_IID_ACCESSOR(NS_IXPATHRESULT_IID)
|
NS_DECLARE_STATIC_IID_ACCESSOR(NS_IXPATHRESULT_IID)
|
||||||
virtual nsresult SetExprResult(txAExprResult* aExprResult,
|
virtual void SetExprResult(txAExprResult* aExprResult, uint16_t aResultType,
|
||||||
uint16_t aResultType,
|
nsINode* aContextNode,
|
||||||
nsINode* aContextNode) = 0;
|
mozilla::ErrorResult& aRv) = 0;
|
||||||
virtual nsresult GetExprResult(txAExprResult** aExprResult) = 0;
|
virtual nsresult GetExprResult(txAExprResult** aExprResult) = 0;
|
||||||
virtual nsresult Clone(nsIXPathResult** aResult) = 0;
|
virtual nsresult Clone(nsIXPathResult** aResult) = 0;
|
||||||
};
|
};
|
||||||
@ -83,7 +83,7 @@ class XPathResult final : public nsIXPathResult,
|
|||||||
uint16_t ResultType() const { return mResultType; }
|
uint16_t ResultType() const { return mResultType; }
|
||||||
double GetNumberValue(ErrorResult& aRv) const {
|
double GetNumberValue(ErrorResult& aRv) const {
|
||||||
if (mResultType != NUMBER_TYPE) {
|
if (mResultType != NUMBER_TYPE) {
|
||||||
aRv.Throw(NS_ERROR_DOM_TYPE_ERR);
|
aRv.ThrowTypeError(u"Result is not a number");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -91,7 +91,7 @@ class XPathResult final : public nsIXPathResult,
|
|||||||
}
|
}
|
||||||
void GetStringValue(nsAString& aStringValue, ErrorResult& aRv) const {
|
void GetStringValue(nsAString& aStringValue, ErrorResult& aRv) const {
|
||||||
if (mResultType != STRING_TYPE) {
|
if (mResultType != STRING_TYPE) {
|
||||||
aRv.Throw(NS_ERROR_DOM_TYPE_ERR);
|
aRv.ThrowTypeError(u"Result is not a string");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -99,7 +99,7 @@ class XPathResult final : public nsIXPathResult,
|
|||||||
}
|
}
|
||||||
bool GetBooleanValue(ErrorResult& aRv) const {
|
bool GetBooleanValue(ErrorResult& aRv) const {
|
||||||
if (mResultType != BOOLEAN_TYPE) {
|
if (mResultType != BOOLEAN_TYPE) {
|
||||||
aRv.Throw(NS_ERROR_DOM_TYPE_ERR);
|
aRv.ThrowTypeError(u"Result is not a boolean");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -107,7 +107,7 @@ class XPathResult final : public nsIXPathResult,
|
|||||||
}
|
}
|
||||||
nsINode* GetSingleNodeValue(ErrorResult& aRv) const {
|
nsINode* GetSingleNodeValue(ErrorResult& aRv) const {
|
||||||
if (!isNode()) {
|
if (!isNode()) {
|
||||||
aRv.Throw(NS_ERROR_DOM_TYPE_ERR);
|
aRv.ThrowTypeError(u"Result is not a node");
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -118,7 +118,7 @@ class XPathResult final : public nsIXPathResult,
|
|||||||
}
|
}
|
||||||
uint32_t GetSnapshotLength(ErrorResult& aRv) const {
|
uint32_t GetSnapshotLength(ErrorResult& aRv) const {
|
||||||
if (!isSnapshot()) {
|
if (!isSnapshot()) {
|
||||||
aRv.Throw(NS_ERROR_DOM_TYPE_ERR);
|
aRv.ThrowTypeError(u"Result is not a snapshot");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -127,7 +127,7 @@ class XPathResult final : public nsIXPathResult,
|
|||||||
nsINode* IterateNext(ErrorResult& aRv);
|
nsINode* IterateNext(ErrorResult& aRv);
|
||||||
nsINode* SnapshotItem(uint32_t aIndex, ErrorResult& aRv) const {
|
nsINode* SnapshotItem(uint32_t aIndex, ErrorResult& aRv) const {
|
||||||
if (!isSnapshot()) {
|
if (!isSnapshot()) {
|
||||||
aRv.Throw(NS_ERROR_DOM_TYPE_ERR);
|
aRv.ThrowTypeError(u"Result is not a snapshot");
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -142,8 +142,8 @@ class XPathResult final : public nsIXPathResult,
|
|||||||
NS_DECL_NSIMUTATIONOBSERVER_CONTENTREMOVED
|
NS_DECL_NSIMUTATIONOBSERVER_CONTENTREMOVED
|
||||||
NS_DECL_NSIMUTATIONOBSERVER_NODEWILLBEDESTROYED
|
NS_DECL_NSIMUTATIONOBSERVER_NODEWILLBEDESTROYED
|
||||||
|
|
||||||
nsresult SetExprResult(txAExprResult* aExprResult, uint16_t aResultType,
|
void SetExprResult(txAExprResult* aExprResult, uint16_t aResultType,
|
||||||
nsINode* aContextNode) override;
|
nsINode* aContextNode, ErrorResult& aRv) override;
|
||||||
nsresult GetExprResult(txAExprResult** aExprResult) override;
|
nsresult GetExprResult(txAExprResult** aExprResult) override;
|
||||||
nsresult Clone(nsIXPathResult** aResult) override;
|
nsresult Clone(nsIXPathResult** aResult) override;
|
||||||
void RemoveObserver();
|
void RemoveObserver();
|
||||||
|
Loading…
Reference in New Issue
Block a user