String HTMLOptionElement::label() const { const AtomicString& label = fastGetAttribute(labelAttr); if (!label.isNull()) return label; return collectOptionInnerText().stripWhiteSpace(isHTMLSpace).simplifyWhiteSpace(isHTMLSpace); }
String HTMLOptionElement::value() const { const AtomicString& value = fastGetAttribute(valueAttr); if (!value.isNull()) return value; return collectOptionInnerText().stripWhiteSpace(isHTMLSpace).simplifyWhiteSpace(isHTMLSpace); }
String OptionElement::collectOptionValue(const OptionElementData& data, const Element* element) { String value = data.value(); if (!value.isNull()) return value; // Use the text if the value wasn't set. return collectOptionInnerText(element).stripWhiteSpace(); }
String OptionElement::collectOptionLabelOrText(const OptionElementData& data, const Element* element) { Document& document = element->document(); String text; // WinIE does not use the label attribute, so as a quirk, we ignore it. if (document.inQuirksMode()) text = data.label(); if (text.isEmpty()) text = collectOptionInnerText(element); return text.stripWhiteSpace().simplifyWhiteSpace(); }
String OptionElement::collectOptionLabelOrText(const OptionElementData& data, const Element* element) { Document* document = element->document(); String text; // WinIE does not use the label attribute, so as a quirk, we ignore it. if (!document->inQuirksMode()) text = data.label(); if (text.isEmpty()) text = collectOptionInnerText(element); return normalizeText(document, text); }
String HTMLOptionElement::text() const { Document* document = this->document(); String text; // WinIE does not use the label attribute, so as a quirk, we ignore it. if (!document->inQuirksMode()) text = fastGetAttribute(labelAttr); // FIXME: The following treats an element with the label attribute set to // the empty string the same as an element with no label attribute at all. // Is that correct? If it is, then should the label function work the same way? if (text.isEmpty()) text = collectOptionInnerText(); // FIXME: Is displayStringModifiedByEncoding helpful here? // If it's correct here, then isn't it needed in the value and label functions too? return document->displayStringModifiedByEncoding(text).stripWhiteSpace(isHTMLSpace).simplifyWhiteSpace(isHTMLSpace); }