mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-18 06:45:33 +00:00
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.
This commit is contained in:
parent
f430e67cb8
commit
aba0c0a15a
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user