Bug 899931 - Part c: Cleanup nsListControlFrame::GetOptionText; r=dzbarsky

This commit is contained in:
Ms2ger 2013-08-02 09:07:08 +02:00
parent e32b9b8720
commit 4d9a9aa40c
3 changed files with 6 additions and 38 deletions

View File

@ -29,7 +29,7 @@ public:
/**
* Get the display string for an item
*/
virtual void GetOptionText(int32_t aIndex, nsAString & aStr) = 0;
virtual void GetOptionText(uint32_t aIndex, nsAString& aStr) = 0;
/**
* Get the Selected Item's index

View File

@ -1158,43 +1158,11 @@ nsListControlFrame::SetComboboxFrame(nsIFrame* aComboboxFrame)
}
void
nsListControlFrame::GetOptionText(int32_t aIndex, nsAString & aStr)
nsListControlFrame::GetOptionText(uint32_t aIndex, nsAString& aStr)
{
aStr.SetLength(0);
nsCOMPtr<nsIDOMHTMLOptionsCollection> options = GetOptions(mContent);
if (options) {
uint32_t numOptions;
options->GetLength(&numOptions);
if (numOptions != 0) {
nsCOMPtr<nsIDOMHTMLOptionElement> optionElement =
GetOption(options, aIndex);
if (optionElement) {
#if 0 // This is for turning off labels Bug 4050
nsAutoString text;
optionElement->GetLabel(text);
// the return value is always NS_OK from DOMElements
// it is meaningless to check for it
if (!text.IsEmpty()) {
nsAutoString compressText = text;
compressText.CompressWhitespace(true, true);
if (!compressText.IsEmpty()) {
text = compressText;
}
}
if (text.IsEmpty()) {
// the return value is always NS_OK from DOMElements
// it is meaningless to check for it
optionElement->GetText(text);
}
aStr = text;
#else
optionElement->GetText(aStr);
#endif
}
}
aStr.Truncate();
if (dom::HTMLOptionElement* optionElement = GetOption(aIndex)) {
optionElement->GetText(aStr);
}
}

View File

@ -124,7 +124,7 @@ public:
* If the there are zero items then an empty string is returned
* If there is nothing selected, then the 0th item's text is returned.
*/
virtual void GetOptionText(int32_t aIndex, nsAString & aStr) MOZ_OVERRIDE;
virtual void GetOptionText(uint32_t aIndex, nsAString& aStr) MOZ_OVERRIDE;
virtual void CaptureMouseEvents(bool aGrabMouseEvents) MOZ_OVERRIDE;
virtual nscoord GetHeightOfARow() MOZ_OVERRIDE;