本文整理汇总了C++中LayoutPoint::x方法的典型用法代码示例。如果您正苦于以下问题:C++ LayoutPoint::x方法的具体用法?C++ LayoutPoint::x怎么用?C++ LayoutPoint::x使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LayoutPoint
的用法示例。
在下文中一共展示了LayoutPoint::x方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
FloatPoint::FloatPoint(const LayoutPoint& p)
: m_x(p.x().toFloat())
, m_y(p.y().toFloat())
{
}
示例2: moveBy
void FloatPoint::moveBy(const LayoutPoint& point)
{
m_x += point.x();
m_y += point.y();
}
示例3: paintOutlineForLine
void InlinePainter::paintOutlineForLine(GraphicsContext* graphicsContext, const LayoutPoint& paintOffset,
const LayoutRect& lastline, const LayoutRect& thisline, const LayoutRect& nextline, const Color outlineColor)
{
const ComputedStyle& styleToUse = m_layoutInline.styleRef();
int outlineWidth = styleToUse.outlineWidth();
EBorderStyle outlineStyle = styleToUse.outlineStyle();
bool antialias = BoxPainter::shouldAntialiasLines(graphicsContext);
int offset = m_layoutInline.style()->outlineOffset();
LayoutRect box(LayoutPoint(paintOffset.x() + thisline.x() - offset, paintOffset.y() + thisline.y() - offset),
LayoutSize(thisline.width() + offset, thisline.height() + offset));
IntRect pixelSnappedBox = pixelSnappedIntRect(box);
if (pixelSnappedBox.width() < 0 || pixelSnappedBox.height() < 0)
return;
// Note that we use IntRect below for working with solely x/width values, simplifying logic at cost of a bit of memory.
IntRect pixelSnappedLastLine = pixelSnappedIntRect(paintOffset.x() + lastline.x() - offset, 0, lastline.width() + offset, 0);
IntRect pixelSnappedNextLine = pixelSnappedIntRect(paintOffset.x() + nextline.x() - offset, 0, nextline.width() + offset, 0);
const int fallbackMaxOutlineX = std::numeric_limits<int>::max();
const int fallbackMinOutlineX = std::numeric_limits<int>::min();
// left edge
ObjectPainter::drawLineForBoxSide(graphicsContext,
pixelSnappedBox.x() - outlineWidth,
pixelSnappedBox.y() - (lastline.isEmpty() || thisline.x() < lastline.x() || (lastline.maxX() - 1) <= thisline.x() ? outlineWidth : 0),
pixelSnappedBox.x(),
pixelSnappedBox.maxY() + (nextline.isEmpty() || thisline.x() <= nextline.x() || (nextline.maxX() - 1) <= thisline.x() ? outlineWidth : 0),
BSLeft,
outlineColor, outlineStyle,
(lastline.isEmpty() || thisline.x() < lastline.x() || (lastline.maxX() - 1) <= thisline.x() ? outlineWidth : -outlineWidth),
(nextline.isEmpty() || thisline.x() <= nextline.x() || (nextline.maxX() - 1) <= thisline.x() ? outlineWidth : -outlineWidth),
antialias);
// right edge
ObjectPainter::drawLineForBoxSide(graphicsContext,
pixelSnappedBox.maxX(),
pixelSnappedBox.y() - (lastline.isEmpty() || lastline.maxX() < thisline.maxX() || (thisline.maxX() - 1) <= lastline.x() ? outlineWidth : 0),
pixelSnappedBox.maxX() + outlineWidth,
pixelSnappedBox.maxY() + (nextline.isEmpty() || nextline.maxX() <= thisline.maxX() || (thisline.maxX() - 1) <= nextline.x() ? outlineWidth : 0),
BSRight,
outlineColor, outlineStyle,
(lastline.isEmpty() || lastline.maxX() < thisline.maxX() || (thisline.maxX() - 1) <= lastline.x() ? outlineWidth : -outlineWidth),
(nextline.isEmpty() || nextline.maxX() <= thisline.maxX() || (thisline.maxX() - 1) <= nextline.x() ? outlineWidth : -outlineWidth),
antialias);
// upper edge
if (thisline.x() < lastline.x()) {
ObjectPainter::drawLineForBoxSide(graphicsContext,
pixelSnappedBox.x() - outlineWidth,
pixelSnappedBox.y() - outlineWidth,
std::min(pixelSnappedBox.maxX() + outlineWidth, (lastline.isEmpty() ? fallbackMaxOutlineX : pixelSnappedLastLine.x())),
pixelSnappedBox.y(),
BSTop, outlineColor, outlineStyle,
outlineWidth,
(!lastline.isEmpty() && paintOffset.x() + lastline.x() + 1 < pixelSnappedBox.maxX() + outlineWidth) ? -outlineWidth : outlineWidth,
antialias);
}
if (lastline.maxX() < thisline.maxX()) {
ObjectPainter::drawLineForBoxSide(graphicsContext,
std::max(lastline.isEmpty() ? fallbackMinOutlineX : pixelSnappedLastLine.maxX(), pixelSnappedBox.x() - outlineWidth),
pixelSnappedBox.y() - outlineWidth,
pixelSnappedBox.maxX() + outlineWidth,
pixelSnappedBox.y(),
BSTop, outlineColor, outlineStyle,
(!lastline.isEmpty() && pixelSnappedBox.x() - outlineWidth < paintOffset.x() + lastline.maxX()) ? -outlineWidth : outlineWidth,
outlineWidth, antialias);
}
if (thisline.x() == thisline.maxX()) {
ObjectPainter::drawLineForBoxSide(graphicsContext,
pixelSnappedBox.x() - outlineWidth,
pixelSnappedBox.y() - outlineWidth,
pixelSnappedBox.maxX() + outlineWidth,
pixelSnappedBox.y(),
BSTop, outlineColor, outlineStyle,
outlineWidth,
outlineWidth,
antialias);
}
// lower edge
if (thisline.x() < nextline.x()) {
ObjectPainter::drawLineForBoxSide(graphicsContext,
pixelSnappedBox.x() - outlineWidth,
pixelSnappedBox.maxY(),
std::min(pixelSnappedBox.maxX() + outlineWidth, !nextline.isEmpty() ? pixelSnappedNextLine.x() + 1 : fallbackMaxOutlineX),
pixelSnappedBox.maxY() + outlineWidth,
BSBottom, outlineColor, outlineStyle,
outlineWidth,
(!nextline.isEmpty() && paintOffset.x() + nextline.x() + 1 < pixelSnappedBox.maxX() + outlineWidth) ? -outlineWidth : outlineWidth,
antialias);
}
if (nextline.maxX() < thisline.maxX()) {
ObjectPainter::drawLineForBoxSide(graphicsContext,
std::max(!nextline.isEmpty() ? pixelSnappedNextLine.maxX() : fallbackMinOutlineX, pixelSnappedBox.x() - outlineWidth),
pixelSnappedBox.maxY(),
//.........这里部分代码省略.........
示例4: nodeAtPoint
// Hit Testing
bool RenderRegion::nodeAtPoint(const HitTestRequest& request, HitTestResult& result, const LayoutPoint& pointInContainer, const LayoutPoint& accumulatedOffset, HitTestAction action)
{
if (!isValid())
return false;
LayoutPoint adjustedLocation = accumulatedOffset + location();
// Check our bounds next. For this purpose always assume that we can only be hit in the
// foreground phase (which is true for replaced elements like images).
LayoutRect boundsRect = borderBoxRectInRegion(result.region());
boundsRect.moveBy(adjustedLocation);
if (visibleToHitTesting() && action == HitTestForeground && boundsRect.intersects(result.rectForPoint(pointInContainer))) {
// Check the contents of the RenderFlowThread.
if (m_flowThread && m_flowThread->hitTestRegion(this, request, result, pointInContainer, LayoutPoint(adjustedLocation.x() + borderLeft() + paddingLeft(), adjustedLocation.y() + borderTop() + paddingTop())))
return true;
updateHitTestResult(result, pointInContainer - toLayoutSize(adjustedLocation));
if (!result.addNodeToRectBasedTestResult(node(), pointInContainer, boundsRect))
return true;
}
return false;
}
示例5: paintReplaced
void RenderImage::paintReplaced(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
{
LayoutUnit cWidth = contentWidth();
LayoutUnit cHeight = contentHeight();
LayoutUnit leftBorder = borderLeft();
LayoutUnit topBorder = borderTop();
LayoutUnit leftPad = paddingLeft();
LayoutUnit topPad = paddingTop();
GraphicsContext& context = paintInfo.context();
float deviceScaleFactor = document().deviceScaleFactor();
Page* page = frame().page();
if (!imageResource().hasImage() || imageResource().errorOccurred()) {
if (paintInfo.phase == PaintPhaseSelection)
return;
if (page && paintInfo.phase == PaintPhaseForeground)
page->addRelevantUnpaintedObject(this, visualOverflowRect());
if (cWidth > 2 && cHeight > 2) {
LayoutUnit borderWidth = LayoutUnit(1 / deviceScaleFactor);
// Draw an outline rect where the image should be.
context.setStrokeStyle(SolidStroke);
context.setStrokeColor(Color::lightGray, style().colorSpace());
context.setFillColor(Color::transparent, style().colorSpace());
context.drawRect(snapRectToDevicePixels(LayoutRect(paintOffset.x() + leftBorder + leftPad, paintOffset.y() + topBorder + topPad, cWidth, cHeight), deviceScaleFactor), borderWidth);
bool errorPictureDrawn = false;
LayoutSize imageOffset;
// When calculating the usable dimensions, exclude the pixels of
// the ouline rect so the error image/alt text doesn't draw on it.
LayoutUnit usableWidth = cWidth - 2 * borderWidth;
LayoutUnit usableHeight = cHeight - 2 * borderWidth;
RefPtr<Image> image = imageResource().image();
if (imageResource().errorOccurred() && !image->isNull() && usableWidth >= image->width() && usableHeight >= image->height()) {
// Call brokenImage() explicitly to ensure we get the broken image icon at the appropriate resolution.
std::pair<Image*, float> brokenImageAndImageScaleFactor = imageResource().cachedImage()->brokenImage(document().deviceScaleFactor());
image = brokenImageAndImageScaleFactor.first;
FloatSize imageSize = image->size();
imageSize.scale(1 / brokenImageAndImageScaleFactor.second);
// Center the error image, accounting for border and padding.
LayoutUnit centerX = (usableWidth - imageSize.width()) / 2;
if (centerX < 0)
centerX = 0;
LayoutUnit centerY = (usableHeight - imageSize.height()) / 2;
if (centerY < 0)
centerY = 0;
imageOffset = LayoutSize(leftBorder + leftPad + centerX + borderWidth, topBorder + topPad + centerY + borderWidth);
ImageOrientationDescription orientationDescription(shouldRespectImageOrientation());
#if ENABLE(CSS_IMAGE_ORIENTATION)
orientationDescription.setImageOrientationEnum(style().imageOrientation());
#endif
context.drawImage(*image, style().colorSpace(), snapRectToDevicePixels(LayoutRect(paintOffset + imageOffset, imageSize), deviceScaleFactor), orientationDescription);
errorPictureDrawn = true;
}
if (!m_altText.isEmpty()) {
String text = document().displayStringModifiedByEncoding(m_altText);
context.setFillColor(style().visitedDependentColor(CSSPropertyColor), style().colorSpace());
const FontCascade& font = style().fontCascade();
const FontMetrics& fontMetrics = font.fontMetrics();
LayoutUnit ascent = fontMetrics.ascent();
LayoutPoint altTextOffset = paintOffset;
altTextOffset.move(leftBorder + leftPad + (paddingWidth / 2) - borderWidth, topBorder + topPad + ascent + (paddingHeight / 2) - borderWidth);
// Only draw the alt text if it'll fit within the content box,
// and only if it fits above the error image.
TextRun textRun = RenderBlock::constructTextRun(this, font, text, style());
LayoutUnit textWidth = font.width(textRun);
if (errorPictureDrawn) {
if (usableWidth >= textWidth && fontMetrics.height() <= imageOffset.height())
context.drawText(font, textRun, altTextOffset);
} else if (usableWidth >= textWidth && usableHeight >= fontMetrics.height())
context.drawText(font, textRun, altTextOffset);
}
}
} else if (imageResource().hasImage() && cWidth > 0 && cHeight > 0) {
RefPtr<Image> img = imageResource().image(cWidth, cHeight);
if (!img || img->isNull()) {
if (page && paintInfo.phase == PaintPhaseForeground)
page->addRelevantUnpaintedObject(this, visualOverflowRect());
return;
}
LayoutRect contentBoxRect = this->contentBoxRect();
contentBoxRect.moveBy(paintOffset);
LayoutRect replacedContentRect = this->replacedContentRect(intrinsicSize());
replacedContentRect.moveBy(paintOffset);
bool clip = !contentBoxRect.contains(replacedContentRect);
GraphicsContextStateSaver stateSaver(context, clip);
if (clip)
context.clip(contentBoxRect);
paintIntoRect(context, snapRectToDevicePixels(replacedContentRect, deviceScaleFactor));
//.........这里部分代码省略.........
示例6: paint
void EllipsisBox::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset, LayoutUnit lineTop, LayoutUnit lineBottom)
{
GraphicsContext* context = paintInfo.context;
RenderStyle* style = m_renderer->style(isFirstLineStyle());
const Font& font = style->font();
FloatPoint boxOrigin = locationIncludingFlipping();
LayoutPoint adjustedPaintOffset = paintOffset;
if (!isHorizontal())
adjustedPaintOffset.move(0, -virtualLogicalHeight());
boxOrigin.move(adjustedPaintOffset.x(), adjustedPaintOffset.y());
FloatRect boxRect(boxOrigin, LayoutSize(logicalWidth(), virtualLogicalHeight()));
GraphicsContextStateSaver stateSaver(*context);
if (!isHorizontal())
context->concatCTM(InlineTextBox::rotation(boxRect, InlineTextBox::Clockwise));
FloatPoint textOrigin = FloatPoint(boxOrigin.x(), boxOrigin.y() + font.fontMetrics().ascent());
Color styleTextColor = m_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.isValid() && foreground != styleTextColor)
context->setFillColor(foreground);
}
// Text shadows are disabled when printing. http://crbug.com/258321
const ShadowList* shadowList = context->printing() ? 0 : style->textShadow();
bool hasShadow = shadowList;
if (hasShadow) {
DrawLooper drawLooper;
for (size_t i = shadowList->shadows().size(); i--; ) {
const ShadowData& shadow = shadowList->shadows()[i];
int shadowX = isHorizontal() ? shadow.x() : shadow.y();
int shadowY = isHorizontal() ? shadow.y() : -shadow.x();
FloatSize offset(shadowX, shadowY);
drawLooper.addShadow(offset, shadow.blur(), m_renderer->resolveColor(shadow.color()),
DrawLooper::ShadowRespectsTransforms, DrawLooper::ShadowIgnoresAlpha);
}
drawLooper.addUnmodifiedContent();
context->setDrawLooper(drawLooper);
}
// FIXME: Why is this always LTR? Fix by passing correct text run flags below.
TextRun textRun = RenderBlockFlow::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);
}
示例7: localToRepaintContainerTransform
AffineTransform RenderSVGRoot::localToRepaintContainerTransform(const LayoutPoint& parentOriginInContainer) const
{
return AffineTransform::translation(parentOriginInContainer.x(), parentOriginInContainer.y()) * localToParentTransform();
}
示例8:
DoublePoint::DoublePoint(const LayoutPoint& p)
: m_x(p.x().toDouble())
, m_y(p.y().toDouble())
{
}
示例9: paint
void EllipsisBox::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset, LayoutUnit lineTop, LayoutUnit lineBottom)
{
GraphicsContext* context = paintInfo.context;
RenderStyle* style = m_renderer->style(isFirstLineStyle());
Color textColor = style->visitedDependentColor(CSSPropertyWebkitTextFillColor);
if (textColor != context->fillColor())
context->setFillColor(textColor, style->colorSpace());
bool setShadow = false;
if (style->textShadow()) {
context->setShadow(LayoutSize(style->textShadow()->x(), style->textShadow()->y()),
style->textShadow()->radius(), style->textShadow()->color(), style->colorSpace());
setShadow = true;
}
const Font& font = style->font();
if (selectionState() != RenderObject::SelectionNone) {
paintSelection(context, paintOffset, style, font);
// Select the correct color for painting the text.
Color foreground = paintInfo.forceBlackText() ? Color::black : renderer()->selectionForegroundColor();
if (foreground.isValid() && foreground != textColor)
context->setFillColor(foreground, style->colorSpace());
}
// FIXME: Why is this always LTR? Fix by passing correct text run flags below.
context->drawText(font, RenderBlock::constructTextRun(renderer(), font, m_str, style, TextRun::AllowTrailingExpansion), LayoutPoint(x() + paintOffset.x(), y() + paintOffset.y() + style->fontMetrics().ascent()));
// Restore the regular fill color.
if (textColor != context->fillColor())
context->setFillColor(textColor, style->colorSpace());
if (setShadow)
context->clearShadow();
paintMarkupBox(paintInfo, paintOffset, lineTop, lineBottom, style);
}
示例10: paint
void RenderWidget::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
{
if (!shouldPaint(paintInfo, paintOffset))
return;
LayoutPoint adjustedPaintOffset = paintOffset + location();
if (hasBoxDecorations() && (paintInfo.phase == PaintPhaseForeground || paintInfo.phase == PaintPhaseSelection))
paintBoxDecorations(paintInfo, adjustedPaintOffset);
if (paintInfo.phase == PaintPhaseMask) {
paintMask(paintInfo, adjustedPaintOffset);
return;
}
if ((paintInfo.phase == PaintPhaseOutline || paintInfo.phase == PaintPhaseSelfOutline) && hasOutline())
paintOutline(paintInfo.context, LayoutRect(adjustedPaintOffset, size()));
if (!m_frameView || paintInfo.phase != PaintPhaseForeground)
return;
#if PLATFORM(MAC)
if (style()->highlight() != nullAtom && !paintInfo.context->paintingDisabled())
paintCustomHighlight(paintOffset, style()->highlight(), true);
#endif
if (style()->hasBorderRadius()) {
LayoutRect borderRect = LayoutRect(adjustedPaintOffset, size());
if (borderRect.isEmpty())
return;
// Push a clip if we have a border radius, since we want to round the foreground content that gets painted.
paintInfo.context->save();
RoundedRect roundedInnerRect = style()->getRoundedInnerBorderFor(borderRect,
paddingTop() + borderTop(), paddingBottom() + borderBottom(), paddingLeft() + borderLeft(), paddingRight() + borderRight(), true, true);
clipRoundedInnerRect(paintInfo.context, borderRect, roundedInnerRect);
}
if (m_widget) {
// Tell the widget to paint now. This is the only time the widget is allowed
// to paint itself. That way it will composite properly with z-indexed layers.
IntPoint widgetLocation = m_widget->frameRect().location();
IntPoint paintLocation(roundToInt(adjustedPaintOffset.x() + borderLeft() + paddingLeft()),
roundToInt(adjustedPaintOffset.y() + borderTop() + paddingTop()));
IntRect paintRect = paintInfo.rect;
IntSize widgetPaintOffset = paintLocation - widgetLocation;
// When painting widgets into compositing layers, tx and ty are relative to the enclosing compositing layer,
// not the root. In this case, shift the CTM and adjust the paintRect to be root-relative to fix plug-in drawing.
if (!widgetPaintOffset.isZero()) {
paintInfo.context->translate(widgetPaintOffset);
paintRect.move(-widgetPaintOffset);
}
m_widget->paint(paintInfo.context, paintRect);
if (!widgetPaintOffset.isZero())
paintInfo.context->translate(-widgetPaintOffset);
if (m_widget->isFrameView()) {
FrameView* frameView = static_cast<FrameView*>(m_widget.get());
bool runOverlapTests = !frameView->useSlowRepaintsIfNotOverlapped() || frameView->hasCompositedContentIncludingDescendants();
if (paintInfo.overlapTestRequests && runOverlapTests) {
ASSERT(!paintInfo.overlapTestRequests->contains(this));
paintInfo.overlapTestRequests->set(this, m_widget->frameRect());
}
}
}
if (style()->hasBorderRadius())
paintInfo.context->restore();
// Paint a partially transparent wash over selected widgets.
if (isSelected() && !document()->printing()) {
// FIXME: selectionRect() is in absolute, not painting coordinates.
paintInfo.context->fillRect(pixelSnappedIntRect(selectionRect()), selectionBackgroundColor(), style()->colorSpace());
}
if (hasLayer() && layer()->canResize())
layer()->paintResizer(paintInfo.context, roundedIntPoint(adjustedPaintOffset), paintInfo.rect);
}
示例11: controlClipRect
LayoutRect RenderButton::controlClipRect(const LayoutPoint& additionalOffset) const
{
// Clip to the padding box to at least give content the extra padding space.
return LayoutRect(additionalOffset.x() + borderLeft(), additionalOffset.y() + borderTop(), width() - borderLeft() - borderRight(), height() - borderTop() - borderBottom());
}
示例12: columnIndexAtVisualPoint
unsigned MultiColumnFragmentainerGroup::columnIndexAtVisualPoint(const LayoutPoint& visualPoint) const
{
bool isColumnProgressionInline = m_columnSet.multiColumnFlowThread()->progressionIsInline();
bool isHorizontalWritingMode = m_columnSet.isHorizontalWritingMode();
LayoutUnit columnLengthInColumnProgressionDirection = isColumnProgressionInline ? m_columnSet.pageLogicalWidth() : logicalHeight();
LayoutUnit offsetInColumnProgressionDirection = isHorizontalWritingMode == isColumnProgressionInline ? visualPoint.x() : visualPoint.y();
if (!m_columnSet.style()->isLeftToRightDirection() && isColumnProgressionInline)
offsetInColumnProgressionDirection = m_columnSet.logicalWidth() - offsetInColumnProgressionDirection;
LayoutUnit columnGap = m_columnSet.columnGap();
if (columnLengthInColumnProgressionDirection + columnGap <= 0)
return 0;
// Column boundaries are in the middle of the column gap.
int index = (offsetInColumnProgressionDirection + columnGap / 2) / (columnLengthInColumnProgressionDirection + columnGap);
if (index < 0)
return 0;
return std::min(unsigned(index), actualColumnCount() - 1);
}