void RenderMenuList::setTextFromOption(int optionIndex) { SelectElement* select = toSelectElement(static_cast<Element*>(node())); const Vector<Element*>& listItems = select->listItems(); int size = listItems.size(); int i = select->optionToListIndex(optionIndex); String text = ""; if (i >= 0 && i < size) { if (OptionElement* optionElement = toOptionElement(listItems[i])) text = optionElement->textIndentedToRespectGroupLabel(); } setText(text.stripWhiteSpace()); }
void RenderMenuList::showPopup() { if (m_popupIsVisible) return; // Create m_innerBlock here so it ends up as the first child. // This is important because otherwise we might try to create m_innerBlock // inside the showPopup call and it would fail. createInnerBlock(); if (!m_popup) m_popup = document()->page()->chrome()->createPopupMenu(this); SelectElement* select = toSelectElement(static_cast<Element*>(node())); m_popupIsVisible = true; // Compute the top left taking transforms into account, but use // the actual width of the element to size the popup. FloatPoint absTopLeft = localToAbsolute(FloatPoint(), false, true); IntRect absBounds = absoluteBoundingBoxRect(); absBounds.setLocation(roundedIntPoint(absTopLeft)); m_popup->show(absBounds, document()->view(), select->optionToListIndex(select->selectedIndex())); }
int RenderMenuList::selectedIndex() const { SelectElement* select = toSelectElement(static_cast<Element*>(node())); return select->optionToListIndex(select->selectedIndex()); }