16427 r=akhil.arora@sun.com fixed by Denis Sharypov <sdv@sparc.spb.su>
Found some more instances where the DOM spec says that it is not an error to return a NULL. Do not throw exceptions in these cases. git-svn-id: svn://10.0.0.236/trunk@51035 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -294,7 +294,7 @@ JNIEXPORT jobject JNICALL Java_org_mozilla_dom_ElementImpl_removeAttributeNode
|
||||
|
||||
nsIDOMAttr* ret = nsnull;
|
||||
nsresult rv = element->RemoveAttributeNode(oldAttr, &ret);
|
||||
if (NS_FAILED(rv)) {
|
||||
if (NS_FAILED(rv) || !ret) {
|
||||
JavaDOMGlobals::ExceptionType exceptionType = JavaDOMGlobals::EXCEPTION_RUNTIME;
|
||||
if (NS_ERROR_GET_MODULE(rv) == NS_ERROR_MODULE_DOM &&
|
||||
(NS_ERROR_GET_CODE(rv) == NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR ||
|
||||
@@ -363,9 +363,6 @@ JNIEXPORT void JNICALL Java_org_mozilla_dom_ElementImpl_setAttribute
|
||||
env->ReleaseStringUTFChars(jname, name);
|
||||
if (NS_FAILED(rv)) {
|
||||
JavaDOMGlobals::ExceptionType exceptionType = JavaDOMGlobals::EXCEPTION_RUNTIME;
|
||||
PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR,
|
||||
("Element.setAttribute: failed (%x)\n", rv));
|
||||
|
||||
if (NS_ERROR_GET_MODULE(rv) == NS_ERROR_MODULE_DOM &&
|
||||
(NS_ERROR_GET_CODE(rv) == NS_ERROR_DOM_INVALID_CHARACTER_ERR ||
|
||||
NS_ERROR_GET_CODE(rv) == NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR)) {
|
||||
@@ -403,7 +400,7 @@ JNIEXPORT jobject JNICALL Java_org_mozilla_dom_ElementImpl_setAttributeNode
|
||||
|
||||
nsIDOMAttr* ret = nsnull;
|
||||
nsresult rv = element->SetAttributeNode(newAttr, &ret);
|
||||
if (NS_FAILED(rv)) {
|
||||
if (NS_FAILED(rv) || !ret) {
|
||||
JavaDOMGlobals::ExceptionType exceptionType = JavaDOMGlobals::EXCEPTION_RUNTIME;
|
||||
if (NS_ERROR_GET_MODULE(rv) == NS_ERROR_MODULE_DOM &&
|
||||
(NS_ERROR_GET_CODE(rv) == NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR ||
|
||||
@@ -430,7 +427,7 @@ JNIEXPORT jobject JNICALL Java_org_mozilla_dom_ElementImpl_setAttributeNode
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (ret) ret->AddRef();
|
||||
ret->AddRef();
|
||||
return jattr;
|
||||
}
|
||||
|
||||
|
||||
@@ -602,11 +602,16 @@ JNIEXPORT jobject JNICALL Java_org_mozilla_dom_NodeImpl_getPreviousSibling
|
||||
|
||||
nsIDOMNode* ret = nsnull;
|
||||
nsresult rv = node->GetPreviousSibling(&ret);
|
||||
if (NS_FAILED(rv) || !ret) {
|
||||
if (NS_FAILED(rv)) {
|
||||
JavaDOMGlobals::ThrowException(env,
|
||||
"Node.getPreviousSibling: failed", rv);
|
||||
return NULL;
|
||||
}
|
||||
if (!ret) {
|
||||
/* according to the spec, getLastChild may return NULL when there
|
||||
are no children. So this is not an error */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return JavaDOMGlobals::CreateNodeSubtype(env, ret);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user