本文整理汇总了C++中LayoutBlock::style方法的典型用法代码示例。如果您正苦于以下问题:C++ LayoutBlock::style方法的具体用法?C++ LayoutBlock::style怎么用?C++ LayoutBlock::style使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LayoutBlock
的用法示例。
在下文中一共展示了LayoutBlock::style方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: firstLineBoxBaseline
int LayoutTextControl::firstLineBoxBaseline() const {
int result = LayoutBlock::firstLineBoxBaseline();
if (result != -1)
return result;
// When the text is empty, |LayoutBlock::firstLineBoxBaseline()| cannot
// compute the baseline because lineboxes do not exist.
Element* innerEditor = innerEditorElement();
if (!innerEditor || !innerEditor->layoutObject())
return -1;
LayoutBlock* innerEditorLayoutObject =
toLayoutBlock(innerEditor->layoutObject());
const SimpleFontData* fontData =
innerEditorLayoutObject->style(true)->font().primaryFont();
DCHECK(fontData);
if (!fontData)
return -1;
LayoutUnit baseline(fontData->getFontMetrics().ascent(AlphabeticBaseline));
for (LayoutObject* box = innerEditorLayoutObject; box && box != this;
box = box->parent()) {
if (box->isBox())
baseline += toLayoutBox(box)->logicalTop();
}
return baseline.toInt();
}
示例2: calculateColumnCountAndWidth
void LayoutMultiColumnFlowThread::calculateColumnCountAndWidth(LayoutUnit& width, unsigned& count) const
{
LayoutBlock* columnBlock = multiColumnBlockFlow();
const ComputedStyle* columnStyle = columnBlock->style();
LayoutUnit availableWidth = columnBlock->contentLogicalWidth();
LayoutUnit columnGap = columnBlock->columnGap();
LayoutUnit computedColumnWidth = max<LayoutUnit>(1, LayoutUnit(columnStyle->columnWidth()));
unsigned computedColumnCount = max<int>(1, columnStyle->columnCount());
ASSERT(!columnStyle->hasAutoColumnCount() || !columnStyle->hasAutoColumnWidth());
if (columnStyle->hasAutoColumnWidth() && !columnStyle->hasAutoColumnCount()) {
count = computedColumnCount;
width = std::max<LayoutUnit>(0, (availableWidth - ((count - 1) * columnGap)) / count);
} else if (!columnStyle->hasAutoColumnWidth() && columnStyle->hasAutoColumnCount()) {
count = std::max<LayoutUnit>(1, (availableWidth + columnGap) / (computedColumnWidth + columnGap));
width = ((availableWidth + columnGap) / count) - columnGap;
} else {
count = std::max<LayoutUnit>(std::min<LayoutUnit>(computedColumnCount, (availableWidth + columnGap) / (computedColumnWidth + columnGap)), 1);
width = ((availableWidth + columnGap) / count) - columnGap;
}
}