本文整理汇总了C++中LayoutRect::setSize方法的典型用法代码示例。如果您正苦于以下问题:C++ LayoutRect::setSize方法的具体用法?C++ LayoutRect::setSize怎么用?C++ LayoutRect::setSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LayoutRect
的用法示例。
在下文中一共展示了LayoutRect::setSize方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: replacedContentRect
LayoutRect RenderReplaced::replacedContentRect(const LayoutSize& intrinsicSize) const
{
LayoutRect contentRect = contentBoxRect();
if (intrinsicSize.isEmpty())
return contentRect;
ObjectFit objectFit = style().objectFit();
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;
FALLTHROUGH;
case ObjectFitNone:
finalRect.setSize(intrinsicSize);
break;
case ObjectFitFill:
break;
}
LengthPoint objectPosition = style().objectPosition();
LayoutUnit xOffset = minimumValueForLength(objectPosition.x(), contentRect.width() - finalRect.width());
LayoutUnit yOffset = minimumValueForLength(objectPosition.y(), contentRect.height() - finalRect.height());
finalRect.move(xOffset, yOffset);
return finalRect;
}
示例2: 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;
}
示例3: 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;
}
示例4: replacedContentRect
LayoutRect RenderReplaced::replacedContentRect(const LayoutSize* overriddenIntrinsicSize) const
{
LayoutRect contentRect = contentBoxRect();
ObjectFit objectFit = style()->objectFit();
if (objectFit == ObjectFitFill && style()->objectPosition() == RenderStyle::initialObjectPosition()) {
if (RuntimeEnabledFeatures::objectFitPositionEnabled())
return contentRect;
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;
}
示例5: writeLayers
void RenderTreeAsText::writeLayers(TextStream& ts, const RenderLayer* rootLayer, RenderLayer* layer,
const LayoutRect& paintRect, int indent, RenderAsTextBehavior behavior)
{
// FIXME: Apply overflow to the root layer to not break every test. Complete hack. Sigh.
LayoutRect paintDirtyRect(paintRect);
if (rootLayer == layer) {
paintDirtyRect.setWidth(max<LayoutUnit>(paintDirtyRect.width(), rootLayer->renderer()->layoutOverflowRect().maxX()));
paintDirtyRect.setHeight(max<LayoutUnit>(paintDirtyRect.height(), rootLayer->renderer()->layoutOverflowRect().maxY()));
}
// Calculate the clip rects we should use.
LayoutRect layerBounds;
ClipRect damageRect;
layer->clipper().calculateRects(ClipRectsContext(rootLayer, UncachedClipRects), paintDirtyRect, layerBounds, damageRect);
// FIXME: Apply overflow to the root layer to not break every test. Complete hack. Sigh.
if (rootLayer == layer)
layerBounds.setSize(layer->size().expandedTo(pixelSnappedIntSize(layer->renderer()->maxLayoutOverflow(), LayoutPoint(0, 0))));
// Ensure our lists are up-to-date.
layer->stackingNode()->updateLayerListsIfNeeded();
bool shouldPaint = (behavior & RenderAsTextShowAllLayers) ? true : layer->intersectsDamageRect(layerBounds, damageRect.rect(), rootLayer);
if (shouldPaint)
write(ts, *layer, layerBounds, damageRect.rect(), indent, behavior);
if (Vector<RenderLayerStackingNode*>* normalFlowList = layer->stackingNode()->normalFlowList()) {
int currIndent = indent;
if (behavior & RenderAsTextShowLayerNesting) {
writeIndent(ts, indent);
ts << " normal flow list(" << normalFlowList->size() << ")\n";
++currIndent;
}
for (unsigned i = 0; i != normalFlowList->size(); ++i)
writeLayers(ts, rootLayer, normalFlowList->at(i)->layer(), paintDirtyRect, currIndent, behavior);
}
if (Vector<RenderLayerStackingNode*>* posList = layer->stackingNode()->zOrderList()) {
int currIndent = indent;
if (behavior & RenderAsTextShowLayerNesting) {
writeIndent(ts, indent);
ts << " positive z-order list(" << posList->size() << ")\n";
++currIndent;
}
for (unsigned i = 0; i != posList->size(); ++i)
writeLayers(ts, rootLayer, posList->at(i)->layer(), paintDirtyRect, currIndent, behavior);
}
}
示例6: scrollIntoView
LayoutRect RootFrameViewport::scrollIntoView(const LayoutRect& rectInContent, const ScrollAlignment& alignX, const ScrollAlignment& alignY)
{
// We want to move the rect into the viewport that excludes the scrollbars so we intersect
// the visual viewport with the scrollbar-excluded frameView content rect. However, we don't
// use visibleContentRect directly since it floors the scroll position. Instead, we use
// FrameView::scrollPositionDouble and construct a LayoutRect from that (the FrameView size
// is always integer sized.
LayoutRect frameRectInContent = LayoutRect(
layoutViewport().scrollPositionDouble(),
layoutViewport().visibleContentRect().size());
LayoutRect visualRectInContent = LayoutRect(
layoutViewport().scrollPositionDouble() + toDoubleSize(visualViewport().scrollPositionDouble()),
visualViewport().visibleContentRect().size());
LayoutRect viewRectInContent = intersection(visualRectInContent, frameRectInContent);
LayoutRect targetViewport =
ScrollAlignment::getRectToExpose(viewRectInContent, rectInContent, alignX, alignY);
// visualViewport.scrollIntoView will attempt to center the given rect within the viewport
// so to prevent it from adjusting r's coordinates the rect must match the viewport's size
// i.e. add the subtracted scrollbars from above back in.
// FIXME: This is hacky and required because getRectToExpose doesn't naturally account
// for the two viewports. crbug.com/449340.
targetViewport.setSize(LayoutSize(visualViewport().visibleContentRect().size()));
// Snap the visible rect to layout units to match the calculated target viewport rect.
FloatRect visible =
LayoutRect(visualViewport().scrollPositionDouble(), visualViewport().visibleContentRect().size());
float centeringOffsetX = (visible.width() - targetViewport.width()) / 2;
float centeringOffsetY = (visible.height() - targetViewport.height()) / 2;
DoublePoint targetOffset(
targetViewport.x() - centeringOffsetX,
targetViewport.y() - centeringOffsetY);
setScrollPosition(targetOffset, ProgrammaticScroll);
// RootFrameViewport only changes the viewport relative to the document so we can't change the input
// rect's location relative to the document origin.
return rectInContent;
}