зеркало из https://github.com/mozilla/gecko-dev.git
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:
Родитель
80f2cdeabf
Коммит
d01a3c8d69
|
@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче