It now uses the nsHTMLContent->GetHTMLAttribute to get the value and/or label

The code now lso checks to see if the attr actually exists before it moves to the label or the content
bug 36459
This commit is contained in:
rods%netscape.com 2000-04-21 22:28:07 +00:00
Родитель 80f2cdeabf
Коммит d01a3c8d69
2 изменённых файлов: 56 добавлений и 12 удалений

Просмотреть файл

@ -716,16 +716,38 @@ nsHTMLSelectElement::GetValue(nsString& aValue)
} }
result = options->Item(selectedIndex, getter_AddRefs(node)); result = options->Item(selectedIndex, getter_AddRefs(node));
if (NS_SUCCEEDED(result) && node) { if (NS_SUCCEEDED(result) && node) {
nsCOMPtr<nsIDOMHTMLOptionElement> option = do_QueryInterface(node); nsCOMPtr<nsIHTMLContent> option = do_QueryInterface(node);
if (option) { if (option) {
option->GetValue(aValue); nsHTMLValue value;
if (0 == aValue.Length()) { // first check to see if value is there and has a value
option->GetLabel(aValue); nsresult rv = option->GetHTMLAttribute(nsHTMLAtoms::value, value);
if (0 == aValue.Length()) { if (NS_CONTENT_ATTR_HAS_VALUE == rv) {
option->GetText(aValue); if (eHTMLUnit_String == value.GetUnit()) {
value.GetStringValue(aValue);
} else {
aValue = "";
} }
return NS_OK;
} }
// first check to see if label is there and has a value
rv = option->GetHTMLAttribute(nsHTMLAtoms::label, value);
if (NS_CONTENT_ATTR_HAS_VALUE == rv) {
if (eHTMLUnit_String == value.GetUnit()) {
value.GetStringValue(aValue);
} else {
aValue = "";
} }
return NS_OK;
}
nsCOMPtr<nsIDOMHTMLOptionElement> optElement = do_QueryInterface(node);
if (optElement) {
optElement->GetText(aValue);
}
return NS_OK;
}
} }
} }
} }

Просмотреть файл

@ -716,16 +716,38 @@ nsHTMLSelectElement::GetValue(nsString& aValue)
} }
result = options->Item(selectedIndex, getter_AddRefs(node)); result = options->Item(selectedIndex, getter_AddRefs(node));
if (NS_SUCCEEDED(result) && node) { if (NS_SUCCEEDED(result) && node) {
nsCOMPtr<nsIDOMHTMLOptionElement> option = do_QueryInterface(node); nsCOMPtr<nsIHTMLContent> option = do_QueryInterface(node);
if (option) { if (option) {
option->GetValue(aValue); nsHTMLValue value;
if (0 == aValue.Length()) { // first check to see if value is there and has a value
option->GetLabel(aValue); nsresult rv = option->GetHTMLAttribute(nsHTMLAtoms::value, value);
if (0 == aValue.Length()) { if (NS_CONTENT_ATTR_HAS_VALUE == rv) {
option->GetText(aValue); if (eHTMLUnit_String == value.GetUnit()) {
value.GetStringValue(aValue);
} else {
aValue = "";
} }
return NS_OK;
} }
// first check to see if label is there and has a value
rv = option->GetHTMLAttribute(nsHTMLAtoms::label, value);
if (NS_CONTENT_ATTR_HAS_VALUE == rv) {
if (eHTMLUnit_String == value.GetUnit()) {
value.GetStringValue(aValue);
} else {
aValue = "";
} }
return NS_OK;
}
nsCOMPtr<nsIDOMHTMLOptionElement> optElement = do_QueryInterface(node);
if (optElement) {
optElement->GetText(aValue);
}
return NS_OK;
}
} }
} }
} }