本文整理汇总了C++中InlineBox::baseline方法的典型用法代码示例。如果您正苦于以下问题:C++ InlineBox::baseline方法的具体用法?C++ InlineBox::baseline怎么用?C++ InlineBox::baseline使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类InlineBox
的用法示例。
在下文中一共展示了InlineBox::baseline方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: computeLogicalBoxHeights
void InlineFlowBox::computeLogicalBoxHeights(int& maxPositionTop, int& maxPositionBottom,
int& maxAscent, int& maxDescent, bool strictMode)
{
if (isRootInlineBox()) {
// Examine our root box.
setHeight(object()->lineHeight(m_firstLine));
bool isTableCell = object()->isTableCell();
if (isTableCell) {
RenderTableCell* tableCell = static_cast<RenderTableCell*>(object());
setBaseline(tableCell->RenderBlock::baselinePosition(m_firstLine));
}
else
setBaseline(object()->baselinePosition(m_firstLine));
if (hasTextChildren() || strictMode) {
int ascent = baseline();
int descent = height() - ascent;
if (maxAscent < ascent)
maxAscent = ascent;
if (maxDescent < descent)
maxDescent = descent;
}
}
for (InlineBox* curr = firstChild(); curr; curr = curr->nextOnLine()) {
if (curr->object()->isPositioned())
continue; // Positioned placeholders don't affect calculations.
curr->setHeight(curr->object()->lineHeight(m_firstLine));
curr->setBaseline(curr->object()->baselinePosition(m_firstLine));
curr->setYPos(curr->object()->verticalPositionHint(m_firstLine));
if (curr->yPos() == PositionTop) {
if (maxPositionTop < curr->height())
maxPositionTop = curr->height();
}
else if (curr->yPos() == PositionBottom) {
if (maxPositionBottom < curr->height())
maxPositionBottom = curr->height();
}
else if (curr->hasTextChildren() || strictMode) {
int ascent = curr->baseline() - curr->yPos();
int descent = curr->height() - ascent;
if (maxAscent < ascent)
maxAscent = ascent;
if (maxDescent < descent)
maxDescent = descent;
}
if (curr->isInlineFlowBox())
static_cast<InlineFlowBox*>(curr)->computeLogicalBoxHeights(maxPositionTop, maxPositionBottom, maxAscent, maxDescent, strictMode);
}
}
示例2: placeBoxesVertically
void InlineFlowBox::placeBoxesVertically(int y, int maxHeight, int maxAscent, bool strictMode,
int& topPosition, int& bottomPosition)
{
if (isRootInlineBox()) {
setYPos(y + maxAscent - baseline());// Place our root box.
// CSS2: 10.8.1 - line-height on the block level element specifies the *minimum*
// height of the generated line box
if (hasTextChildren() && maxHeight < object()->lineHeight(m_firstLine))
maxHeight = object()->lineHeight(m_firstLine);
}
for (InlineBox* curr = firstChild(); curr; curr = curr->nextOnLine()) {
if (curr->object()->isPositioned())
continue; // Positioned placeholders don't affect calculations.
// Adjust boxes to use their real box y/height and not the logical height (as dictated by
// line-height).
if (curr->isInlineFlowBox())
static_cast<InlineFlowBox*>(curr)->placeBoxesVertically(y, maxHeight, maxAscent, strictMode,
topPosition, bottomPosition);
bool childAffectsTopBottomPos = true;
if (curr->yPos() == PositionTop)
curr->setYPos(y);
else if (curr->yPos() == PositionBottom)
curr->setYPos(y + maxHeight - curr->height());
else {
if (!strictMode && !curr->hasTextDescendant())
childAffectsTopBottomPos = false;
curr->setYPos(curr->yPos() + y + maxAscent - curr->baseline());
}
int newY = curr->yPos();
int newHeight = curr->height();
int newBaseline = curr->baseline();
int overflowTop = 0;
int overflowBottom = 0;
if (curr->isInlineTextBox() || curr->isInlineFlowBox()) {
const QFontMetrics &fm = curr->object()->fontMetrics( m_firstLine );
#ifdef APPLE_CHANGES
newBaseline = fm.ascent();
newY += curr->baseline() - newBaseline;
newHeight = newBaseline+fm.descent();
#else
// only adjust if the leading delta is superior to the font's natural leading
if ( kAbs(fm.ascent() - curr->baseline()) > fm.leading()/2 ) {
int ascent = fm.ascent()+fm.leading()/2;
newBaseline = ascent;
newY += curr->baseline() - newBaseline;
newHeight = fm.lineSpacing();
}
#endif
for (ShadowData* shadow = curr->object()->style()->textShadow(); shadow; shadow = shadow->next) {
overflowTop = kMin(overflowTop, shadow->y - shadow->blur);
overflowBottom = kMax(overflowBottom, shadow->y + shadow->blur);
}
if (curr->isInlineFlowBox()) {
newHeight += curr->object()->borderTop() + curr->object()->paddingTop() +
curr->object()->borderBottom() + curr->object()->paddingBottom();
newY -= curr->object()->borderTop() + curr->object()->paddingTop();
newBaseline += curr->object()->borderTop() + curr->object()->paddingTop();
}
} else {
newY += curr->object()->marginTop();
newHeight = curr->height() - (curr->object()->marginTop() + curr->object()->marginBottom());
overflowTop = curr->object()->overflowTop();
overflowBottom = curr->object()->overflowHeight() - newHeight;
}
curr->setYPos(newY);
curr->setHeight(newHeight);
curr->setBaseline(newBaseline);
if (childAffectsTopBottomPos) {
topPosition = kMin(topPosition, newY + overflowTop);
bottomPosition = kMax(bottomPosition, newY + newHeight + overflowBottom);
}
}
if (isRootInlineBox()) {
const QFontMetrics &fm = object()->fontMetrics( m_firstLine );
#ifdef APPLE_CHANGES
setHeight(fm.ascent()+fm.descent());
setYPos(yPos() + baseline() - fm.ascent());
setBaseline(fm.ascent());
#else
if ( kAbs(fm.ascent() - baseline()) > fm.leading()/2 ) {
int ascent = fm.ascent()+fm.leading()/2;
setHeight(fm.lineSpacing());
setYPos(yPos() + baseline() - ascent);
setBaseline(ascent);
}
#endif
if (hasTextDescendant() || strictMode) {
if (yPos() < topPosition)
topPosition = yPos();
if (yPos() + height() > bottomPosition)
bottomPosition = yPos() + height();
}
}
}