Update menu list text when popup is visible

http://src.chromium.org/viewvc/blink?view=rev&revision=184106
added updateFromElement() in RenderMenuList::popupDidHide()
to ensure the text is updated which wasn't updated when the
popup is visible.

This causes unnecessary invalidation when popup is closed when
selected item didn't change.

Now always update text in RenderMenuList::updateFromElement()
despite visibility of popup, and don't call updateFromElement()
from popupDidHide() to avoid unnecessary invalidation.

BTW fix an issue that the select title text was not updated
when selectedIndex is changed by program when the popup is
visible.

BUG=430857
TEST=fast/forms/select/menulist-update-text-popup.html

Review URL: https://codereview.chromium.org/706843004

git-svn-id: svn://svn.chromium.org/blink/trunk@184945 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 504bd358
......@@ -1392,6 +1392,8 @@ crbug.com/421854 [ SnowLeopard Debug ] fast/dom/52776.html [ Pass Crash ]
crbug.com/421854 [ SnowLeopard Debug ] virtual/antialiasedtext/fast/text/sub-pixel/text-scaling-rtl.html [ Pass Crash ]
crbug.com/421854 [ SnowLeopard Debug ] virtual/textblob/fast/text/sub-pixel/text-scaling-rtl.html [ Pass Crash ]
crbug.com/430857 fast/forms/select/menulist-update-text-popup.html [ NeedsRebaseline ]
# Re-enable these tests once M40 braches.
crbug.com/414283 fast/dynamic/anchor-lock.html [ Pass ImageOnlyFailure ]
crbug.com/414283 fast/events/scale-and-scroll-div.html [ Pass Failure ]
......
Tests <select> text update when popup is visible and selectionIndex changes.
Needs dump-render-tree.
layer at (0,0) size 34x20 backgroundClip at (8,50) size 34x20 clip at (8,50) size 34x20 outlineClip at (8,50) size 34x20
RenderBlock (positioned) {DIV} at (8,50) size 34x20
RenderMenuList {SELECT} at (0,0) size 34x20 [bgcolor=#C0C0C0] [border: (1px solid #A9A9A9)]
RenderBlock (anonymous) at (1,1) size 32x18
RenderText at (4,1) size 9x16
text run at (4,1) width 9: "C"
RenderText {#text} at (0,0) size 0x0
Tests &lt;select&gt; text update when popup is visible and selectionIndex changes.<br>
Needs dump-render-tree.<br>
<div style="position: absolute; top: 50px">
<select id="select">
<option>A</option>
<option>B</option>
<option>C</option>
</select>
</div>
<pre id="output"></pre>
<script>
if (window.testRunner && window.eventSender) {
testRunner.dumpAsText();
var select = document.getElementById('select');
select.focus();
eventSender.keyDown(' ', null);
select.selectedIndex = 2;
// We need to show in the result the title text of the select when popup is visible.
// Must dump renderer tree here otherwise dump-render-tree will close the popup.
// The title text should be "C".
output.textContent = internals.elementRenderTreeAsText(select.parentNode);
testRunner.notifyDone();
}
</script>
......@@ -216,14 +216,13 @@ void RenderMenuList::updateFromElement()
m_optionsChanged = false;
}
if (m_popupIsVisible) {
if (m_popupIsVisible)
m_popup->updateFromElement();
} else {
if (selectElement()->suggestedIndex() >= 0)
setTextFromOption(selectElement()->suggestedIndex());
else
setTextFromOption(selectElement()->selectedIndex());
}
if (selectElement()->suggestedIndex() >= 0)
setTextFromOption(selectElement()->suggestedIndex());
else
setTextFromOption(selectElement()->selectedIndex());
}
void RenderMenuList::setTextFromOption(int optionIndex)
......@@ -568,8 +567,6 @@ int RenderMenuList::selectedIndex() const
void RenderMenuList::popupDidHide()
{
m_popupIsVisible = false;
// Ensure the text is updated which wasn't updated when the popup is visible.
updateFromElement();
}
bool RenderMenuList::itemIsSeparator(unsigned listIndex) const
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment