本文整理汇总了C++中RenderElement::firstLineStyle方法的典型用法代码示例。如果您正苦于以下问题:C++ RenderElement::firstLineStyle方法的具体用法?C++ RenderElement::firstLineStyle怎么用?C++ RenderElement::firstLineStyle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RenderElement
的用法示例。
在下文中一共展示了RenderElement::firstLineStyle方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ascentAndDescentForBox
//.........这里部分代码省略.........
LayoutUnit RootInlineBox::verticalPositionForBox(InlineBox* box, VerticalPositionCache& verticalPositionCache)
{
if (box->renderer().isTextOrLineBreak())
return box->parent()->logicalTop();
RenderBoxModelObject* renderer = box->boxModelObject();
ASSERT(renderer->isInline());
if (!renderer->isInline())
return 0;
// This method determines the vertical position for inline elements.
bool firstLine = isFirstLine();
if (firstLine && !renderer->document().styleSheetCollection().usesFirstLineRules())
firstLine = false;
// Check the cache.
bool isRenderInline = renderer->isRenderInline();
if (isRenderInline && !firstLine) {
LayoutUnit verticalPosition = verticalPositionCache.get(renderer, baselineType());
if (verticalPosition != PositionUndefined)
return verticalPosition;
}
LayoutUnit verticalPosition = 0;
EVerticalAlign verticalAlign = renderer->style().verticalAlign();
if (verticalAlign == TOP || verticalAlign == BOTTOM)
return 0;
RenderElement* parent = renderer->parent();
if (parent->isRenderInline() && parent->style().verticalAlign() != TOP && parent->style().verticalAlign() != BOTTOM)
verticalPosition = box->parent()->logicalTop();
if (verticalAlign != BASELINE) {
const RenderStyle& parentLineStyle = firstLine ? parent->firstLineStyle() : parent->style();
const Font& font = parentLineStyle.font();
const FontMetrics& fontMetrics = font.fontMetrics();
int fontSize = font.pixelSize();
LineDirectionMode lineDirection = parent->isHorizontalWritingMode() ? HorizontalLine : VerticalLine;
if (verticalAlign == SUB)
verticalPosition += fontSize / 5 + 1;
else if (verticalAlign == SUPER)
verticalPosition -= fontSize / 3 + 1;
else if (verticalAlign == TEXT_TOP)
verticalPosition += renderer->baselinePosition(baselineType(), firstLine, lineDirection) - fontMetrics.ascent(baselineType());
else if (verticalAlign == MIDDLE)
verticalPosition = (verticalPosition - LayoutUnit(fontMetrics.xHeight() / 2) - renderer->lineHeight(firstLine, lineDirection) / 2 + renderer->baselinePosition(baselineType(), firstLine, lineDirection)).round();
else if (verticalAlign == TEXT_BOTTOM) {
verticalPosition += fontMetrics.descent(baselineType());
// lineHeight - baselinePosition is always 0 for replaced elements (except inline blocks), so don't bother wasting time in that case.
if (!renderer->isReplaced() || renderer->isInlineBlockOrInlineTable())
verticalPosition -= (renderer->lineHeight(firstLine, lineDirection) - renderer->baselinePosition(baselineType(), firstLine, lineDirection));
} else if (verticalAlign == BASELINE_MIDDLE)
verticalPosition += -renderer->lineHeight(firstLine, lineDirection) / 2 + renderer->baselinePosition(baselineType(), firstLine, lineDirection);
else if (verticalAlign == LENGTH) {
LayoutUnit lineHeight;
//Per http://www.w3.org/TR/CSS21/visudet.html#propdef-vertical-align: 'Percentages: refer to the 'line-height' of the element itself'.
if (renderer->style().verticalAlignLength().isPercent())
lineHeight = renderer->style().computedLineHeight();
else
lineHeight = renderer->lineHeight(firstLine, lineDirection);
verticalPosition -= valueForLength(renderer->style().verticalAlignLength(), lineHeight);
}
}