本文整理汇总了C++中RenderBoxModelObject::layout方法的典型用法代码示例。如果您正苦于以下问题:C++ RenderBoxModelObject::layout方法的具体用法?C++ RenderBoxModelObject::layout怎么用?C++ RenderBoxModelObject::layout使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RenderBoxModelObject
的用法示例。
在下文中一共展示了RenderBoxModelObject::layout方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: layout
void RenderMathMLRoot::layout()
{
RenderBlock::layout();
if (!firstChild() || !lastChild())
return;
int baseHeight = toRenderBoxModelObject(lastChild())->pixelSnappedOffsetHeight();
if (!baseHeight)
baseHeight = style()->fontSize();
RenderObject* base = lastChild()->firstChild();
if (base)
base->style()->setVerticalAlign(BASELINE); // FIXME: Can this style be modified?
// Base height above which the shape of the root changes
int thresholdHeight = static_cast<int>(gThresholdBaseHeightEms * style()->fontSize());
int overbarLeftPointShift = 0;
// FIXME: Can style() and indexBox->style() be modified (4 times below)?
if (baseHeight > thresholdHeight && thresholdHeight) {
float shift = (baseHeight - thresholdHeight) / static_cast<float>(thresholdHeight);
if (shift > 1.)
shift = 1.0f;
int frontWidth = static_cast<int>(style()->fontSize() * gFrontWidthEms);
overbarLeftPointShift = static_cast<int>(gRadicalBottomPointXFront * frontWidth * shift);
style()->setPaddingBottom(Length(static_cast<int>(gBigRootBottomPaddingEms * style()->fontSize()), Fixed));
}
// Positioning of the index
RenderObject* possibleIndex = firstChild()->firstChild();
while (possibleIndex && !possibleIndex->isBoxModelObject())
possibleIndex = possibleIndex->nextSibling();
RenderBoxModelObject* indexBox = toRenderBoxModelObject(possibleIndex);
if (!indexBox)
return;
int shiftForIndex = indexBox->pixelSnappedOffsetWidth() + overbarLeftPointShift;
int partDipHeight = static_cast<int>((1 - gRadicalDipLeftPointYPos) * baseHeight);
int rootExtraTop = partDipHeight + style()->paddingBottom().value() + indexBox->pixelSnappedOffsetHeight()
- (baseHeight + static_cast<int>(gRootPaddingEms * style()->fontSize()));
style()->setPaddingLeft(Length(shiftForIndex, Fixed));
if (rootExtraTop > 0)
style()->setPaddingTop(Length(rootExtraTop + static_cast<int>(gRootPaddingEms * style()->fontSize()), Fixed));
setNeedsLayout(true);
setPreferredLogicalWidthsDirty(true, MarkOnlyThis); // FIXME: Can this really be right?
RenderBlock::layout();
indexBox->style()->setBottom(Length(partDipHeight + style()->paddingBottom().value(), Fixed));
// Now that we've potentially changed its position, we need layout the index again.
indexBox->setNeedsLayout(true);
indexBox->layout();
}
示例2: layout
void RenderMathMLRoot::layout()
{
RenderBlock::layout();
if (!firstChild() || !lastChild())
return;
int maxHeight = toRenderBoxModelObject(lastChild())->offsetHeight();
RenderObject* current = lastChild()->firstChild();
if (current)
current->style()->setVerticalAlign(BASELINE);
if (!maxHeight)
maxHeight = style()->fontSize();
// Base height above which the shape of the root changes
int thresholdHeight = static_cast<int>(gThresholdBaseHeight * style()->fontSize());
int topStartShift = 0;
if (maxHeight > thresholdHeight && thresholdHeight) {
float shift = (maxHeight - thresholdHeight) / static_cast<float>(thresholdHeight);
if (shift > 1.)
shift = 1.0f;
int frontWidth = static_cast<int>(style()->fontSize() * gRadicalWidth);
topStartShift = static_cast<int>(gRadicalBottomPointXPos * frontWidth * shift);
style()->setPaddingBottom(Length(static_cast<int>(gRootBottomPadding * style()->fontSize()), Fixed));
}
// Positioning of the index
RenderObject* possibleIndex = firstChild()->firstChild();
while (possibleIndex && !possibleIndex->isBoxModelObject())
possibleIndex = possibleIndex->nextSibling();
RenderBoxModelObject* indexBox = toRenderBoxModelObject(possibleIndex);
if (!indexBox)
return;
int indexShift = indexBox->offsetWidth() + topStartShift;
int radicalHeight = static_cast<int>((1 - gRadicalTopLeftPointYPos) * maxHeight);
int rootMarginTop = radicalHeight + style()->paddingBottom().value() + indexBox->offsetHeight() - (maxHeight + static_cast<int>(gRootPadding * style()->fontSize()));
style()->setPaddingLeft(Length(indexShift, Fixed));
if (rootMarginTop > 0)
style()->setPaddingTop(Length(rootMarginTop + static_cast<int>(gRootPadding * style()->fontSize()), Fixed));
setNeedsLayout(true);
setPreferredLogicalWidthsDirty(true, false);
RenderBlock::layout();
indexBox->style()->setBottom(Length(radicalHeight + style()->paddingBottom().value(), Fixed));
// Now that we've potentially changed its position, we need layout the index again.
indexBox->setNeedsLayout(true);
indexBox->layout();
}