本文整理汇总了C++中HTMLOptGroupElement::getAttribute方法的典型用法代码示例。如果您正苦于以下问题:C++ HTMLOptGroupElement::getAttribute方法的具体用法?C++ HTMLOptGroupElement::getAttribute怎么用?C++ HTMLOptGroupElement::getAttribute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HTMLOptGroupElement
的用法示例。
在下文中一共展示了HTMLOptGroupElement::getAttribute方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: updateFromElement
void DeprecatedRenderSelect::updateFromElement()
{
m_ignoreSelectEvents = true;
// change widget type
bool oldMultiple = m_multiple;
m_multiple = static_cast<HTMLSelectElement*>(node())->multiple();
if (oldMultiple != m_multiple) {
static_cast<ListBox*>(m_widget)->setSelectionMode(m_multiple ? ListBox::Extended : ListBox::Single);
m_selectionChanged = true;
m_optionsChanged = true;
}
// update contents listbox/combobox based on options in m_element
if (m_optionsChanged) {
static_cast<HTMLSelectElement*>(node())->recalcListItems();
const Vector<HTMLElement*>& listItems = static_cast<HTMLSelectElement*>(node())->listItems();
int listIndex;
static_cast<ListBox*>(m_widget)->clear();
bool groupEnabled = true;
for (listIndex = 0; listIndex < int(listItems.size()); listIndex++) {
if (listItems[listIndex]->hasTagName(optgroupTag)) {
HTMLOptGroupElement* optgroupElement = static_cast<HTMLOptGroupElement*>(listItems[listIndex]);
DeprecatedString label = optgroupElement->getAttribute(labelAttr).deprecatedString();
label.replace('\\', backslashAsCurrencySymbol());
// In WinIE, an optgroup can't start or end with whitespace (other than the indent
// we give it). We match this behavior.
label = label.stripWhiteSpace();
// We want to collapse our whitespace too. This will match other browsers.
label = label.simplifyWhiteSpace();
groupEnabled = optgroupElement->isEnabled();
static_cast<ListBox*>(m_widget)->appendGroupLabel(label, groupEnabled);
} else if (listItems[listIndex]->hasTagName(optionTag)) {
HTMLOptionElement* optionElement = static_cast<HTMLOptionElement*>(listItems[listIndex]);
DeprecatedString itemText = optionElement->text().deprecatedString();
if (itemText.isEmpty())
itemText = optionElement->getAttribute(labelAttr).deprecatedString();
itemText.replace('\\', backslashAsCurrencySymbol());
// In WinIE, leading and trailing whitespace is ignored in options. We match this behavior.
itemText = itemText.stripWhiteSpace();
// We want to collapse our whitespace too. This will match other browsers.
itemText = itemText.simplifyWhiteSpace();
if (listItems[listIndex]->parentNode()->hasTagName(optgroupTag))
itemText.prepend(" ");
static_cast<ListBox*>(m_widget)->appendItem(itemText, groupEnabled && optionElement->isEnabled());
} else
ASSERT(false);
m_selectionChanged = true;
}
static_cast<ListBox*>(m_widget)->doneAppendingItems();
setNeedsLayoutAndMinMaxRecalc();
m_optionsChanged = false;
}
// update selection
if (m_selectionChanged)
updateSelection();
m_ignoreSelectEvents = false;
RenderFormElement::updateFromElement();
}