本文整理汇总了C++中FontDescription::bolderWeight方法的典型用法代码示例。如果您正苦于以下问题:C++ FontDescription::bolderWeight方法的具体用法?C++ FontDescription::bolderWeight怎么用?C++ FontDescription::bolderWeight使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FontDescription
的用法示例。
在下文中一共展示了FontDescription::bolderWeight方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: updateFromElement
void RenderListBox::updateFromElement()
{
if (m_optionsChanged) {
const Vector<Element*>& listItems = toSelectElement(static_cast<Element*>(node()))->listItems();
int size = numItems();
float width = 0;
for (int i = 0; i < size; ++i) {
Element* element = listItems[i];
String text;
Font itemFont = style()->font();
if (OptionElement* optionElement = toOptionElement(element))
text = optionElement->textIndentedToRespectGroupLabel();
else if (OptionGroupElement* optionGroupElement = toOptionGroupElement(element)) {
text = optionGroupElement->groupLabelText();
FontDescription d = itemFont.fontDescription();
d.setWeight(d.bolderWeight());
itemFont = Font(d, itemFont.letterSpacing(), itemFont.wordSpacing());
itemFont.update(document()->styleSelector()->fontSelector());
}
if (!text.isEmpty()) {
float textWidth = itemFont.floatWidth(TextRun(text.impl(), 0, 0, 0, false, false, false, false));
width = max(width, textWidth);
}
}
m_optionsWidth = static_cast<int>(ceilf(width));
m_optionsChanged = false;
setHasVerticalScrollbar(true);
setNeedsLayoutAndPrefWidthsRecalc();
}
}
示例2: calculatePositionAndSize
void PopupMenu::calculatePositionAndSize(const IntRect& r, FrameView* v)
{
IntRect rScreenCoords(v->contentsToWindow(r.location()), r.size());
rScreenCoords.setY(rScreenCoords.y() + rScreenCoords.height());
m_itemHeight = rScreenCoords.height();
int itemCount = client()->listSize();
int naturalHeight = m_itemHeight * itemCount;
int popupWidth = 0;
for (int i = 0; i < itemCount; ++i) {
String text = client()->itemText(i);
if (text.isEmpty())
continue;
Font itemFont = client()->clientStyle()->font();
if (client()->itemIsLabel(i)) {
FontDescription d = itemFont.fontDescription();
d.setWeight(d.bolderWeight());
itemFont = Font(d, itemFont.letterSpacing(), itemFont.wordSpacing());
itemFont.update(m_popupClient->fontSelector());
}
popupWidth = max(popupWidth, itemFont.width(TextRun(text.characters(), text.length())));
}
rScreenCoords.setHeight(naturalHeight);
rScreenCoords.setWidth(popupWidth + 10);
m_windowRect = rScreenCoords;
}
示例3: paintItemForeground
void RenderListBox::paintItemForeground(PaintInfo& paintInfo, const LayoutPoint& paintOffset, int listIndex)
{
FontCachePurgePreventer fontCachePurgePreventer;
const Vector<HTMLElement*>& listItems = toHTMLSelectElement(node())->listItems();
HTMLElement* element = listItems[listIndex];
RenderStyle* itemStyle = element->renderStyle();
if (!itemStyle)
itemStyle = style();
if (itemStyle->visibility() == HIDDEN)
return;
String itemText;
bool isOptionElement = element->hasTagName(optionTag);
if (isOptionElement)
itemText = toHTMLOptionElement(element)->textIndentedToRespectGroupLabel();
else if (element->hasTagName(optgroupTag))
itemText = static_cast<const HTMLOptGroupElement*>(element)->groupLabelText();
applyTextTransform(style(), itemText, ' ');
Color textColor = element->renderStyle() ? element->renderStyle()->visitedDependentColor(CSSPropertyColor) : style()->visitedDependentColor(CSSPropertyColor);
if (isOptionElement && toHTMLOptionElement(element)->selected()) {
if (frame()->selection()->isFocusedAndActive() && document()->focusedNode() == node())
textColor = theme()->activeListBoxSelectionForegroundColor();
// Honor the foreground color for disabled items
else if (!element->disabled())
textColor = theme()->inactiveListBoxSelectionForegroundColor();
}
ColorSpace colorSpace = itemStyle->colorSpace();
paintInfo.context->setFillColor(textColor, colorSpace);
unsigned length = itemText.length();
const UChar* string = itemText.characters();
TextRun textRun(string, length, false, 0, 0, TextRun::AllowTrailingExpansion, itemStyle->direction(), itemStyle->unicodeBidi() == Override, TextRun::NoRounding);
Font itemFont = style()->font();
LayoutRect r = itemBoundingBoxRect(paintOffset, listIndex);
r.move(itemOffsetForAlignment(textRun, itemStyle, itemFont, r));
if (element->hasTagName(optgroupTag)) {
FontDescription d = itemFont.fontDescription();
d.setWeight(d.bolderWeight());
itemFont = Font(d, itemFont.letterSpacing(), itemFont.wordSpacing());
itemFont.update(document()->styleSelector()->fontSelector());
}
// Draw the item text
paintInfo.context->drawBidiText(itemFont, textRun, r.location());
}
示例4: paintItemForeground
void RenderListBox::paintItemForeground(PaintInfo& paintInfo, int tx, int ty, int listIndex)
{
SelectElement* select = toSelectElement(static_cast<Element*>(node()));
const Vector<Element*>& listItems = select->listItems();
Element* element = listItems[listIndex];
OptionElement* optionElement = toOptionElement(element);
String itemText;
if (optionElement)
itemText = optionElement->textIndentedToRespectGroupLabel();
else if (OptionGroupElement* optionGroupElement = toOptionGroupElement(element))
itemText = optionGroupElement->groupLabelText();
// Determine where the item text should be placed
IntRect r = itemBoundingBoxRect(tx, ty, listIndex);
r.move(optionsSpacingHorizontal, style()->font().ascent());
RenderStyle* itemStyle = element->renderStyle();
if (!itemStyle)
itemStyle = style();
Color textColor = element->renderStyle() ? element->renderStyle()->color() : style()->color();
if (optionElement && optionElement->selected()) {
if (document()->frame()->selection()->isFocusedAndActive() && document()->focusedNode() == node())
textColor = theme()->activeListBoxSelectionForegroundColor();
// Honor the foreground color for disabled items
else if (!element->disabled())
textColor = theme()->inactiveListBoxSelectionForegroundColor();
}
ColorSpace colorSpace = itemStyle->colorSpace();
paintInfo.context->setFillColor(textColor, colorSpace);
Font itemFont = style()->font();
if (isOptionGroupElement(element)) {
FontDescription d = itemFont.fontDescription();
d.setWeight(d.bolderWeight());
itemFont = Font(d, itemFont.letterSpacing(), itemFont.wordSpacing());
itemFont.update(document()->styleSelector()->fontSelector());
}
unsigned length = itemText.length();
const UChar* string = itemText.characters();
TextRun textRun(string, length, 0, 0, 0, itemStyle->direction() == RTL, itemStyle->unicodeBidi() == Override, false, false);
// Draw the item text
if (itemStyle->visibility() != HIDDEN)
paintInfo.context->drawBidiText(itemFont, textRun, r.location());
}
示例5: applyValue
virtual void applyValue(CSSStyleSelector* selector, CSSValue* value) const
{
if (!value->isPrimitiveValue())
return;
CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value);
FontDescription fontDescription = selector->fontDescription();
switch (primitiveValue->getIdent()) {
case CSSValueInvalid:
ASSERT_NOT_REACHED();
break;
case CSSValueBolder:
fontDescription.setWeight(fontDescription.bolderWeight());
break;
case CSSValueLighter:
fontDescription.setWeight(fontDescription.lighterWeight());
break;
default:
fontDescription.setWeight(*primitiveValue);
}
selector->setFontDescription(fontDescription);
}
示例6: updateFromElement
void RenderListBox::updateFromElement()
{
FontCachePurgePreventer fontCachePurgePreventer;
if (m_optionsChanged) {
const Vector<HTMLElement*>& listItems = toHTMLSelectElement(node())->listItems();
int size = numItems();
float width = 0;
for (int i = 0; i < size; ++i) {
HTMLElement* element = listItems[i];
String text;
Font itemFont = style()->font();
if (element->hasTagName(optionTag))
text = toHTMLOptionElement(element)->textIndentedToRespectGroupLabel();
else if (element->hasTagName(optgroupTag)) {
text = static_cast<const HTMLOptGroupElement*>(element)->groupLabelText();
FontDescription d = itemFont.fontDescription();
d.setWeight(d.bolderWeight());
itemFont = Font(d, itemFont.letterSpacing(), itemFont.wordSpacing());
itemFont.update(document()->styleSelector()->fontSelector());
}
if (!text.isEmpty()) {
applyTextTransform(style(), text, ' ');
// FIXME: Why is this always LTR? Can't text direction affect the width?
TextRun textRun = constructTextRun(this, itemFont, text, style(), TextRun::AllowTrailingExpansion);
textRun.disableRoundingHacks();
float textWidth = itemFont.width(textRun);
width = max(width, textWidth);
}
}
m_optionsWidth = static_cast<int>(ceilf(width));
m_optionsChanged = false;
setHasVerticalScrollbar(true);
setNeedsLayoutAndPrefWidthsRecalc();
}
}