本文整理汇总了C++中TextRun::setExpansionBehavior方法的典型用法代码示例。如果您正苦于以下问题:C++ TextRun::setExpansionBehavior方法的具体用法?C++ TextRun::setExpansionBehavior怎么用?C++ TextRun::setExpansionBehavior使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TextRun
的用法示例。
在下文中一共展示了TextRun::setExpansionBehavior方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: paintObject
void FileUploadControlPainter::paintObject(const PaintInfo& paintInfo, const LayoutPoint& paintOffset)
{
if (m_layoutFileUploadControl.style()->visibility() != VISIBLE)
return;
// Push a clip.
Optional<ClipRecorder> clipRecorder;
if (paintInfo.phase == PaintPhaseForeground || paintInfo.phase == PaintPhaseDescendantBlockBackgroundsOnly) {
IntRect clipRect = enclosingIntRect(LayoutRect(
LayoutPoint(paintOffset.x() + m_layoutFileUploadControl.borderLeft(), paintOffset.y() + m_layoutFileUploadControl.borderTop()),
m_layoutFileUploadControl.size() + LayoutSize(0, -m_layoutFileUploadControl.borderWidth() + buttonShadowHeight)));
if (clipRect.isEmpty())
return;
clipRecorder.emplace(paintInfo.context, m_layoutFileUploadControl, DisplayItem::ClipFileUploadControlRect, clipRect);
}
if (paintInfo.phase == PaintPhaseForeground && !LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(paintInfo.context, m_layoutFileUploadControl, paintInfo.phase)) {
const String& displayedFilename = m_layoutFileUploadControl.fileTextValue();
const Font& font = m_layoutFileUploadControl.style()->font();
TextRun textRun = constructTextRun(font, displayedFilename, m_layoutFileUploadControl.styleRef(), RespectDirection | RespectDirectionOverride);
textRun.setExpansionBehavior(TextRun::AllowTrailingExpansion);
// Determine where the filename should be placed
LayoutUnit contentLeft = paintOffset.x() + m_layoutFileUploadControl.borderLeft() + m_layoutFileUploadControl.paddingLeft();
Node* button = m_layoutFileUploadControl.uploadButton();
if (!button)
return;
int buttonWidth = (button && button->layoutBox()) ? button->layoutBox()->pixelSnappedWidth() : 0;
LayoutUnit buttonAndSpacingWidth(buttonWidth + LayoutFileUploadControl::afterButtonSpacing);
float textWidth = font.width(textRun);
LayoutUnit textX;
if (m_layoutFileUploadControl.style()->isLeftToRightDirection())
textX = contentLeft + buttonAndSpacingWidth;
else
textX = LayoutUnit(contentLeft + m_layoutFileUploadControl.contentWidth() - buttonAndSpacingWidth - textWidth);
LayoutUnit textY;
// We want to match the button's baseline
// FIXME: Make this work with transforms.
if (LayoutButton* buttonLayoutObject = toLayoutButton(button->layoutObject()))
textY = paintOffset.y() + m_layoutFileUploadControl.borderTop() + m_layoutFileUploadControl.paddingTop() + buttonLayoutObject->baselinePosition(AlphabeticBaseline, true, HorizontalLine, PositionOnContainingLine);
else
textY = LayoutUnit(m_layoutFileUploadControl.baselinePosition(AlphabeticBaseline, true, HorizontalLine, PositionOnContainingLine));
TextRunPaintInfo textRunPaintInfo(textRun);
// FIXME: Shouldn't these offsets be rounded? crbug.com/350474
textRunPaintInfo.bounds = FloatRect(textX.toFloat(), textY.toFloat() - m_layoutFileUploadControl.style()->getFontMetrics().ascent(),
textWidth, m_layoutFileUploadControl.style()->getFontMetrics().height());
// Draw the filename.
LayoutObjectDrawingRecorder recorder(paintInfo.context, m_layoutFileUploadControl, paintInfo.phase, textRunPaintInfo.bounds);
paintInfo.context.setFillColor(m_layoutFileUploadControl.resolveColor(CSSPropertyColor));
paintInfo.context.drawBidiText(font, textRunPaintInfo, FloatPoint(roundToInt(textX), roundToInt(textY)));
}
// Paint the children.
m_layoutFileUploadControl.LayoutBlockFlow::paintObject(paintInfo, paintOffset);
}