本文整理汇总了C++中LayoutSize类的典型用法代码示例。如果您正苦于以下问题:C++ LayoutSize类的具体用法?C++ LayoutSize怎么用?C++ LayoutSize使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了LayoutSize类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: contentBoxRect
LayoutRect RenderReplaced::replacedContentRect(const LayoutSize* overriddenIntrinsicSize) const
{
LayoutRect contentRect = contentBoxRect();
ObjectFit objectFit = style()->objectFit();
if (objectFit == ObjectFitFill && style()->objectPosition() == RenderStyle::initialObjectPosition())
objectFit = ObjectFitContain;
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;
}
示例2: videoElement
LayoutSize RenderVideo::calculateIntrinsicSize()
{
// Spec text from 4.8.6
//
// The intrinsic width of a video element's playback area is the intrinsic width
// of the video resource, if that is available; otherwise it is the intrinsic
// width of the poster frame, if that is available; otherwise it is 300 CSS pixels.
//
// The intrinsic height of a video element's playback area is the intrinsic height
// of the video resource, if that is available; otherwise it is the intrinsic
// height of the poster frame, if that is available; otherwise it is 150 CSS pixels.
MediaPlayer* player = videoElement().player();
if (player && videoElement().readyState() >= HTMLVideoElement::HAVE_METADATA) {
LayoutSize size = player->naturalSize();
if (!size.isEmpty())
return size;
}
if (videoElement().shouldDisplayPosterImage() && !m_cachedImageSize.isEmpty() && !imageResource()->errorOccurred())
return m_cachedImageSize;
// When the natural size of the video is unavailable, we use the provided
// width and height attributes of the video element as the intrinsic size until
// better values become available.
if (videoElement().hasAttribute(widthAttr) && videoElement().hasAttribute(heightAttr))
return LayoutSize(videoElement().width(), videoElement().height());
// <video> in standalone media documents should not use the default 300x150
// size since they also have audio-only files. By setting the intrinsic
// size to 300x1 the video will resize itself in these cases, and audio will
// have the correct height (it needs to be > 0 for controls to render properly).
if (videoElement().document().isMediaDocument())
return LayoutSize(defaultSize().width(), 1);
return defaultSize();
}
示例3: flowThreadContainingBlock
void RenderImage::layoutShadowControls(const LayoutSize& oldSize)
{
auto* controlsRenderer = downcast<RenderBox>(firstChild());
if (!controlsRenderer)
return;
bool controlsNeedLayout = controlsRenderer->needsLayout();
// If the region chain has changed we also need to relayout the controls to update the region box info.
// FIXME: We can do better once we compute region box info for RenderReplaced, not only for RenderBlock.
const RenderFlowThread* flowThread = flowThreadContainingBlock();
if (flowThread && !controlsNeedLayout) {
if (flowThread->pageLogicalSizeChanged())
controlsNeedLayout = true;
}
LayoutSize newSize = contentBoxRect().size();
if (newSize == oldSize && !controlsNeedLayout)
return;
// When calling layout() on a child node, a parent must either push a LayoutStateMaintainter, or
// instantiate LayoutStateDisabler. Since using a LayoutStateMaintainer is slightly more efficient,
// and this method might be called many times per second during video playback, use a LayoutStateMaintainer:
LayoutStateMaintainer statePusher(view(), *this, locationOffset(), hasTransform() || hasReflection() || style().isFlippedBlocksWritingMode());
if (shadowControlsNeedCustomLayoutMetrics()) {
controlsRenderer->setLocation(LayoutPoint(borderLeft(), borderTop()) + LayoutSize(paddingLeft(), paddingTop()));
controlsRenderer->style().setHeight(Length(newSize.height(), Fixed));
controlsRenderer->style().setWidth(Length(newSize.width(), Fixed));
}
controlsRenderer->setNeedsLayout(MarkOnlyThis);
controlsRenderer->layout();
clearChildNeedsLayout();
statePusher.pop();
}
示例4: ASSERT
void ImageDocument::imageUpdated()
{
ASSERT(m_imageElement);
if (m_imageSizeIsKnown)
return;
LayoutSize imageSize = this->imageSize();
if (imageSize.isEmpty())
return;
m_imageSizeIsKnown = true;
if (m_shouldShrinkImage) {
#if PLATFORM(IOS)
FloatSize screenSize = page()->chrome().screenSize();
if (imageSize.width() > screenSize.width())
processViewport(String::format("width=%u", static_cast<unsigned>(imageSize.width().toInt())), ViewportArguments::ImageDocument);
#else
// Call windowSizeChanged for its side effect of sizing the image.
windowSizeChanged();
#endif
}
}
示例5: push
void RenderGeometryMap::push(const RenderObject* renderer, const LayoutSize& offsetFromContainer, bool accumulatingTransform, bool isNonUniform, bool isFixedPosition, bool hasTransform, LayoutSize offsetForFixedPosition)
{
// fprintf(stderr, "RenderGeometryMap::push %p %d,%d isNonUniform=%d\n", renderer, offsetFromContainer.width().toInt(), offsetFromContainer.height().toInt(), isNonUniform);
ASSERT(m_insertionPosition != kNotFound);
ASSERT(!renderer->isRenderView() || !m_insertionPosition || m_mapCoordinatesFlags & TraverseDocumentBoundaries);
ASSERT(offsetForFixedPosition.isZero() || renderer->isRenderView());
m_mapping.insert(m_insertionPosition, RenderGeometryMapStep(renderer, accumulatingTransform, isNonUniform, isFixedPosition, hasTransform));
RenderGeometryMapStep& step = m_mapping[m_insertionPosition];
step.m_offset = offsetFromContainer;
step.m_offsetForFixedPosition = offsetForFixedPosition;
stepInserted(step);
}
示例6: push
void LayoutGeometryMap::push(const LayoutObject* layoutObject, const LayoutSize& offsetFromContainer, GeometryInfoFlags flags, LayoutSize offsetForFixedPosition)
{
LAYOUT_GEOMETRY_MAP_LOG("LayoutGeometryMap::push %p %d,%d isNonUniform=%d\n", layoutObject, offsetFromContainer.width().toInt(), offsetFromContainer.height().toInt(), isNonUniform);
ASSERT(m_insertionPosition != kNotFound);
ASSERT(!layoutObject->isLayoutView() || !m_insertionPosition || m_mapCoordinatesFlags & TraverseDocumentBoundaries);
ASSERT(offsetForFixedPosition.isZero() || layoutObject->isLayoutView());
m_mapping.insert(m_insertionPosition, LayoutGeometryMapStep(layoutObject, flags));
LayoutGeometryMapStep& step = m_mapping[m_insertionPosition];
step.m_offset = offsetFromContainer;
step.m_offsetForFixedPosition = offsetForFixedPosition;
stepInserted(step);
}
示例7: ASSERT
void RenderGeometryMap::push(const RenderObject* renderer, const TransformationMatrix& t, bool accumulatingTransform, bool isNonUniform, bool isFixedPosition, bool hasTransform, LayoutSize offsetForFixedPosition)
{
ASSERT(m_insertionPosition != kNotFound);
ASSERT(!renderer->isRenderView() || !m_insertionPosition || m_mapCoordinatesFlags & TraverseDocumentBoundaries);
ASSERT(offsetForFixedPosition.isZero() || renderer->isRenderView());
m_mapping.insert(m_insertionPosition, RenderGeometryMapStep(renderer, accumulatingTransform, isNonUniform, isFixedPosition, hasTransform));
RenderGeometryMapStep& step = m_mapping[m_insertionPosition];
step.m_offsetForFixedPosition = offsetForFixedPosition;
if (!t.isIntegerTranslation())
step.m_transform = adoptPtr(new TransformationMatrix(t));
else
step.m_offset = LayoutSize(t.e(), t.f());
stepInserted(step);
}
示例8: setContainerSizeForRenderer
void CachedImage::setContainerSizeForRenderer(const CachedImageClient* renderer, const LayoutSize& containerSize, float containerZoom)
{
if (containerSize.isEmpty())
return;
ASSERT(renderer);
ASSERT(containerZoom);
if (!m_image) {
m_pendingContainerSizeRequests.set(renderer, SizeAndZoom(containerSize, containerZoom));
return;
}
if (!m_image->isSVGImage()) {
m_image->setContainerSize(containerSize);
return;
}
m_svgImageCache->setContainerSizeForRenderer(renderer, containerSize, containerZoom);
}
示例9: LayoutSize
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();
}
示例10: startLabelImage
LayoutRect RenderSnapshottedPlugIn::tryToFitStartLabel(LabelSize size, const LayoutRect& contentBox) const
{
Image* labelImage = startLabelImage(size);
if (!labelImage)
return LayoutRect();
// Assume that the labelImage has been provided to match our device scale.
float scaleFactor = 1;
if (document()->page())
scaleFactor = document()->page()->deviceScaleFactor();
IntSize labelImageSize = labelImage->size();
labelImageSize.scale(1 / (scaleFactor ? scaleFactor : 1));
LayoutSize labelSize = labelImageSize - LayoutSize(2 * startLabelInset, 2 * startLabelInset);
LayoutRect candidateRect(contentBox.maxXMinYCorner() + LayoutSize(-startLabelPadding, startLabelPadding) + LayoutSize(-labelSize.width(), 0), labelSize);
// The minimum allowed content box size is the label image placed in the center of the box, surrounded by startLabelPadding.
if (candidateRect.x() < startLabelPadding || candidateRect.maxY() > contentBox.height() - startLabelPadding)
return LayoutRect();
return candidateRect;
}
示例11: setReferenceBoxLogicalSize
void ShapeOutsideInfo::setReferenceBoxLogicalSize(
LayoutSize newReferenceBoxLogicalSize) {
bool isHorizontalWritingMode =
m_layoutBox.containingBlock()->style()->isHorizontalWritingMode();
switch (referenceBox(*m_layoutBox.style()->shapeOutside())) {
case MarginBox:
if (isHorizontalWritingMode)
newReferenceBoxLogicalSize.expand(m_layoutBox.marginWidth(),
m_layoutBox.marginHeight());
else
newReferenceBoxLogicalSize.expand(m_layoutBox.marginHeight(),
m_layoutBox.marginWidth());
break;
case BorderBox:
break;
case PaddingBox:
if (isHorizontalWritingMode)
newReferenceBoxLogicalSize.shrink(m_layoutBox.borderWidth(),
m_layoutBox.borderHeight());
else
newReferenceBoxLogicalSize.shrink(m_layoutBox.borderHeight(),
m_layoutBox.borderWidth());
break;
case ContentBox:
if (isHorizontalWritingMode)
newReferenceBoxLogicalSize.shrink(m_layoutBox.borderAndPaddingWidth(),
m_layoutBox.borderAndPaddingHeight());
else
newReferenceBoxLogicalSize.shrink(m_layoutBox.borderAndPaddingHeight(),
m_layoutBox.borderAndPaddingWidth());
break;
case BoxMissing:
ASSERT_NOT_REACHED();
break;
}
newReferenceBoxLogicalSize.clampNegativeToZero();
if (m_referenceBoxLogicalSize == newReferenceBoxLogicalSize)
return;
markShapeAsDirty();
m_referenceBoxLogicalSize = newReferenceBoxLogicalSize;
}
示例12: ASSERT
bool ImageDocument::imageFitsInWindow() const
{
ASSERT(m_shrinkToFitMode == Desktop);
if (!m_imageElement || m_imageElement->document() != this)
return true;
FrameView* view = frame()->view();
if (!view)
return true;
ASSERT(m_imageElement->cachedImage());
LayoutSize imageSize = m_imageElement->cachedImage()->imageSizeForLayoutObject(m_imageElement->layoutObject(), pageZoomFactor(this));
LayoutSize windowSize = LayoutSize(view->width(), view->height());
return imageSize.width() <= windowSize.width() && imageSize.height() <= windowSize.height();
}
示例13: frame
float ImageDocument::scale() const
{
if (!m_imageElement || m_imageElement->document() != this)
return 1.0f;
FrameView* view = frame()->view();
if (!view)
return 1;
ASSERT(m_imageElement->cachedImage());
LayoutSize imageSize = m_imageElement->cachedImage()->imageSizeForLayoutObject(m_imageElement->layoutObject(), pageZoomFactor(this));
LayoutSize windowSize = LayoutSize(view->width(), view->height());
float widthScale = windowSize.width().toFloat() / imageSize.width().toFloat();
float heightScale = windowSize.height().toFloat() / imageSize.height().toFloat();
return min(widthScale, heightScale);
}
示例14: accumulateInFlowPositionOffsets
LayoutSize RenderBoxModelObject::relativePositionOffset() const
{
LayoutSize offset = accumulateInFlowPositionOffsets(this);
RenderBlock* containingBlock = this->containingBlock();
// Objects that shrink to avoid floats normally use available line width when computing containing block width. However
// in the case of relative positioning using percentages, we can't do this. The offset should always be resolved using the
// available width of the containing block. Therefore we don't use containingBlockLogicalWidthForContent() here, but instead explicitly
// call availableWidth on our containing block.
if (!style()->left().isAuto()) {
if (!style()->right().isAuto() && !containingBlock->style()->isLeftToRightDirection())
offset.setWidth(-valueForLength(style()->right(), containingBlock->availableWidth()));
else
offset.expand(valueForLength(style()->left(), containingBlock->availableWidth()), 0);
} else if (!style()->right().isAuto()) {
offset.expand(-valueForLength(style()->right(), containingBlock->availableWidth()), 0);
}
// If the containing block of a relatively positioned element does not
// specify a height, a percentage top or bottom offset should be resolved as
// auto. An exception to this is if the containing block has the WinIE quirk
// where <html> and <body> assume the size of the viewport. In this case,
// calculate the percent offset based on this height.
// See <https://bugs.webkit.org/show_bug.cgi?id=26396>.
if (!style()->top().isAuto()
&& (!containingBlock->hasAutoHeightOrContainingBlockWithAutoHeight()
|| !style()->top().isPercent()
|| containingBlock->stretchesToViewport()))
offset.expand(0, valueForLength(style()->top(), containingBlock->availableHeight()));
else if (!style()->bottom().isAuto()
&& (!containingBlock->hasAutoHeightOrContainingBlockWithAutoHeight()
|| !style()->bottom().isPercent()
|| containingBlock->stretchesToViewport()))
offset.expand(0, -valueForLength(style()->bottom(), containingBlock->availableHeight()));
return offset;
}
示例15: setReferenceBoxLogicalSize
void ShapeOutsideInfo::setReferenceBoxLogicalSize(LayoutSize newReferenceBoxLogicalSize)
{
bool isHorizontalWritingMode = m_renderer.containingBlock()->style().isHorizontalWritingMode();
switch (referenceBox(*m_renderer.style().shapeOutside())) {
case MarginBox:
if (isHorizontalWritingMode)
newReferenceBoxLogicalSize.expand(m_renderer.horizontalMarginExtent(), m_renderer.verticalMarginExtent());
else
newReferenceBoxLogicalSize.expand(m_renderer.verticalMarginExtent(), m_renderer.horizontalMarginExtent());
break;
case BorderBox:
break;
case PaddingBox:
if (isHorizontalWritingMode)
newReferenceBoxLogicalSize.shrink(m_renderer.horizontalBorderExtent(), m_renderer.verticalBorderExtent());
else
newReferenceBoxLogicalSize.shrink(m_renderer.verticalBorderExtent(), m_renderer.horizontalBorderExtent());
break;
case ContentBox:
if (isHorizontalWritingMode)
newReferenceBoxLogicalSize.shrink(m_renderer.horizontalBorderAndPaddingExtent(), m_renderer.verticalBorderAndPaddingExtent());
else
newReferenceBoxLogicalSize.shrink(m_renderer.verticalBorderAndPaddingExtent(), m_renderer.horizontalBorderAndPaddingExtent());
break;
case Fill:
case Stroke:
case ViewBox:
case BoxMissing:
ASSERT_NOT_REACHED();
break;
}
if (m_referenceBoxLogicalSize == newReferenceBoxLogicalSize)
return;
markShapeAsDirty();
m_referenceBoxLogicalSize = newReferenceBoxLogicalSize;
}