本文整理汇总了C++中LayoutRect::size方法的典型用法代码示例。如果您正苦于以下问题:C++ LayoutRect::size方法的具体用法?C++ LayoutRect::size怎么用?C++ LayoutRect::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LayoutRect
的用法示例。
在下文中一共展示了LayoutRect::size方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: computeRegionClippingRect
LayoutRect RenderFlowThread::computeRegionClippingRect(const LayoutPoint& offset, const LayoutRect& flowThreadPortionRect, const LayoutRect& flowThreadPortionOverflowRect) const
{
LayoutRect regionClippingRect(offset + (flowThreadPortionOverflowRect.location() - flowThreadPortionRect.location()), flowThreadPortionOverflowRect.size());
if (style()->isFlippedBlocksWritingMode())
regionClippingRect.move(flowThreadPortionRect.size() - flowThreadPortionOverflowRect.size());
return regionClippingRect;
}
示例2: paintBoxDecorationBackground
void InlineFlowBoxPainter::paintBoxDecorationBackground(const PaintInfo& paintInfo, const LayoutPoint& paintOffset, const LayoutRect& cullRect)
{
ASSERT(paintInfo.phase == PaintPhaseForeground);
if (m_inlineFlowBox.lineLayoutItem().style()->visibility() != VISIBLE)
return;
// You can use p::first-line to specify a background. If so, the root line boxes for
// a line may actually have to paint a background.
LayoutObject* inlineFlowBoxLayoutObject = LineLayoutAPIShim::layoutObjectFrom(m_inlineFlowBox.lineLayoutItem());
const ComputedStyle* styleToUse = m_inlineFlowBox.lineLayoutItem().style(m_inlineFlowBox.isFirstLineStyle());
bool shouldPaintBoxDecorationBackground;
if (m_inlineFlowBox.parent())
shouldPaintBoxDecorationBackground = inlineFlowBoxLayoutObject->hasBoxDecorationBackground();
else
shouldPaintBoxDecorationBackground = m_inlineFlowBox.isFirstLineStyle() && styleToUse != m_inlineFlowBox.lineLayoutItem().style();
if (!shouldPaintBoxDecorationBackground)
return;
if (DrawingRecorder::useCachedDrawingIfPossible(paintInfo.context, m_inlineFlowBox, DisplayItem::BoxDecorationBackground))
return;
DrawingRecorder recorder(paintInfo.context, m_inlineFlowBox, DisplayItem::BoxDecorationBackground, pixelSnappedIntRect(cullRect));
LayoutRect frameRect = frameRectClampedToLineTopAndBottomIfNeeded();
// Move x/y to our coordinates.
LayoutRect localRect(frameRect);
m_inlineFlowBox.flipForWritingMode(localRect);
LayoutPoint adjustedPaintOffset = paintOffset + localRect.location();
LayoutRect adjustedFrameRect = LayoutRect(adjustedPaintOffset, frameRect.size());
IntRect adjustedClipRect;
BorderPaintingType borderPaintingType = getBorderPaintType(adjustedFrameRect, adjustedClipRect);
// Shadow comes first and is behind the background and border.
if (!m_inlineFlowBox.boxModelObject().boxShadowShouldBeAppliedToBackground(BackgroundBleedNone, &m_inlineFlowBox))
paintBoxShadow(paintInfo, *styleToUse, Normal, adjustedFrameRect);
Color backgroundColor = inlineFlowBoxLayoutObject->resolveColor(*styleToUse, CSSPropertyBackgroundColor);
paintFillLayers(paintInfo, backgroundColor, styleToUse->backgroundLayers(), adjustedFrameRect);
paintBoxShadow(paintInfo, *styleToUse, Inset, adjustedFrameRect);
switch (borderPaintingType) {
case DontPaintBorders:
break;
case PaintBordersWithoutClip:
BoxPainter::paintBorder(*toLayoutBoxModelObject(LineLayoutAPIShim::layoutObjectFrom(m_inlineFlowBox.boxModelObject())), paintInfo, adjustedFrameRect, m_inlineFlowBox.lineLayoutItem().styleRef(m_inlineFlowBox.isFirstLineStyle()), BackgroundBleedNone, m_inlineFlowBox.includeLogicalLeftEdge(), m_inlineFlowBox.includeLogicalRightEdge());
break;
case PaintBordersWithClip:
// FIXME: What the heck do we do with RTL here? The math we're using is obviously not right,
// but it isn't even clear how this should work at all.
LayoutRect imageStripPaintRect = paintRectForImageStrip(adjustedPaintOffset, frameRect.size(), LTR);
GraphicsContextStateSaver stateSaver(paintInfo.context);
paintInfo.context.clip(adjustedClipRect);
BoxPainter::paintBorder(*toLayoutBoxModelObject(LineLayoutAPIShim::layoutObjectFrom(m_inlineFlowBox.boxModelObject())), paintInfo, imageStripPaintRect, m_inlineFlowBox.lineLayoutItem().styleRef(m_inlineFlowBox.isFirstLineStyle()));
break;
}
}
示例3: orientation
// Lacking concrete evidence of orientation, horizontal means width > height. vertical is height > width;
AccessibilityOrientation AccessibilityObject::orientation() const
{
LayoutRect bounds = elementRect();
if (bounds.size().width() > bounds.size().height())
return AccessibilityOrientationHorizontal;
if (bounds.size().height() > bounds.size().width())
return AccessibilityOrientationVertical;
// A tie goes to horizontal.
return AccessibilityOrientationHorizontal;
}
开发者ID:IllusionRom-deprecated,项目名称:android_platform_external_chromium_org_third_party_WebKit,代码行数:12,代码来源:AccessibilityObject.cpp
示例4: 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;
}
示例5: imageAreaForImage
HTMLAreaElement* HitTestResult::imageAreaForImage() const
{
ASSERT(m_innerNode);
HTMLImageElement* imageElement = nullptr;
if (isHTMLImageElement(m_innerNode)) {
imageElement = toHTMLImageElement(m_innerNode);
} else if (m_innerNode->isInShadowTree()) {
if (m_innerNode->containingShadowRoot()->type() == ShadowRootType::UserAgent) {
if (isHTMLImageElement(m_innerNode->shadowHost()))
imageElement = toHTMLImageElement(m_innerNode->shadowHost());
}
}
if (!imageElement || !imageElement->layoutObject() || !imageElement->layoutObject()->isBox())
return nullptr;
HTMLMapElement* map = imageElement->treeScope().getImageMap(imageElement->fastGetAttribute(usemapAttr));
if (!map)
return nullptr;
LayoutBox* box = toLayoutBox(imageElement->layoutObject());
LayoutRect contentBox = box->contentBoxRect();
float scaleFactor = 1 / box->style()->effectiveZoom();
LayoutPoint location = localPoint();
location.scale(scaleFactor, scaleFactor);
return map->areaForPoint(location, contentBox.size());
}
示例6: 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;
}
示例7: 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();
}
示例8: invalidatePaintOfScrollbarIfNeeded
static void invalidatePaintOfScrollbarIfNeeded(Scrollbar* scrollbar, GraphicsLayer* graphicsLayer, bool& previouslyWasOverlay, LayoutRect& previousPaintInvalidationRect, bool needsPaintInvalidationArg, LayoutBox& box, const PaintInvalidationState& paintInvalidationState, const LayoutBoxModelObject& paintInvalidationContainer)
{
bool isOverlay = scrollbar && scrollbar->isOverlayScrollbar();
// Calculate paint invalidation rect of the scrollbar, except overlay composited scrollbars because we invalidate the graphics layer only.
LayoutRect newPaintInvalidationRect;
if (scrollbar && !(graphicsLayer && isOverlay))
newPaintInvalidationRect = scrollControlPaintInvalidationRect(scrollbar->frameRect(), box, paintInvalidationState, paintInvalidationContainer);
bool needsPaintInvalidation = needsPaintInvalidationArg;
if (graphicsLayer) {
// If the scrollbar needs paint invalidation but didn't change location/size or the scrollbar is an
// overlay scrollbar (paint invalidation rect is empty), invalidating the graphics layer is enough
// (which has been done in ScrollableArea::setScrollbarNeedsPaintInvalidation()).
// Otherwise invalidatePaintOfScrollControlIfNeeded() below will invalidate the old and new location
// of the scrollbar on the box's paint invalidation container to ensure newly expanded/shrunk areas
// of the box to be invalidated.
needsPaintInvalidation = false;
}
// Invalidate the box's display item client if the box's padding box size is affected by change of the
// non-overlay scrollbar width. We detect change of paint invalidation rect size instead of change of
// scrollbar width change, which may have some false-positives (e.g. the scrollbar changed length but
// not width) but won't invalidate more than expected because in the false-positive case the box must
// have changed size and have been invalidated.
LayoutSize newScrollbarUsedSpaceInBox;
if (!isOverlay)
newScrollbarUsedSpaceInBox = newPaintInvalidationRect.size();
LayoutSize previousScrollbarUsedSpaceInBox;
if (!previouslyWasOverlay)
previousScrollbarUsedSpaceInBox= previousPaintInvalidationRect.size();
if (newScrollbarUsedSpaceInBox != previousScrollbarUsedSpaceInBox)
paintInvalidationContainer.invalidateDisplayItemClientOnBacking(box, PaintInvalidationScroll);
bool invalidated = invalidatePaintOfScrollControlIfNeeded(newPaintInvalidationRect, previousPaintInvalidationRect, needsPaintInvalidation, box, paintInvalidationContainer);
previousPaintInvalidationRect = newPaintInvalidationRect;
previouslyWasOverlay = isOverlay;
if (!invalidated || !scrollbar || graphicsLayer)
return;
paintInvalidationContainer.invalidateDisplayItemClientOnBacking(*scrollbar, PaintInvalidationScroll);
if (scrollbar->isCustomScrollbar())
toLayoutScrollbar(scrollbar)->invalidateDisplayItemClientsOfScrollbarParts(paintInvalidationContainer);
}
示例9: boxReflectionForPaintLayer
BoxReflection boxReflectionForPaintLayer(const PaintLayer& layer,
const ComputedStyle& style) {
const StyleReflection* reflectStyle = style.boxReflect();
LayoutRect frameLayoutRect = toLayoutBox(layer.layoutObject())->frameRect();
FloatRect frameRect(frameLayoutRect);
BoxReflection::ReflectionDirection direction =
BoxReflection::VerticalReflection;
float offset = 0;
switch (reflectStyle->direction()) {
case ReflectionAbove:
direction = BoxReflection::VerticalReflection;
offset = -floatValueForLength(reflectStyle->offset(), frameRect.height());
break;
case ReflectionBelow:
direction = BoxReflection::VerticalReflection;
offset = 2 * frameRect.height() +
floatValueForLength(reflectStyle->offset(), frameRect.height());
break;
case ReflectionLeft:
direction = BoxReflection::HorizontalReflection;
offset = -floatValueForLength(reflectStyle->offset(), frameRect.width());
break;
case ReflectionRight:
direction = BoxReflection::HorizontalReflection;
offset = 2 * frameRect.width() +
floatValueForLength(reflectStyle->offset(), frameRect.width());
break;
}
sk_sp<SkPicture> mask;
const NinePieceImage& maskNinePiece = reflectStyle->mask();
if (maskNinePiece.hasImage()) {
LayoutRect maskRect(LayoutPoint(), frameLayoutRect.size());
LayoutRect maskBoundingRect(maskRect);
maskBoundingRect.expand(style.imageOutsets(maskNinePiece));
FloatRect maskBoundingFloatRect(maskBoundingRect);
// TODO(jbroman): SkPictureBuilder + DrawingRecorder seems excessive.
// If NinePieceImagePainter operated on SkCanvas, we'd only need an
// SkPictureRecorder here.
SkPictureBuilder recorder(maskBoundingFloatRect);
{
GraphicsContext& context = recorder.context();
DrawingRecorder drawingRecorder(context, *layer.layoutObject(),
DisplayItem::kReflectionMask,
maskBoundingFloatRect);
NinePieceImagePainter(*layer.layoutObject())
.paint(recorder.context(), maskRect, style, maskNinePiece,
SkXfermode::kSrcOver_Mode);
}
mask = recorder.endRecording();
}
return BoxReflection(direction, offset, std::move(mask));
}
示例10: logicalRectToPhysicalRect
void InlineBox::logicalRectToPhysicalRect(LayoutRect& current) const
{
if (isHorizontal() && !lineLayoutItem().hasFlippedBlocksWritingMode())
return;
if (!isHorizontal()) {
current = current.transposedRect();
}
current.setLocation(logicalPositionToPhysicalPoint(current.location(), current.size()));
return;
}
示例11: paint
void NinePieceImage::paint(GraphicsContext* graphicsContext, RenderElement* renderer, const RenderStyle& style, const LayoutRect& destination, const LayoutSize& source, bool intrinsicSource, float deviceScaleFactor, CompositeOperator op) const
{
StyleImage* styleImage = image();
ASSERT(styleImage && styleImage->isLoaded());
LayoutBoxExtent sourceSlices = computeSlices(source, imageSlices(), styleImage->imageScaleFactor());
LayoutBoxExtent destinationSlices = computeSlices(destination.size(), borderSlices(), style.borderWidth(), sourceSlices);
scaleSlicesIfNeeded(destination.size(), destinationSlices, deviceScaleFactor);
Vector<FloatRect> destinationRects = computeIntrinsicRects(destination, destinationSlices, deviceScaleFactor);
Vector<FloatRect> sourceRects;
Vector<FloatSize> tileScales;
if (intrinsicSource) {
sourceRects = computeIntrinsicRects(FloatRect(FloatPoint(), source), sourceSlices, deviceScaleFactor);
tileScales = computeIntrinsicTileScales(destinationRects, sourceRects, horizontalRule(), verticalRule());
} else {
sourceRects = computeNonIntrinsicRects(destinationRects, sourceSlices);
tileScales = computeNonIntrinsicTileScales();
}
RefPtr<Image> image = styleImage->image(renderer, source);
ColorSpace colorSpace = style.colorSpace();
for (ImagePiece piece = MinPiece; piece < MaxPiece; ++piece) {
if ((piece == MiddlePiece && !fill()) || isEmptyPieceRect(piece, destinationRects, sourceRects))
continue;
if (isCornerPiece(piece)) {
graphicsContext->drawImage(image.get(), colorSpace, destinationRects[piece], sourceRects[piece], op);
continue;
}
Image::TileRule hRule = isHorizontalPiece(piece) ? static_cast<Image::TileRule>(horizontalRule()) : Image::StretchTile;
Image::TileRule vRule = isVerticalPiece(piece) ? static_cast<Image::TileRule>(verticalRule()) : Image::StretchTile;
graphicsContext->drawTiledImage(image.get(), colorSpace, destinationRects[piece], sourceRects[piece], tileScales[piece], hRule, vRule, op);
}
}
示例12: 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;
}
示例13: 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);
}
示例14: computeOrigin
IntPoint ViewportAnchor::computeOrigin(const IntSize& currentViewSize) const
{
if (!m_anchorNode || !m_anchorNode->inDocument())
return m_viewRect.location();
const LayoutRect currentNodeBounds = m_anchorNode->boundingBox();
if (m_anchorNodeBounds == currentNodeBounds)
return m_viewRect.location();
// Compute the new anchor point relative to the node position
FloatSize anchorOffsetFromNode = currentNodeBounds.size();
anchorOffsetFromNode.scale(m_anchorInNodeCoords.width(), m_anchorInNodeCoords.height());
FloatPoint anchorPoint = currentNodeBounds.location() + anchorOffsetFromNode;
// Compute the new origin point relative to the new anchor point
FloatSize anchorOffsetFromOrigin = currentViewSize;
anchorOffsetFromOrigin.scale(m_anchorInViewCoords.width(), m_anchorInViewCoords.height());
return flooredIntPoint(anchorPoint - anchorOffsetFromOrigin);
}
示例15: getInnerOrigin
FloatPoint ViewportAnchor::getInnerOrigin(const FloatSize& innerSize) const
{
if (!m_anchorNode || !m_anchorNode->inDocument())
return m_pinchViewportInDocument;
const LayoutRect currentNodeBounds = m_anchorNode->boundingBox();
if (m_anchorNodeBounds == currentNodeBounds)
return m_pinchViewportInDocument;
// Compute the new anchor point relative to the node position
FloatSize anchorOffsetFromNode(currentNodeBounds.size());
anchorOffsetFromNode.scale(m_anchorInNodeCoords.width(), m_anchorInNodeCoords.height());
FloatPoint anchorPoint = FloatPoint(currentNodeBounds.location()) + anchorOffsetFromNode;
// Compute the new origin point relative to the new anchor point
FloatSize anchorOffsetFromOrigin = innerSize;
anchorOffsetFromOrigin.scale(m_anchorInInnerViewCoords.width(), m_anchorInInnerViewCoords.height());
return anchorPoint - anchorOffsetFromOrigin;
}