From 49fd6e2f599f751c56a6c33fd6613389204369dd Mon Sep 17 00:00:00 2001 From: "edburns%acm.org" Date: Tue, 12 Jun 2001 18:30:56 +0000 Subject: [PATCH] ra=ashuk bug=79427. This checkin adds the following behavior: On GetValue, if a checkbox or radio button, it returns "CHECKED" or "UNCHECKED". On SetValue, any string not equal to the empty string causes the checkbox to be set. git-svn-id: svn://10.0.0.236/trunk@96927 18797224-902f-48f8-a5cc-f745e15eee43 --- .../java/dom/jni/org_mozilla_dom_NodeImpl.cpp | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/mozilla/java/dom/jni/org_mozilla_dom_NodeImpl.cpp b/mozilla/java/dom/jni/org_mozilla_dom_NodeImpl.cpp index 0e64144fb37..e7f1022531d 100644 --- a/mozilla/java/dom/jni/org_mozilla_dom_NodeImpl.cpp +++ b/mozilla/java/dom/jni/org_mozilla_dom_NodeImpl.cpp @@ -686,6 +686,23 @@ JNIEXPORT jstring JNICALL Java_org_mozilla_dom_NodeImpl_getNodeValue nsresult rv; OMDNI_QUERY_AND_CALL(node, GetValue, ret) + if (input) { + nsAutoString typeStr; + PRBool isChecked; + if (NS_SUCCEEDED(rv = input->GetType(typeStr))) { + if (0 == typeStr.CompareWithConversion("radio", PR_TRUE) || + 0 == typeStr.CompareWithConversion("checkbox", PR_TRUE)) { + if (NS_SUCCEEDED(rv = input->GetChecked(&isChecked))) { + if (isChecked) { + ret.AssignWithConversion("CHECKED"); + } + else { + ret.AssignWithConversion(""); + } + } + } + } + } if (!OMDNI_didCall) { rv = node->GetNodeValue(ret); @@ -1002,6 +1019,25 @@ JNIEXPORT void JNICALL Java_org_mozilla_dom_NodeImpl_setNodeValue nsresult rv; OMDNI_QUERY_AND_CALL(node, SetValue, *value) + if (input) { + nsAutoString typeStr; + nsString empty; + nsString val; + + if (NS_SUCCEEDED(rv = input->GetType(typeStr))) { + if (0 == typeStr.CompareWithConversion("radio", PR_TRUE) || + 0 == typeStr.CompareWithConversion("checkbox", PR_TRUE)) { + empty.AssignWithConversion(""); + val = *value; + if (0 == empty.CompareWithConversion(val)) { + input->SetChecked(PR_FALSE); + } + else { + input->SetChecked(PR_TRUE); + } + } + } + } if (!OMDNI_didCall) { rv = node->SetNodeValue(*value);