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


C++ LayoutRect::height方法代码示例

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


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

示例1: clipRectForNinePieceImageStrip

static LayoutRect clipRectForNinePieceImageStrip(const InlineFlowBox& box, const NinePieceImage& image, const LayoutRect& paintRect)
{
    LayoutRect clipRect(paintRect);
    const ComputedStyle& style = box.lineLayoutItem().styleRef();
    LayoutRectOutsets outsets = style.imageOutsets(image);
    if (box.isHorizontal()) {
        clipRect.setY(paintRect.y() - outsets.top());
        clipRect.setHeight(paintRect.height() + outsets.top() + outsets.bottom());
        if (box.includeLogicalLeftEdge()) {
            clipRect.setX(paintRect.x() - outsets.left());
            clipRect.setWidth(paintRect.width() + outsets.left());
        }
        if (box.includeLogicalRightEdge())
            clipRect.setWidth(clipRect.width() + outsets.right());
    } else {
        clipRect.setX(paintRect.x() - outsets.left());
        clipRect.setWidth(paintRect.width() + outsets.left() + outsets.right());
        if (box.includeLogicalLeftEdge()) {
            clipRect.setY(paintRect.y() - outsets.top());
            clipRect.setHeight(paintRect.height() + outsets.top());
        }
        if (box.includeLogicalRightEdge())
            clipRect.setHeight(clipRect.height() + outsets.bottom());
    }
    return clipRect;
}
开发者ID:mtucker6784,项目名称:chromium,代码行数:26,代码来源:InlineFlowBoxPainter.cpp

示例2: videoBox

IntRect RenderVideo::videoBox() const
{
    if (m_cachedImageSize.isEmpty() && videoElement()->shouldDisplayPosterImage())
        return IntRect();

    LayoutSize elementSize;
    if (videoElement()->shouldDisplayPosterImage())
        elementSize = m_cachedImageSize;
    else
        elementSize = intrinsicSize();

    IntRect contentRect = pixelSnappedIntRect(contentBoxRect());
    if (elementSize.isEmpty() || contentRect.isEmpty())
        return IntRect();

    LayoutRect renderBox = contentRect;
    LayoutUnit ratio = renderBox.width() * elementSize.height() - renderBox.height() * elementSize.width();
    if (ratio > 0) {
        LayoutUnit newWidth = renderBox.height() * elementSize.width() / elementSize.height();
        // Just fill the whole area if the difference is one pixel or less (in both sides)
        if (renderBox.width() - newWidth > 2)
            renderBox.setWidth(newWidth);
        renderBox.move((contentRect.width() - renderBox.width()) / 2, 0);
    } else if (ratio < 0) {
        LayoutUnit newHeight = renderBox.width() * elementSize.height() / elementSize.width();
        if (renderBox.height() - newHeight > 2)
            renderBox.setHeight(newHeight);
        renderBox.move(0, (contentRect.height() - renderBox.height()) / 2);
    }

    return pixelSnappedIntRect(renderBox);
}
开发者ID:kcomkar,项目名称:webkit,代码行数:32,代码来源:RenderVideo.cpp

示例3: replacedContentRect

LayoutRect RenderReplaced::replacedContentRect(const LayoutSize& intrinsicSize) const
{
    LayoutRect contentRect = contentBoxRect();
    ObjectFit objectFit = style().objectFit();
    if (objectFit == ObjectFitFill)
        return contentRect;

    if (!intrinsicSize.width() || !intrinsicSize.height())
        return contentRect;

    LayoutRect finalRect = contentRect;
    switch (objectFit) {
    case ObjectFitContain:
    case ObjectFitScaleDown:
    case ObjectFitCover:
        finalRect.setSize(finalRect.size().fitToAspectRatio(intrinsicSize, objectFit == ObjectFitCover ? AspectRatioFitGrow : AspectRatioFitShrink));
        if (objectFit != ObjectFitScaleDown || finalRect.width() <= intrinsicSize.width())
            break;
        // fall through
    case ObjectFitNone:
        finalRect.setSize(intrinsicSize);
        break;
    case ObjectFitFill:
        ASSERT_NOT_REACHED();
    }

    // FIXME: This is where object-position should be taken into account, but since it's not
    // implemented yet, assume the initial value of "50% 50%".
    LayoutUnit xOffset = (contentRect.width() - finalRect.width()) / 2;
    LayoutUnit yOffset = (contentRect.height() - finalRect.height()) / 2;
    finalRect.move(xOffset, yOffset);

    return finalRect;
}
开发者ID:ZeusbaseWeb,项目名称:webkit,代码行数:34,代码来源:RenderReplaced.cpp

示例4: resizeSourceDimensions

