当前位置: 首页>>代码示例>>C++>>正文


C++ RenderBoxModelObject::layout方法代码示例

本文整理汇总了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();
}
开发者ID:xiaolu31,项目名称:webkit-node,代码行数:57,代码来源:RenderMathMLRoot.cpp

示例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();
}
开发者ID:0omega,项目名称:platform_external_webkit,代码行数:56,代码来源:RenderMathMLRoot.cpp


注:本文中的RenderBoxModelObject::layout方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。