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


C++ LayoutBox::borderBoxRect方法代码示例

本文整理汇总了C++中LayoutBox::borderBoxRect方法的典型用法代码示例。如果您正苦于以下问题:C++ LayoutBox::borderBoxRect方法的具体用法?C++ LayoutBox::borderBoxRect怎么用?C++ LayoutBox::borderBoxRect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在LayoutBox的用法示例。


在下文中一共展示了LayoutBox::borderBoxRect方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: buildNodeQuads

bool InspectorHighlight::buildNodeQuads(Node* node, FloatQuad* content, FloatQuad* padding, FloatQuad* border, FloatQuad* margin)
{
    LayoutObject* layoutObject = node->layoutObject();
    if (!layoutObject)
        return false;

    FrameView* containingView = layoutObject->frameView();
    if (!containingView)
        return false;
    if (!layoutObject->isBox() && !layoutObject->isLayoutInline())
        return false;

    LayoutRect contentBox;
    LayoutRect paddingBox;
    LayoutRect borderBox;
    LayoutRect marginBox;

    if (layoutObject->isBox()) {
        LayoutBox* layoutBox = toLayoutBox(layoutObject);

        // LayoutBox returns the "pure" content area box, exclusive of the scrollbars (if present), which also count towards the content area in CSS.
        const int verticalScrollbarWidth = layoutBox->verticalScrollbarWidth();
        const int horizontalScrollbarHeight = layoutBox->horizontalScrollbarHeight();
        contentBox = layoutBox->contentBoxRect();
        contentBox.setWidth(contentBox.width() + verticalScrollbarWidth);
        contentBox.setHeight(contentBox.height() + horizontalScrollbarHeight);

        paddingBox = layoutBox->paddingBoxRect();
        paddingBox.setWidth(paddingBox.width() + verticalScrollbarWidth);
        paddingBox.setHeight(paddingBox.height() + horizontalScrollbarHeight);

        borderBox = layoutBox->borderBoxRect();

        marginBox = LayoutRect(borderBox.x() - layoutBox->marginLeft(), borderBox.y() - layoutBox->marginTop(),
            borderBox.width() + layoutBox->marginWidth(), borderBox.height() + layoutBox->marginHeight());
    } else {
        LayoutInline* layoutInline = toLayoutInline(layoutObject);

        // LayoutInline's bounding box includes paddings and borders, excludes margins.
        borderBox = LayoutRect(layoutInline->linesBoundingBox());
        paddingBox = LayoutRect(borderBox.x() + layoutInline->borderLeft(), borderBox.y() + layoutInline->borderTop(),
            borderBox.width() - layoutInline->borderLeft() - layoutInline->borderRight(), borderBox.height() - layoutInline->borderTop() - layoutInline->borderBottom());
        contentBox = LayoutRect(paddingBox.x() + layoutInline->paddingLeft(), paddingBox.y() + layoutInline->paddingTop(),
            paddingBox.width() - layoutInline->paddingLeft() - layoutInline->paddingRight(), paddingBox.height() - layoutInline->paddingTop() - layoutInline->paddingBottom());
        // Ignore marginTop and marginBottom for inlines.
        marginBox = LayoutRect(borderBox.x() - layoutInline->marginLeft(), borderBox.y(),
            borderBox.width() + layoutInline->marginWidth(), borderBox.height());
    }

    *content = layoutObject->localToAbsoluteQuad(FloatRect(contentBox));
    *padding = layoutObject->localToAbsoluteQuad(FloatRect(paddingBox));
    *border = layoutObject->localToAbsoluteQuad(FloatRect(borderBox));
    *margin = layoutObject->localToAbsoluteQuad(FloatRect(marginBox));

    contentsQuadToViewport(containingView, *content);
    contentsQuadToViewport(containingView, *padding);
    contentsQuadToViewport(containingView, *border);
    contentsQuadToViewport(containingView, *margin);

    return true;
}
开发者ID:howardroark2018,项目名称:chromium,代码行数:61,代码来源:InspectorHighlight.cpp


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