void MediaPlayerPrivate::resizeSourceDimensions()
{
    if (!m_webCorePlayer)
        return;

    if (!m_webCorePlayer->mediaPlayerClient()->mediaPlayerIsVideo())
        return;

    // If we have an HTMLVideoElement but the source has no video, then we need to resize the media element.
    if (!hasVideo() && PlatformPlayer::MediaOK == m_platformPlayer->error()) {
        LayoutRect rect = m_webCorePlayer->mediaPlayerClient()->mediaPlayerContentBoxRect();

        static const int playbookMinAudioElementWidth = 300;
        static const int playbookMinAudioElementHeight = 32;
        // If the rect dimensions are less than the allowed minimum, use the minimum instead.
        int newWidth = max(rect.width().toInt(), playbookMinAudioElementWidth);
        int newHeight = max(rect.height().toInt(), playbookMinAudioElementHeight);

        m_webCorePlayer->mediaPlayerClient()->mediaPlayerSetSize(IntSize(newWidth, newHeight));
    }

    // If we don't know what the width and height of the video source is, then we need to set it to something sane.
    if (m_platformPlayer->sourceWidth() && m_platformPlayer->sourceHeight())
        return;
    LayoutRect rect = m_webCorePlayer->mediaPlayerClient()->mediaPlayerContentBoxRect();
    m_platformPlayer->setSourceDimension(rect.width().toUnsigned(), rect.height().toUnsigned());
}
开发者ID:kcomkar,项目名称:webkit,代码行数:27,代码来源:MediaPlayerPrivateBlackBerry.cpp

示例5: inflateWithRadii

void RoundedRect::inflateWithRadii(const LayoutUnit& size)
{
    LayoutRect old = m_rect;

    m_rect.inflate(size);
    // Considering the inflation factor of shorter size to scale the radii seems appropriate here
    float factor;
    if (m_rect.width() < m_rect.height())
        factor = old.width() ? (float)m_rect.width() / old.width() : int(0);
    else
        factor = old.height() ? (float)m_rect.height() / old.height() : int(0);

    m_radii.scale(factor);
}
开发者ID:boska,项目名称:webkit,代码行数:14,代码来源:RoundedRect.cpp

示例6: applyRootMargin

void IntersectionObserver::applyRootMargin(LayoutRect& rect) const
{
    // TODO(szager): Make sure the spec is clear that left/right margins are resolved against
    // width and not height.
    LayoutUnit topMargin = computeMargin(m_topMargin, rect.height());
    LayoutUnit rightMargin = computeMargin(m_rightMargin, rect.width());
    LayoutUnit bottomMargin = computeMargin(m_bottomMargin, rect.height());
    LayoutUnit leftMargin = computeMargin(m_leftMargin, rect.width());

    rect.setX(rect.x() - leftMargin);
    rect.setWidth(rect.width() + leftMargin + rightMargin);
    rect.setY(rect.y() - topMargin);
    rect.setHeight(rect.height() + topMargin + bottomMargin);
}
开发者ID:astojilj,项目名称:chromium-crosswalk,代码行数:14,代码来源:IntersectionObserver.cpp

示例7: deflateIfOverlapped

static void deflateIfOverlapped(LayoutRect& a, LayoutRect& b)
{
    if (!a.intersects(b) || a.contains(b) || b.contains(a))
        return;

    LayoutUnit deflateFactor = -fudgeFactor();

    // Avoid negative width or height values.
    if ((a.width() + 2 * deflateFactor > 0) && (a.height() + 2 * deflateFactor > 0))
        a.inflate(deflateFactor);

    if ((b.width() + 2 * deflateFactor > 0) && (b.height() + 2 * deflateFactor > 0))
        b.inflate(deflateFactor);
}
开发者ID:venkatarajasekhar,项目名称:Qt,代码行数:14,代码来源:SpatialNavigation.cpp

示例8: computeObjectFit

