本文整理汇总了C++中RenderBoxModelObject::style方法的典型用法代码示例。如果您正苦于以下问题:C++ RenderBoxModelObject::style方法的具体用法?C++ RenderBoxModelObject::style怎么用?C++ RenderBoxModelObject::style使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RenderBoxModelObject
的用法示例。
在下文中一共展示了RenderBoxModelObject::style方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: layout
void RenderMathMLSquareRoot::layout()
{
int maxHeight = 0;
RenderObject* current = firstChild();
while (current) {
if (current->isBoxModelObject()) {
RenderBoxModelObject* box = toRenderBoxModelObject(current);
if (box->pixelSnappedOffsetHeight() > maxHeight)
maxHeight = box->pixelSnappedOffsetHeight();
box->style()->setVerticalAlign(BASELINE);
}
current = current->nextSibling();
}
if (!maxHeight)
maxHeight = style()->fontSize();
if (maxHeight > static_cast<int>(gThresholdBaseHeight * style()->fontSize()))
style()->setPaddingBottom(Length(static_cast<int>(gRootBottomPadding * style()->fontSize()), Fixed));
RenderBlock::layout();
}
示例2: 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();
}
示例3: 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();
}
示例4: findRendererDefininingTextDecoration
static inline RenderBoxModelObject& findRendererDefininingTextDecoration(InlineFlowBox* parentBox)
{
// Lookup first render object in parent hierarchy which has text-decoration set.
RenderBoxModelObject* renderer = nullptr;
while (parentBox) {
renderer = &parentBox->renderer();
if (renderer->style()->textDecoration() != TextDecorationNone)
break;
parentBox = parentBox->parent();
}
ASSERT(renderer);
return *renderer;
}
示例5: paintDecorationWithStyle
void SVGInlineTextBox::paintDecorationWithStyle(GraphicsContext* context, TextDecoration decoration, const SVGTextFragment& fragment, RenderBoxModelObject& decorationRenderer)
{
ASSERT(!m_paintingResource);
ASSERT(m_paintingResourceMode != ApplyToDefaultMode);
RenderStyle* decorationStyle = decorationRenderer.style();
ASSERT(decorationStyle);
float scalingFactor = 1;
Font scaledFont;
RenderSVGInlineText::computeNewScaledFontForStyle(&decorationRenderer, decorationStyle, scalingFactor, scaledFont);
ASSERT(scalingFactor);
// The initial y value refers to overline position.
float thickness = thicknessForDecoration(decoration, scaledFont);
if (fragment.width <= 0 && thickness <= 0)
return;
FloatPoint decorationOrigin(fragment.x, fragment.y);
float width = fragment.width;
const FontMetrics& scaledFontMetrics = scaledFont.fontMetrics();
GraphicsContextStateSaver stateSaver(*context);
if (scalingFactor != 1) {
width *= scalingFactor;
decorationOrigin.scale(scalingFactor, scalingFactor);
context->scale(FloatSize(1 / scalingFactor, 1 / scalingFactor));
}
decorationOrigin.move(0, -scaledFontMetrics.floatAscent() + positionOffsetForDecoration(decoration, scaledFontMetrics, thickness));
Path path;
path.addRect(FloatRect(decorationOrigin, FloatSize(width, thickness)));
if (acquirePaintingResource(context, scalingFactor, decorationRenderer, decorationStyle))
releasePaintingResource(context, &path);
}
示例6: ascentAndDescentForBox
//.........这里部分代码省略.........
affectsAscent = glyphOverflow->top - box->logicalTop() > 0;
affectsDescent = glyphOverflow->bottom + box->logicalTop() > 0;
glyphOverflow->top = std::min(glyphOverflow->top, std::max(0, glyphOverflow->top - boxLineStyle.fontMetrics().ascent(baselineType())));
glyphOverflow->bottom = std::min(glyphOverflow->bottom, std::max(0, glyphOverflow->bottom - boxLineStyle.fontMetrics().descent(baselineType())));
}
if (includeMarginForBox(box)) {
LayoutUnit ascentWithMargin = boxLineStyle.fontMetrics().ascent(baselineType());
LayoutUnit descentWithMargin = boxLineStyle.fontMetrics().descent(baselineType());
if (box->parent() && !box->renderer().isTextOrLineBreak()) {
ascentWithMargin += box->boxModelObject()->borderAndPaddingBefore() + box->boxModelObject()->marginBefore();
descentWithMargin += box->boxModelObject()->borderAndPaddingAfter() + box->boxModelObject()->marginAfter();
}
setAscentAndDescent(ascent, descent, ascentWithMargin, descentWithMargin, ascentDescentSet);
// Treat like a replaced element, since we're using the margin box.
affectsAscent = true;
affectsDescent = true;
}
}
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)