本文整理汇总了C++中LayoutSize::height方法的典型用法代码示例。如果您正苦于以下问题:C++ LayoutSize::height方法的具体用法?C++ LayoutSize::height怎么用?C++ LayoutSize::height使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LayoutSize
的用法示例。
在下文中一共展示了LayoutSize::height方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: translateTransform
void TransformState::translateTransform(const LayoutSize& offset)
{
if (m_direction == ApplyTransformDirection)
m_accumulatedTransform->translateRight(offset.width(), offset.height());
else
m_accumulatedTransform->translate(offset.width(), offset.height());
}
示例2: 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;
}
}
示例3: 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);
}
示例4: 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;
}
}
示例5: imageSizeForLayoutObject
LayoutSize ImageResource::imageSizeForLayoutObject(const LayoutObject* layoutObject, float multiplier, SizeType sizeType)
{
ASSERT(!isPurgeable());
if (!m_image)
return LayoutSize();
LayoutSize imageSize;
if (m_image->isBitmapImage() && (layoutObject && layoutObject->shouldRespectImageOrientation() == RespectImageOrientation))
imageSize = LayoutSize(toBitmapImage(m_image.get())->sizeRespectingOrientation());
else if (m_image->isSVGImage() && sizeType == NormalSize)
imageSize = LayoutSize(svgImageSizeForLayoutObject(layoutObject));
else
imageSize = LayoutSize(m_image->size());
if (multiplier == 1.0f)
return imageSize;
// Don't let images that have a width/height >= 1 shrink below 1 when zoomed.
float widthScale = m_image->hasRelativeWidth() ? 1.0f : multiplier;
float heightScale = m_image->hasRelativeHeight() ? 1.0f : multiplier;
LayoutSize minimumSize(imageSize.width() > 0 ? 1 : 0, imageSize.height() > 0 ? 1 : 0);
imageSize.scale(widthScale, heightScale);
imageSize.clampToMinimumSize(minimumSize);
ASSERT(multiplier != 1.0f || (imageSize.width().fraction() == 0.0f && imageSize.height().fraction() == 0.0f));
return imageSize;
}
示例6: imageSizeForRenderer
LayoutSize CachedImage::imageSizeForRenderer(const RenderObject* renderer, float multiplier, SizeType sizeType)
{
if (!m_image)
return LayoutSize();
LayoutSize imageSize;
if (is<BitmapImage>(*m_image) && renderer && renderer->shouldRespectImageOrientation() == RespectImageOrientation)
imageSize = LayoutSize(downcast<BitmapImage>(*m_image).sizeRespectingOrientation());
else if (is<SVGImage>(*m_image) && sizeType == UsedSize)
imageSize = LayoutSize(m_svgImageCache->imageSizeForRenderer(renderer));
else
imageSize = LayoutSize(m_image->size());
if (multiplier == 1.0f)
return imageSize;
// Don't let images that have a width/height >= 1 shrink below 1 when zoomed.
float widthScale = m_image->hasRelativeWidth() ? 1.0f : multiplier;
float heightScale = m_image->hasRelativeHeight() ? 1.0f : multiplier;
LayoutSize minimumSize(imageSize.width() > 0 ? 1 : 0, imageSize.height() > 0 ? 1 : 0);
imageSize.scale(widthScale, heightScale);
imageSize.clampToMinimumSize(minimumSize);
ASSERT(multiplier != 1.0f || (imageSize.width().fraction() == 0.0f && imageSize.height().fraction() == 0.0f));
return imageSize;
}
示例7: constrainedBetween
LayoutSize LayoutSize::constrainedBetween(const LayoutSize& min, const LayoutSize& max) const
{
return {
std::max(min.width(), std::min(max.width(), m_width)),
std::max(min.height(), std::min(max.height(), m_height))
};
}
示例8: computeSlices
LayoutBoxExtent NinePieceImage::computeSlices(const LayoutSize& size, const LengthBox& lengths, int scaleFactor)
{
LayoutUnit top = std::min<LayoutUnit>(size.height(), valueForLength(lengths.top(), size.height())) * scaleFactor;
LayoutUnit right = std::min<LayoutUnit>(size.width(), valueForLength(lengths.right(), size.width())) * scaleFactor;
LayoutUnit bottom = std::min<LayoutUnit>(size.height(), valueForLength(lengths.bottom(), size.height())) * scaleFactor;
LayoutUnit left = std::min<LayoutUnit>(size.width(), valueForLength(lengths.left(), size.width())) * scaleFactor;
return LayoutBoxExtent(top, right, bottom, left);
}
示例9: rect
PassOwnPtr<Shape> Shape::createShape(const LayoutSize& logicalSize, const LayoutSize& logicalRadii, WritingMode writingMode, Length margin, Length padding)
{
FloatRect rect(0, 0, logicalSize.width(), logicalSize.height());
FloatSize radii(logicalRadii.width(), logicalRadii.height());
FloatRoundedRect bounds(rect, radii, radii, radii, radii);
OwnPtr<Shape> shape = createBoxShape(bounds);
shape->m_writingMode = writingMode;
shape->m_margin = floatValueForLength(margin, 0);
shape->m_padding = floatValueForLength(padding, 0);
return shape.release();
}
示例10: imageFitsInWindow
bool ImageDocument::imageFitsInWindow()
{
if (!m_imageElement)
return true;
FrameView* view = this->view();
if (!view)
return true;
LayoutSize imageSize = this->imageSize();
LayoutSize windowSize = LayoutSize(view->width(), view->height());
return imageSize.width() <= windowSize.width() && imageSize.height() <= windowSize.height();
}
示例11: listIndexAtOffset
int RenderListBox::listIndexAtOffset(const LayoutSize& offset)
{
if (!numItems())
return -1;
if (offset.height() < borderTop() + paddingTop() || offset.height() > height() - paddingBottom() - borderBottom())
return -1;
LayoutUnit scrollbarWidth = m_vBar ? m_vBar->width() : LayoutUnit(0);
if (offset.width() < borderLeft() + paddingLeft() || offset.width() > width() - borderRight() - paddingRight() - scrollbarWidth)
return -1;
int newOffset = (offset.height() - borderTop() - paddingTop()) / itemHeight() + m_indexOffset;
return newOffset < numItems() ? newOffset : -1;
}
示例12: paintReplaced
void RenderHTMLCanvas::paintReplaced(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
{
GraphicsContext* context = paintInfo.context;
LayoutRect contentRect = contentBoxRect();
contentRect.moveBy(paintOffset);
LayoutRect paintRect = replacedContentRect();
paintRect.moveBy(paintOffset);
bool clip = !contentRect.contains(paintRect);
if (clip) {
// Not allowed to overflow the content box.
paintInfo.context->save();
paintInfo.context->clip(pixelSnappedIntRect(contentRect));
}
// FIXME: InterpolationNone should be used if ImageRenderingOptimizeContrast is set.
// See bug for more details: crbug.com/353716.
InterpolationQuality interpolationQuality = style()->imageRendering() == ImageRenderingOptimizeContrast ? InterpolationLow : CanvasDefaultInterpolationQuality;
HTMLCanvasElement* canvas = toHTMLCanvasElement(node());
LayoutSize layoutSize = contentRect.size();
if (style()->imageRendering() == ImageRenderingPixelated
&& (layoutSize.width() > canvas->width() || layoutSize.height() > canvas->height() || layoutSize == canvas->size())) {
interpolationQuality = InterpolationNone;
}
InterpolationQuality previousInterpolationQuality = context->imageInterpolationQuality();
context->setImageInterpolationQuality(interpolationQuality);
canvas->paint(context, paintRect);
context->setImageInterpolationQuality(previousInterpolationQuality);
if (clip)
context->restore();
}
示例13: mapAbsoluteToLocalPoint
void RenderMultiColumnFlowThread::mapAbsoluteToLocalPoint(MapCoordinatesFlags mode, TransformState& transformState) const
{
// First get the transform state's point into the block flow thread's physical coordinate space.
parent()->mapAbsoluteToLocalPoint(mode, transformState);
LayoutPoint transformPoint = roundedLayoutPoint(transformState.mappedPoint());
// Now walk through each region.
const RenderMultiColumnSet* candidateColumnSet = nullptr;
LayoutPoint candidatePoint;
LayoutSize candidateContainerOffset;
for (const auto& columnSet : childrenOfType<RenderMultiColumnSet>(*parent())) {
candidateContainerOffset = columnSet.offsetFromContainer(parent(), LayoutPoint());
candidatePoint = transformPoint - candidateContainerOffset;
candidateColumnSet = &columnSet;
// We really have no clue what to do with overflow. We'll just use the closest region to the point in that case.
LayoutUnit pointOffset = isHorizontalWritingMode() ? candidatePoint.y() : candidatePoint.x();
LayoutUnit regionOffset = isHorizontalWritingMode() ? columnSet.topLeftLocation().y() : columnSet.topLeftLocation().x();
if (pointOffset < regionOffset + columnSet.logicalHeight())
break;
}
// Once we have a good guess as to which region we hit tested through (and yes, this was just a heuristic, but it's
// the best we could do), then we can map from the region into the flow thread.
LayoutSize translationOffset = physicalTranslationFromRegionToFlow(candidateColumnSet, candidatePoint) + candidateContainerOffset;
bool preserve3D = mode & UseTransforms && (parent()->style().preserves3D() || style().preserves3D());
if (mode & UseTransforms && shouldUseTransformFromContainer(parent())) {
TransformationMatrix t;
getTransformFromContainer(parent(), translationOffset, t);
transformState.applyTransform(t, preserve3D ? TransformState::AccumulateTransform : TransformState::FlattenTransform);
} else
transformState.move(translationOffset.width(), translationOffset.height(), preserve3D ? TransformState::AccumulateTransform : TransformState::FlattenTransform);
}
示例14: paintRectForImageStrip
LayoutRect InlineFlowBoxPainter::paintRectForImageStrip(const LayoutPoint& paintOffset, const LayoutSize& frameSize, TextDirection direction) const
{
// We have a fill/border/mask image that spans multiple lines.
// We need to adjust the offset by the width of all previous lines.
// Think of background painting on inlines as though you had one long line, a single continuous
// strip. Even though that strip has been broken up across multiple lines, you still paint it
// as though you had one single line. This means each line has to pick up the background where
// the previous line left off.
LayoutUnit logicalOffsetOnLine = 0;
LayoutUnit totalLogicalWidth;
if (direction == LTR) {
for (const InlineFlowBox* curr = m_inlineFlowBox.prevLineBox(); curr; curr = curr->prevLineBox())
logicalOffsetOnLine += curr->logicalWidth();
totalLogicalWidth = logicalOffsetOnLine;
for (const InlineFlowBox* curr = &m_inlineFlowBox; curr; curr = curr->nextLineBox())
totalLogicalWidth += curr->logicalWidth();
} else {
for (const InlineFlowBox* curr = m_inlineFlowBox.nextLineBox(); curr; curr = curr->nextLineBox())
logicalOffsetOnLine += curr->logicalWidth();
totalLogicalWidth = logicalOffsetOnLine;
for (const InlineFlowBox* curr = &m_inlineFlowBox; curr; curr = curr->prevLineBox())
totalLogicalWidth += curr->logicalWidth();
}
LayoutUnit stripX = paintOffset.x() - (m_inlineFlowBox.isHorizontal() ? logicalOffsetOnLine : LayoutUnit());
LayoutUnit stripY = paintOffset.y() - (m_inlineFlowBox.isHorizontal() ? LayoutUnit() : logicalOffsetOnLine);
LayoutUnit stripWidth = m_inlineFlowBox.isHorizontal() ? totalLogicalWidth : frameSize.width();
LayoutUnit stripHeight = m_inlineFlowBox.isHorizontal() ? frameSize.height() : totalLogicalWidth;
return LayoutRect(stripX, stripY, stripWidth, stripHeight);
}
示例15: layout
void RenderReplaced::layout()
{
StackStats::LayoutCheckPoint layoutCheckPoint;
ASSERT(needsLayout());
LayoutRepainter repainter(*this, checkForRepaintDuringLayout());
setHeight(minimumReplacedHeight());
updateLogicalWidth();
updateLogicalHeight();
// Now that we've calculated our preferred layout, we check to see
// if we should further constrain sizing to the intrinsic aspect ratio.
if (style().aspectRatioType() == AspectRatioFromIntrinsic && !m_intrinsicSize.isEmpty()) {
float aspectRatio = m_intrinsicSize.aspectRatio();
LayoutSize frameSize = size();
float frameAspectRatio = frameSize.aspectRatio();
if (frameAspectRatio < aspectRatio)
setHeight(computeReplacedLogicalHeightRespectingMinMaxHeight(frameSize.height() * frameAspectRatio / aspectRatio));
else if (frameAspectRatio > aspectRatio)
setWidth(computeReplacedLogicalWidthRespectingMinMaxWidth(frameSize.width() * aspectRatio / frameAspectRatio, ComputePreferred));
}
clearOverflow();
addVisualEffectOverflow();
updateLayerTransform();
invalidateBackgroundObscurationStatus();
repainter.repaintAfterLayout();
clearNeedsLayout();
}