LayoutRect LayoutReplaced::computeObjectFit(
    const LayoutSize* overriddenIntrinsicSize) const {
    LayoutRect contentRect = contentBoxRect();
    ObjectFit objectFit = style()->getObjectFit();

    if (objectFit == ObjectFitFill &&
            style()->objectPosition() == ComputedStyle::initialObjectPosition()) {
        return contentRect;
    }

    // TODO(davve): intrinsicSize doubles as both intrinsic size and intrinsic
    // ratio. In the case of SVG images this isn't correct since they can have
    // intrinsic ratio but no intrinsic size. In order to maintain aspect ratio,
    // the intrinsic size for SVG might be faked from the aspect ratio,
    // see SVGImage::containerSize().
    LayoutSize intrinsicSize = overriddenIntrinsicSize ? *overriddenIntrinsicSize
                               : this->intrinsicSize();
    if (!intrinsicSize.width() || !intrinsicSize.height())
        return contentRect;

    LayoutRect finalRect = contentRect;
    switch (objectFit) {
    case ObjectFitContain:
    case ObjectFitScaleDown:
    case ObjectFitCover:
        finalRect.setSize(finalRect.size().fitToAspectRatio(
                              intrinsicSize, objectFit == ObjectFitCover ? AspectRatioFitGrow
                              : AspectRatioFitShrink));
        if (objectFit != ObjectFitScaleDown ||
                finalRect.width() <= intrinsicSize.width())
            break;
    // fall through
    case ObjectFitNone:
        finalRect.setSize(intrinsicSize);
        break;
    case ObjectFitFill:
        break;
    default:
        ASSERT_NOT_REACHED();
    }

    LayoutUnit xOffset = minimumValueForLength(
                             style()->objectPosition().x(), contentRect.width() - finalRect.width());
    LayoutUnit yOffset = minimumValueForLength(
                             style()->objectPosition().y(), contentRect.height() - finalRect.height());
    finalRect.move(xOffset, yOffset);

    return finalRect;
}
开发者ID:mirror,项目名称:chromium,代码行数:49,代码来源:LayoutReplaced.cpp

示例9: paintIntoRect

void RenderImage::paintIntoRect(GraphicsContext* context, const LayoutRect& rect)
{
    if (!m_imageResource->hasImage() || m_imageResource->errorOccurred() || rect.width() <= 0 || rect.height() <= 0)
        return;

    RefPtr<Image> img = m_imageResource->image(rect.width(), rect.height());
    if (!img || img->isNull())
        return;

    HTMLImageElement* imageElt = (node() && node()->hasTagName(imgTag)) ? static_cast<HTMLImageElement*>(node()) : 0;
    CompositeOperator compositeOperator = imageElt ? imageElt->compositeOperator() : CompositeSourceOver;
    Image* image = m_imageResource->image().get();
    bool useLowQualityScaling = shouldPaintAtLowQuality(context, image, image, rect.size());
    context->drawImage(m_imageResource->image(rect.width(), rect.height()).get(), style()->colorSpace(), rect, compositeOperator, useLowQualityScaling);
}
开发者ID:CannedFish,项目名称:deepin-webkit,代码行数:15,代码来源:RenderImage.cpp

示例10: elementRect

LayoutRect AccessibilitySpinButtonPart::elementRect() const
{
    // FIXME: This logic should exist in the render tree or elsewhere, but there is no
    // relationship that exists that can be queried.
    
    LayoutRect parentRect = parentObject()->elementRect();
    if (m_isIncrementor)
        parentRect.setHeight(parentRect.height() / 2);
    else {
        parentRect.setY(parentRect.y() + parentRect.height() / 2);        
        parentRect.setHeight(parentRect.height() / 2);        
    }
        
    return parentRect;
}
开发者ID:AndriyKalashnykov,项目名称:webkit,代码行数:15,代码来源:AccessibilitySpinButton.cpp

示例11: addRectData

void TimelineRecordFactory::addRectData(InspectorObject* data, const LayoutRect& rect)
{
    data->setNumber("x", rect.x());
    data->setNumber("y", rect.y());
    data->setNumber("width", rect.width());
    data->setNumber("height", rect.height());
}
开发者ID:jbat100,项目名称:webkit,代码行数:7,代码来源:TimelineRecordFactory.cpp

示例12: canScrollInDirection

bool canScrollInDirection(const Frame* frame, FocusDirection direction)
{
    if (!frame->view())
        return false;
    ScrollbarMode verticalMode;
    ScrollbarMode horizontalMode;
    frame->view()->calculateScrollbarModesForLayout(horizontalMode, verticalMode);
    if ((direction == FocusDirectionLeft || direction == FocusDirectionRight) && ScrollbarAlwaysOff == horizontalMode)
        return false;
    if ((direction == FocusDirectionUp || direction == FocusDirectionDown) &&  ScrollbarAlwaysOff == verticalMode)
        return false;
    LayoutSize size = frame->view()->totalContentsSize();
    LayoutSize offset = frame->view()->scrollOffset();
    LayoutRect rect = frame->view()->visibleContentRectIncludingScrollbars();

    switch (direction) {
    case FocusDirectionLeft:
        return offset.width() > 0;
    case FocusDirectionUp:
        return offset.height() > 0;
    case FocusDirectionRight:
        return rect.width() + offset.width() < size.width();
    case FocusDirectionDown:
        return rect.height() + offset.height() < size.height();
    default:
        ASSERT_NOT_REACHED();
        return false;
    }
}
开发者ID:CannedFish,项目名称:webkitgtk,代码行数:29,代码来源:SpatialNavigation.cpp

示例13: regionAtBlockOffset

