Index: Source/core/html/HTMLSelectElement.cpp |
diff --git a/Source/core/html/HTMLSelectElement.cpp b/Source/core/html/HTMLSelectElement.cpp |
index ed9942c1b431faf10bf5242adf2dab270549dd4b..4c08b470faea4f74108878d90be47ade54cbd2e3 100644 |
--- a/Source/core/html/HTMLSelectElement.cpp |
+++ b/Source/core/html/HTMLSelectElement.cpp |
@@ -74,6 +74,7 @@ HTMLSelectElement::HTMLSelectElement(Document& document, HTMLFormElement* form) |
, m_activeSelectionState(false) |
, m_shouldRecalcListItems(false) |
, m_suggestedIndex(-1) |
+ , m_optionChildChangedTimer(this, &HTMLSelectElement::timerFired) |
{ |
ScriptWrappable::init(this); |
} |
@@ -508,11 +509,12 @@ int HTMLSelectElement::nextValidIndex(int listIndex, SkipDirection direction, in |
int size = listItems.size(); |
for (listIndex += direction; listIndex >= 0 && listIndex < size; listIndex += direction) { |
--skip; |
- if (!listItems[listIndex]->isDisabledFormControl() && isHTMLOptionElement(*listItems[listIndex])) { |
- lastGoodIndex = listIndex; |
- if (skip <= 0) |
- break; |
- } |
+ HTMLElement* element = listItems[listIndex]; |
+ if (!isHTMLOptionElement(*element) || toHTMLOptionElement(element)->isDisabledFormControl() || !toHTMLOptionElement(element)->isDisplayNone()) |
+ continue; |
+ lastGoodIndex = listIndex; |
+ if (skip <= 0) |
+ break; |
} |
return lastGoodIndex; |
} |
@@ -625,7 +627,7 @@ void HTMLSelectElement::updateListBoxSelection(bool deselectOtherOptions) |
const Vector<HTMLElement*>& items = listItems(); |
for (unsigned i = 0; i < items.size(); ++i) { |
HTMLElement* element = items[i]; |
- if (!isHTMLOptionElement(*element) || toHTMLOptionElement(element)->isDisabledFormControl()) |
+ if (!isHTMLOptionElement(*element) || toHTMLOptionElement(element)->isDisabledFormControl() || !toHTMLOptionElement(element)->isDisplayNone()) |
continue; |
if (i >= start && i <= end) |
@@ -1624,4 +1626,20 @@ bool HTMLSelectElement::supportsAutofocus() const |
return true; |
} |
+void HTMLSelectElement::updateListOnRenderer() |
+{ |
+ if (m_optionChildChangedTimer.isActive()) |
+ return; |
+ ASSERT(!m_optionChildChangedTimer.isActive()); |
+ m_optionChildChangedTimer.startOneShot(0, FROM_HERE); |
esprehn
2014/03/20 17:09:25
This is not correct, you can't use a timer.
spartha
2014/03/21 21:37:36
Just curious, when is it recommended to use a time
|
+} |
+ |
+void HTMLSelectElement::timerFired(Timer<HTMLSelectElement>* ) |
+{ |
+ setOptionsChangedOnRenderer(); |
+ // Update the renderer with the new list. |
+ if (RenderObject* renderer = this->renderer()) |
+ renderer->updateFromElement(); |
+} |
+ |
} // namespace |