本文整理汇总了C++中HTMLOptionElement::textIndentedToRespectGroupLabel方法的典型用法代码示例。如果您正苦于以下问题:C++ HTMLOptionElement::textIndentedToRespectGroupLabel方法的具体用法?C++ HTMLOptionElement::textIndentedToRespectGroupLabel怎么用?C++ HTMLOptionElement::textIndentedToRespectGroupLabel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HTMLOptionElement
的用法示例。
在下文中一共展示了HTMLOptionElement::textIndentedToRespectGroupLabel方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: paintTextArea
bool RenderThemeAndroid::paintTextArea(RenderObject* obj, const RenderObject::PaintInfo& info, const IntRect& rect)
{
if (!obj->isListBox())
return true;
paintCombo(obj, info, rect);
RenderStyle* style = obj->style();
if (style)
style->setColor(Color::transparent);
Node* node = obj->node();
if (!node || !node->hasTagName(HTMLNames::selectTag))
return true;
HTMLSelectElement* select = static_cast<HTMLSelectElement*>(node);
// The first item may be visible. Make sure it does not draw.
// If it has a style, it overrides the RenderListBox's style, so we
// need to make sure both are set to transparent.
node = select->item(0);
if (node) {
RenderObject* renderer = node->renderer();
if (renderer) {
RenderStyle* renderStyle = renderer->style();
if (renderStyle)
renderStyle->setColor(Color::transparent);
}
}
// Find the first selected option, and draw its text.
// FIXME: In a later change, if there is more than one item selected,
// draw a string that says "X items" like iPhone Safari does
int index = select->selectedIndex();
node = select->item(index);
if (!node || !node->hasTagName(HTMLNames::optionTag))
return true;
HTMLOptionElement* option = static_cast<HTMLOptionElement*>(node);
String label = option->textIndentedToRespectGroupLabel();
SkRect r(rect);
SkPaint paint;
paint.setAntiAlias(true);
paint.setTextEncoding(SkPaint::kUTF16_TextEncoding);
// Values for text size and positioning determined by trial and error
paint.setTextSize(r.height() - SkIntToScalar(6));
SkCanvas* canvas = getCanvasFromInfo(info);
int saveCount = canvas->save();
r.fRight -= SkIntToScalar(RenderSkinCombo::extraWidth());
canvas->clipRect(r);
canvas->drawText(label.characters(), label.length() << 1,
r.fLeft + SkIntToScalar(5), r.fBottom - SkIntToScalar(5), paint);
canvas->restoreToCount(saveCount);
return true;
}
示例2: setTextFromOption
void LayoutMenuList::setTextFromOption(int optionIndex)
{
HTMLSelectElement* select = selectElement();
const HeapVector<Member<HTMLElement>>& listItems = select->listItems();
const int size = listItems.size();
String text = emptyString();
m_optionStyle.clear();
if (selectElement()->multiple()) {
unsigned selectedCount = 0;
int firstSelectedIndex = -1;
for (int i = 0; i < size; ++i) {
Element* element = listItems[i];
if (!isHTMLOptionElement(*element))
continue;
if (toHTMLOptionElement(element)->selected()) {
if (++selectedCount == 1)
firstSelectedIndex = i;
}
}
if (selectedCount == 1) {
ASSERT(0 <= firstSelectedIndex);
ASSERT(firstSelectedIndex < size);
HTMLOptionElement* selectedOptionElement = toHTMLOptionElement(listItems[firstSelectedIndex]);
ASSERT(selectedOptionElement->selected());
text = selectedOptionElement->textIndentedToRespectGroupLabel();
m_optionStyle = selectedOptionElement->mutableComputedStyle();
} else {
Locale& locale = select->locale();
String localizedNumberString = locale.convertToLocalizedNumber(String::number(selectedCount));
text = locale.queryString(WebLocalizedString::SelectMenuListText, localizedNumberString);
ASSERT(!m_optionStyle);
}
} else {
const int i = select->optionToListIndex(optionIndex);
if (i >= 0 && i < size) {
Element* element = listItems[i];
if (isHTMLOptionElement(*element)) {
text = toHTMLOptionElement(element)->textIndentedToRespectGroupLabel();
m_optionStyle = element->mutableComputedStyle();
}
}
}
setText(text.stripWhiteSpace());
didUpdateActiveOption(optionIndex);
}
示例3: updateFromElement
void LayoutMenuList::updateFromElement() {
HTMLSelectElement* select = selectElement();
HTMLOptionElement* option = select->optionToBeShown();
String text = emptyString();
m_optionStyle.clear();
if (select->isMultiple()) {
unsigned selectedCount = 0;
HTMLOptionElement* selectedOptionElement = nullptr;
for (const auto& option : select->optionList()) {
if (option->selected()) {
if (++selectedCount == 1)
selectedOptionElement = option;
}
}
if (selectedCount == 1) {
text = selectedOptionElement->textIndentedToRespectGroupLabel();
m_optionStyle = selectedOptionElement->mutableComputedStyle();
} else {
Locale& locale = select->locale();
String localizedNumberString =
locale.convertToLocalizedNumber(String::number(selectedCount));
text = locale.queryString(WebLocalizedString::SelectMenuListText,
localizedNumberString);
ASSERT(!m_optionStyle);
}
} else {
if (option) {
text = option->textIndentedToRespectGroupLabel();
m_optionStyle = option->mutableComputedStyle();
}
}
setText(text.stripWhiteSpace());
didUpdateActiveOption(option);
}