RenderRegion* RenderFlowThread::regionAtBlockOffset(LayoutUnit offset, bool extendLastRegion) const
{
    ASSERT(!m_regionsInvalidated);

    // If no region matches the position and extendLastRegion is true, it will return
    // the last valid region. It is similar to auto extending the size of the last region. 
    RenderRegion* lastValidRegion = 0;

    LayoutUnit accumulatedLogicalHeight = 0;
    
    // FIXME: The regions are always in order, optimize this search.
    for (RenderRegionList::const_iterator iter = m_regionList.begin(); iter != m_regionList.end(); ++iter) {
        RenderRegion* region = *iter;

        if (offset <= 0)
            return region;

        if (extendLastRegion || region->isRenderRegionSet())
            lastValidRegion = region;

        if (region->hasOverrideHeight() && view()->normalLayoutPhase()) {
            accumulatedLogicalHeight += region->overrideLogicalContentHeight();
            if (offset < accumulatedLogicalHeight)
                return region;
            continue;
        }

        LayoutRect regionRect = region->flowThreadPortionRect();
        accumulatedLogicalHeight += isHorizontalWritingMode() ? regionRect.height() : regionRect.width();
        if (offset < accumulatedLogicalHeight)
            return region;
    }

    return lastValidRegion;
}
开发者ID:rgabor-dev,项目名称:webkitnix,代码行数:35,代码来源:RenderFlowThread.cpp

示例14: visualPointToFlowThreadPoint

LayoutPoint MultiColumnFragmentainerGroup::visualPointToFlowThreadPoint(
    const LayoutPoint& visualPoint) const {
  unsigned columnIndex = columnIndexAtVisualPoint(visualPoint);
  LayoutRect columnRect = columnRectAt(columnIndex);
  LayoutPoint localPoint(visualPoint);
  localPoint.moveBy(-columnRect.location());
  // Before converting to a flow thread position, if the block direction
  // coordinate is outside the column, snap to the bounds of the column, and
  // reset the inline direction coordinate to the start position in the column.
  // The effect of this is that if the block position is before the column
  // rectangle, we'll get to the beginning of this column, while if the block
  // position is after the column rectangle, we'll get to the beginning of the
  // next column.
  if (!m_columnSet.isHorizontalWritingMode()) {
    LayoutUnit columnStart = m_columnSet.style()->isLeftToRightDirection()
                                 ? LayoutUnit()
                                 : columnRect.height();
    if (localPoint.x() < 0)
      localPoint = LayoutPoint(LayoutUnit(), columnStart);
    else if (localPoint.x() > logicalHeight())
      localPoint = LayoutPoint(logicalHeight(), columnStart);
    return LayoutPoint(localPoint.x() + logicalTopInFlowThreadAt(columnIndex),
                       localPoint.y());
  }
  LayoutUnit columnStart = m_columnSet.style()->isLeftToRightDirection()
                               ? LayoutUnit()
                               : columnRect.width();
  if (localPoint.y() < 0)
    localPoint = LayoutPoint(columnStart, LayoutUnit());
  else if (localPoint.y() > logicalHeight())
    localPoint = LayoutPoint(columnStart, logicalHeight());
  return LayoutPoint(localPoint.x(),
                     localPoint.y() + logicalTopInFlowThreadAt(columnIndex));
}
开发者ID:mirror,项目名称:chromium,代码行数:34,代码来源:MultiColumnFragmentainerGroup.cpp

示例15: canScrollInDirection

bool canScrollInDirection(const LocalFrame* frame, FocusType type)
{
    if (!frame->view())
        return false;
    ScrollbarMode verticalMode;
    ScrollbarMode horizontalMode;
    frame->view()->calculateScrollbarModesForLayoutAndSetViewportRenderer(horizontalMode, verticalMode);
    if ((type == FocusTypeLeft || type == FocusTypeRight) && ScrollbarAlwaysOff == horizontalMode)
        return false;
    if ((type == FocusTypeUp || type == FocusTypeDown) &&  ScrollbarAlwaysOff == verticalMode)
        return false;
    LayoutSize size = frame->view()->contentsSize();
    LayoutSize offset = frame->view()->scrollOffset();
    LayoutRect rect = frame->view()->visibleContentRect(IncludeScrollbars);

    switch (type) {
    case FocusTypeLeft:
        return offset.width() > 0;
    case FocusTypeUp:
        return offset.height() > 0;
    case FocusTypeRight:
        return rect.width() + offset.width() < size.width();
    case FocusTypeDown:
        return rect.height() + offset.height() < size.height();
    default:
        ASSERT_NOT_REACHED();
        return false;
    }
}
开发者ID:venkatarajasekhar,项目名称:Qt,代码行数:29,代码来源:SpatialNavigation.cpp


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