本文整理汇总了C++中LayoutSize函数的典型用法代码示例。如果您正苦于以下问题:C++ LayoutSize函数的具体用法?C++ LayoutSize怎么用?C++ LayoutSize使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了LayoutSize函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: toLayoutBox
void PaintInvalidationState::applyClipIfNeeded(const LayoutObject& layoutObject)
{
if (!layoutObject.hasOverflowClip())
return;
const LayoutBox& box = toLayoutBox(layoutObject);
// Do not clip scroll layer contents because the compositor expects the whole layer
// to be always invalidated in-time.
if (box.usesCompositedScrolling())
ASSERT(!m_clipped); // The box should establish paint invalidation container, so no m_clipped inherited.
else
addClipRectRelativeToPaintOffset(LayoutSize(box.layer()->size()));
m_paintOffset -= box.scrolledContentOffset();
}
示例2: computedShape
bool ExclusionShapeInsideInfo::adjustLogicalLineTop(float minSegmentWidth)
{
const ExclusionShape* shape = computedShape();
if (!shape || m_lineHeight <= 0 || logicalLineTop() > shapeLogicalBottom())
return false;
LayoutUnit newLineTop;
if (shape->firstIncludedIntervalLogicalTop(m_shapeLineTop, LayoutSize(minSegmentWidth, m_lineHeight), newLineTop)) {
if (newLineTop > m_shapeLineTop) {
m_shapeLineTop = newLineTop;
return true;
}
}
return false;
}
示例3: pixelSnappedIntRect
void ImagePainter::paintIntoRect(GraphicsContext& context,
const LayoutRect& destRect,
const LayoutRect& contentRect) {
if (!m_layoutImage.imageResource()->hasImage() ||
m_layoutImage.imageResource()->errorOccurred())
return; // FIXME: should we just ASSERT these conditions? (audit all
// callers).
IntRect pixelSnappedDestRect = pixelSnappedIntRect(destRect);
if (pixelSnappedDestRect.isEmpty())
return;
RefPtr<Image> image = m_layoutImage.imageResource()->image(
pixelSnappedDestRect.size(), m_layoutImage.style()->effectiveZoom());
if (!image || image->isNull())
return;
// FIXME: why is interpolation quality selection not included in the
// Instrumentation reported cost of drawing an image?
InterpolationQuality interpolationQuality =
BoxPainter::chooseInterpolationQuality(
m_layoutImage, image.get(), image.get(),
LayoutSize(pixelSnappedDestRect.size()));
FloatRect srcRect = image->rect();
// If the content rect requires clipping, adjust |srcRect| and
// |pixelSnappedDestRect| over using a clip.
if (!contentRect.contains(destRect)) {
IntRect pixelSnappedContentRect = pixelSnappedIntRect(contentRect);
pixelSnappedContentRect.intersect(pixelSnappedDestRect);
if (pixelSnappedContentRect.isEmpty())
return;
srcRect = mapRect(pixelSnappedContentRect, pixelSnappedDestRect, srcRect);
pixelSnappedDestRect = pixelSnappedContentRect;
}
TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "PaintImage",
"data", InspectorPaintImageEvent::data(m_layoutImage));
InterpolationQuality previousInterpolationQuality =
context.imageInterpolationQuality();
context.setImageInterpolationQuality(interpolationQuality);
context.drawImage(
image.get(), pixelSnappedDestRect, &srcRect, SkXfermode::kSrcOver_Mode,
LayoutObject::shouldRespectImageOrientation(&m_layoutImage));
context.setImageInterpolationQuality(previousInterpolationQuality);
}
示例4: ASSERT
void IntersectionObservation::clipToRoot(LayoutRect& rect)
{
// Map and clip rect into root element coordinates.
// TODO(szager): the writing mode flipping needs a test.
ASSERT(m_target);
LayoutObject* rootLayoutObject = m_observer->rootLayoutObject();
LayoutObject* targetLayoutObject = target()->layoutObject();
targetLayoutObject->mapToVisibleRectInAncestorSpace(toLayoutBoxModelObject(rootLayoutObject), rect, nullptr);
if (rootLayoutObject->hasOverflowClip()) {
LayoutBox* rootLayoutBox = toLayoutBox(rootLayoutObject);
LayoutRect clipRect(LayoutPoint(), LayoutSize(rootLayoutBox->layer()->size()));
m_observer->applyRootMargin(clipRect);
rootLayoutBox->flipForWritingMode(rect);
rect.intersect(clipRect);
rootLayoutBox->flipForWritingMode(rect);
}
}
示例5: applyClipRects
static void applyClipRects(const ClipRectsContext& context,
const LayoutBoxModelObject& layoutObject,
LayoutPoint offset,
ClipRects& clipRects) {
DCHECK(layoutObject.hasClipRelatedProperty() ||
(layoutObject.isSVGRoot() &&
toLayoutSVGRoot(&layoutObject)->shouldApplyViewportClip()));
LayoutView* view = layoutObject.view();
DCHECK(view);
if (clipRects.fixed() && context.rootLayer->layoutObject() == view)
offset -= LayoutSize(view->frameView()->scrollOffset());
if (layoutObject.hasOverflowClip() ||
(layoutObject.isSVGRoot() &&
toLayoutSVGRoot(&layoutObject)->shouldApplyViewportClip()) ||
(layoutObject.styleRef().containsPaint() && layoutObject.isBox())) {
ClipRect newOverflowClip =
toLayoutBox(layoutObject)
.overflowClipRect(offset, context.overlayScrollbarClipBehavior);
newOverflowClip.setHasRadius(layoutObject.styleRef().hasBorderRadius());
clipRects.setOverflowClipRect(
intersection(newOverflowClip, clipRects.overflowClipRect()));
if (layoutObject.isPositioned())
clipRects.setPosClipRect(
intersection(newOverflowClip, clipRects.posClipRect()));
if (layoutObject.isLayoutView())
clipRects.setFixedClipRect(
intersection(newOverflowClip, clipRects.fixedClipRect()));
if (layoutObject.styleRef().containsPaint()) {
clipRects.setPosClipRect(
intersection(newOverflowClip, clipRects.posClipRect()));
clipRects.setFixedClipRect(
intersection(newOverflowClip, clipRects.fixedClipRect()));
}
}
if (layoutObject.hasClip()) {
LayoutRect newClip = toLayoutBox(layoutObject).clipRect(offset);
clipRects.setPosClipRect(
intersection(newClip, clipRects.posClipRect()).setIsClippedByClipCss());
clipRects.setOverflowClipRect(
intersection(newClip, clipRects.overflowClipRect())
.setIsClippedByClipCss());
clipRects.setFixedClipRect(intersection(newClip, clipRects.fixedClipRect())
.setIsClippedByClipCss());
}
}
示例6: 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);
}
示例7: renderer
void EllipsisBox::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset, LayoutUnit lineTop, LayoutUnit lineBottom)
{
GraphicsContext* context = paintInfo.context;
RenderStyle* style = renderer().style(isFirstLineStyle());
const Font& font = style->font();
FloatPoint boxOrigin = locationIncludingFlipping();
boxOrigin.moveBy(FloatPoint(paintOffset));
FloatRect boxRect(boxOrigin, LayoutSize(logicalWidth(), virtualLogicalHeight()));
GraphicsContextStateSaver stateSaver(*context);
FloatPoint textOrigin = FloatPoint(boxOrigin.x(), boxOrigin.y() + font.fontMetrics().ascent());
Color styleTextColor = renderer().resolveColor(style, CSSPropertyWebkitTextFillColor);
if (styleTextColor != context->fillColor())
context->setFillColor(styleTextColor);
if (selectionState() != RenderObject::SelectionNone) {
paintSelection(context, boxOrigin, style, font);
// Select the correct color for painting the text.
Color foreground = paintInfo.forceBlackText() ? Color::black : renderer().selectionForegroundColor();
if (foreground != styleTextColor)
context->setFillColor(foreground);
}
const ShadowList* shadowList = style->textShadow();
bool hasShadow = shadowList;
if (hasShadow)
context->setDrawLooper(shadowList->createDrawLooper(DrawLooperBuilder::ShadowIgnoresAlpha));
TextRun textRun = constructTextRun(&renderer(), font, m_str, style, TextRun::AllowTrailingExpansion);
TextRunPaintInfo textRunPaintInfo(textRun);
textRunPaintInfo.bounds = boxRect;
context->drawText(font, textRunPaintInfo, textOrigin);
// Restore the regular fill color.
if (styleTextColor != context->fillColor())
context->setFillColor(styleTextColor);
if (hasShadow)
context->clearDrawLooper();
paintMarkupBox(paintInfo, paintOffset, lineTop, lineBottom, style);
}
示例8: layoutObject
AffineTransform SVGGraphicsElement::calculateAnimatedLocalTransform() const
{
AffineTransform matrix;
const ComputedStyle* style = layoutObject() ? layoutObject()->style() : nullptr;
// If CSS property was set, use that, otherwise fallback to attribute (if set).
if (style && style->hasTransform()) {
TransformationMatrix transform;
float zoom = style->effectiveZoom();
// SVGTextElements need special handling for the text positioning code.
if (isSVGTextElement(this)) {
// Do not take into account SVG's zoom rules, transform-origin, or percentage values.
style->applyTransform(transform, LayoutSize(0, 0), ComputedStyle::ExcludeTransformOrigin, ComputedStyle::IncludeMotionPath, ComputedStyle::IncludeIndependentTransformProperties);
} else {
// CSS transforms operate with pre-scaled lengths. To make this work with SVG
// (which applies the zoom factor globally, at the root level) we
//
// * pre-scale the bounding box (to bring it into the same space as the other CSS values)
// * invert the zoom factor (to effectively compute the CSS transform under a 1.0 zoom)
//
// Note: objectBoundingBox is an emptyRect for elements like pattern or clipPath.
// See the "Object bounding box units" section of http://dev.w3.org/csswg/css3-transforms/
if (zoom != 1) {
FloatRect scaledBBox = layoutObject()->objectBoundingBox();
scaledBBox.scale(zoom);
transform.scale(1 / zoom);
style->applyTransform(transform, scaledBBox, ComputedStyle::IncludeTransformOrigin, ComputedStyle::IncludeMotionPath, ComputedStyle::IncludeIndependentTransformProperties);
transform.scale(zoom);
} else {
style->applyTransform(transform, layoutObject()->objectBoundingBox(), ComputedStyle::IncludeTransformOrigin, ComputedStyle::IncludeMotionPath, ComputedStyle::IncludeIndependentTransformProperties);
}
}
// Flatten any 3D transform.
matrix = transform.toAffineTransform();
} else {
m_transform->currentValue()->concatenate(matrix);
}
if (hasSVGRareData())
return *svgRareData()->animateMotionTransform() * matrix;
return matrix;
}
示例9: m_isPaginated
LayoutState::LayoutState(LayoutObject& root)
: m_isPaginated(false)
, m_pageLogicalHeightChanged(false)
, m_containingBlockLogicalWidthChanged(false)
, m_flowThread(nullptr)
, m_next(root.view()->layoutState())
, m_layoutObject(root)
{
ASSERT(!m_next);
// We'll end up pushing in LayoutView itself, so don't bother adding it.
if (root.isLayoutView())
return;
root.view()->pushLayoutState(*this);
LayoutObject* container = root.container();
FloatPoint absContentPoint = container->localToAbsolute(FloatPoint(), UseTransforms);
m_layoutOffset = LayoutSize(absContentPoint.x(), absContentPoint.y());
}
示例10: LayoutRect
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;
}
示例11: move
void TransformState::applyTransform(
const TransformationMatrix& transformFromContainer,
TransformAccumulation accumulate,
bool* wasClamped) {
if (wasClamped)
*wasClamped = false;
if (transformFromContainer.isIntegerTranslation()) {
move(LayoutSize(LayoutUnit(transformFromContainer.e()),
LayoutUnit(transformFromContainer.f())),
accumulate);
return;
}
applyAccumulatedOffset();
// If we have an accumulated transform from last time, multiply in this
// transform
if (m_accumulatedTransform) {
if (m_direction == ApplyTransformDirection)
m_accumulatedTransform = TransformationMatrix::create(
transformFromContainer * *m_accumulatedTransform);
else
m_accumulatedTransform->multiply(transformFromContainer);
} else if (accumulate == AccumulateTransform) {
// Make one if we started to accumulate
m_accumulatedTransform =
TransformationMatrix::create(transformFromContainer);
}
if (accumulate == FlattenTransform) {
if (m_forceAccumulatingTransform) {
m_accumulatedTransform->flattenTo2d();
} else {
const TransformationMatrix* finalTransform =
m_accumulatedTransform ? m_accumulatedTransform.get()
: &transformFromContainer;
flattenWithTransform(*finalTransform, wasClamped);
}
}
m_accumulatingTransform =
accumulate == AccumulateTransform || m_forceAccumulatingTransform;
}
示例12: ASSERT_ARG
const RenderObject* RenderView::pushMappingToContainer(const RenderBox* ancestorToStopAt, RenderGeometryMap& geometryMap) const
{
LayoutSize offset;
RenderObject* container = 0;
// If a container was specified, and was not 0 or the RenderView, then we
// should have found it by now unless we're traversing to a parent document.
ASSERT_ARG(ancestorToStopAt, !ancestorToStopAt || ancestorToStopAt == this || container);
if ((!ancestorToStopAt || container) && shouldUseTransformFromContainer(container)) {
TransformationMatrix t;
getTransformFromContainer(container, LayoutSize(), t);
geometryMap.push(this, t, false, false, true);
} else {
geometryMap.push(this, offset, false, false, false);
}
return container;
}
示例13: roundedIntSize
PassOwnPtr<Shape> ShapeOutsideInfo::createShapeForImage(StyleImage* styleImage, float shapeImageThreshold, WritingMode writingMode, float margin) const
{
const IntSize& imageSize = m_layoutBox.calculateImageIntrinsicDimensions(styleImage, roundedIntSize(m_referenceBoxLogicalSize), LayoutImage::ScaleByEffectiveZoom);
styleImage->setContainerSizeForLayoutObject(&m_layoutBox, imageSize, m_layoutBox.style()->effectiveZoom());
const LayoutRect& marginRect = getShapeImageMarginRect(m_layoutBox, m_referenceBoxLogicalSize);
const LayoutRect& imageRect = (m_layoutBox.isLayoutImage())
? toLayoutImage(m_layoutBox).replacedContentRect()
: LayoutRect(LayoutPoint(), LayoutSize(imageSize));
if (!isValidRasterShapeRect(marginRect) || !isValidRasterShapeRect(imageRect)) {
m_layoutBox.document().addConsoleMessage(ConsoleMessage::create(RenderingMessageSource, ErrorMessageLevel, "The shape-outside image is too large."));
return Shape::createEmptyRasterShape(writingMode, margin);
}
ASSERT(!styleImage->isPendingImage());
RefPtr<Image> image = styleImage->image(const_cast<LayoutBox*>(&m_layoutBox), imageSize);
return Shape::createRasterShape(image.get(), shapeImageThreshold, imageRect, marginRect, writingMode, margin);
}
示例14: paintRect
void EllipsisBoxPainter::paintEllipsis(const PaintInfo& paintInfo, const LayoutPoint& paintOffset, LayoutUnit lineTop, LayoutUnit lineBottom, const ComputedStyle& style)
{
bool haveSelection = !paintInfo.isPrinting() && paintInfo.phase != PaintPhaseTextClip && m_ellipsisBox.getSelectionState() != SelectionNone;
LayoutRect paintRect(m_ellipsisBox.logicalFrameRect());
if (haveSelection)
paintRect.unite(LayoutRect(m_ellipsisBox.selectionRect()));
m_ellipsisBox.logicalRectToPhysicalRect(paintRect);
paintRect.moveBy(paintOffset);
GraphicsContext& context = paintInfo.context;
DisplayItem::Type displayItemType = DisplayItem::paintPhaseToDrawingType(paintInfo.phase);
if (DrawingRecorder::useCachedDrawingIfPossible(context, m_ellipsisBox, displayItemType))
return;
DrawingRecorder recorder(context, m_ellipsisBox, displayItemType, FloatRect(paintRect));
LayoutPoint boxOrigin = m_ellipsisBox.locationIncludingFlipping();
boxOrigin.moveBy(paintOffset);
LayoutRect boxRect(boxOrigin, LayoutSize(m_ellipsisBox.logicalWidth(), m_ellipsisBox.virtualLogicalHeight()));
GraphicsContextStateSaver stateSaver(context);
if (!m_ellipsisBox.isHorizontal())
context.concatCTM(TextPainter::rotation(boxRect, TextPainter::Clockwise));
const Font& font = style.font();
if (haveSelection)
paintSelection(context, boxOrigin, style, font);
else if (paintInfo.phase == PaintPhaseSelection)
return;
TextPainter::Style textStyle = TextPainter::textPaintingStyle(m_ellipsisBox.getLineLayoutItem(), style, paintInfo);
if (haveSelection)
textStyle = TextPainter::selectionPaintingStyle(m_ellipsisBox.getLineLayoutItem(), true, paintInfo, textStyle);
TextRun textRun = constructTextRun(font, m_ellipsisBox.ellipsisStr(), style, TextRun::AllowTrailingExpansion);
LayoutPoint textOrigin(boxOrigin.x(), boxOrigin.y() + font.getFontMetrics().ascent());
TextPainter textPainter(context, font, textRun, textOrigin, boxRect, m_ellipsisBox.isHorizontal());
textPainter.paint(0, m_ellipsisBox.ellipsisStr().length(), m_ellipsisBox.ellipsisStr().length(), textStyle);
}
示例15: VisiblePosition
VisiblePosition LocalFrame::visiblePositionForPoint(const IntPoint& framePoint)
{
if (!contentRenderer() || !view() || !view()->didFirstLayout())
return VisiblePosition();
LayoutSize padding = LayoutSize();
HitTestResult result(framePoint, padding.height(), padding.width(), padding.height(), padding.width());
HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::Active);
contentRenderer()->hitTest(request, result);
Node* node = result.innerNonSharedNode();
if (!node)
return VisiblePosition();
RenderObject* renderer = node->renderer();
if (!renderer)
return VisiblePosition();
VisiblePosition visiblePos = VisiblePosition(renderer->positionForPoint(result.localPoint()));
if (visiblePos.isNull())
visiblePos = VisiblePosition(firstPositionInOrBeforeNode(node));
return visiblePos;
}