本文整理汇总了C++中LayoutPoint类的典型用法代码示例。如果您正苦于以下问题:C++ LayoutPoint类的具体用法?C++ LayoutPoint怎么用?C++ LayoutPoint使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了LayoutPoint类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: UIEventWithKeyState
MouseRelatedEvent::MouseRelatedEvent(const AtomicString& eventType, bool canBubble, bool cancelable, EventTarget* relatedTarget,
RawPtr<AbstractView> abstractView, int detail, const IntPoint& screenLocation,
const IntPoint& rootFrameLocation, const IntPoint& movementDelta, PlatformEvent::Modifiers modifiers,
double platformTimeStamp, PositionType positionType, InputDeviceCapabilities* sourceCapabilities)
: UIEventWithKeyState(eventType, canBubble, cancelable, relatedTarget, abstractView, detail, modifiers, platformTimeStamp, sourceCapabilities)
, m_screenLocation(screenLocation)
, m_movementDelta(movementDelta)
, m_positionType(positionType)
{
LayoutPoint adjustedPageLocation;
LayoutPoint scrollPosition;
LocalFrame* frame = view() && view()->isLocalDOMWindow() ? toLocalDOMWindow(view())->frame() : nullptr;
if (frame && hasPosition()) {
if (FrameView* frameView = frame->view()) {
scrollPosition = frameView->scrollPosition();
adjustedPageLocation = frameView->rootFrameToContents(rootFrameLocation);
float scaleFactor = 1 / frame->pageZoomFactor();
if (scaleFactor != 1.0f) {
adjustedPageLocation.scale(scaleFactor, scaleFactor);
scrollPosition.scale(scaleFactor, scaleFactor);
}
}
}
m_clientLocation = adjustedPageLocation - toLayoutSize(scrollPosition);
m_pageLocation = adjustedPageLocation;
// Set up initial values for coordinates.
// Correct values are computed lazily, see computeRelativePosition.
m_layerLocation = m_pageLocation;
m_offsetLocation = m_pageLocation;
computePageLocation();
m_hasCachedRelativePosition = false;
}
示例2: firstRootBox
VisiblePosition RenderSVGText::positionForPoint(const LayoutPoint& pointInContents, const RenderRegion* region)
{
RootInlineBox* rootBox = firstRootBox();
if (!rootBox)
return createVisiblePosition(0, DOWNSTREAM);
ASSERT(!rootBox->nextRootBox());
ASSERT(childrenInline());
InlineBox* closestBox = downcast<SVGRootInlineBox>(*rootBox).closestLeafChildForPosition(pointInContents);
if (!closestBox)
return createVisiblePosition(0, DOWNSTREAM);
return closestBox->renderer().positionForPoint(LayoutPoint(pointInContents.x(), closestBox->y()), region);
}
示例3: firstRootBox
PositionWithAffinity RenderSVGText::positionForPoint(const LayoutPoint& pointInContents)
{
RootInlineBox* rootBox = firstRootBox();
if (!rootBox)
return createPositionWithAffinity(0, DOWNSTREAM);
ASSERT(!rootBox->nextRootBox());
ASSERT(childrenInline());
InlineBox* closestBox = toSVGRootInlineBox(rootBox)->closestLeafChildForPosition(pointInContents);
if (!closestBox)
return createPositionWithAffinity(0, DOWNSTREAM);
return closestBox->renderer().positionForPoint(LayoutPoint(pointInContents.x(), closestBox->y()));
}
示例4: rangeIntersectsRect
bool RenderLineBoxList::rangeIntersectsRect(RenderBoxModelObject* renderer, LayoutUnit logicalTop, LayoutUnit logicalBottom, const LayoutRect& rect, const LayoutPoint& offset) const
{
RenderBox* block;
if (renderer->isBox())
block = toRenderBox(renderer);
else
block = renderer->containingBlock();
LayoutUnit physicalStart = block->flipForWritingMode(logicalTop);
LayoutUnit physicalEnd = block->flipForWritingMode(logicalBottom);
LayoutUnit physicalExtent = absoluteValue(physicalEnd - physicalStart);
physicalStart = min(physicalStart, physicalEnd);
if (renderer->style()->isHorizontalWritingMode()) {
physicalStart += offset.y();
if (physicalStart >= rect.maxY() || physicalStart + physicalExtent <= rect.y())
return false;
} else {
physicalStart += offset.x();
if (physicalStart >= rect.maxX() || physicalStart + physicalExtent <= rect.x())
return false;
}
return true;
}
示例5: contentWidth
void RenderEmbeddedObject::paintSnapshotImage(PaintInfo& paintInfo, const LayoutPoint& paintOffset, Image* image)
{
LayoutUnit cWidth = contentWidth();
LayoutUnit cHeight = contentHeight();
if (!cWidth || !cHeight)
return;
GraphicsContext* context = paintInfo.context;
LayoutSize contentSize(cWidth, cHeight);
LayoutPoint contentLocation = location() + paintOffset;
contentLocation.move(borderLeft() + paddingLeft(), borderTop() + paddingTop());
LayoutRect rect(contentLocation, contentSize);
IntRect alignedRect = snappedIntRect(rect);
if (alignedRect.width() <= 0 || alignedRect.height() <= 0)
return;
bool useLowQualityScaling = shouldPaintAtLowQuality(context, image, image, alignedRect.size());
ImageOrientationDescription orientationDescription(shouldRespectImageOrientation());
#if ENABLE(CSS_IMAGE_ORIENTATION)
orientationDescription.setImageOrientationEnum(style().imageOrientation());
#endif
context->drawImage(image, style().colorSpace(), alignedRect, ImagePaintingOptions(orientationDescription, useLowQualityScaling));
}
示例6: firstChild
void RenderFrameSet::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
{
if (paintInfo.phase != PaintPhaseForeground)
return;
RenderObject* child = firstChild();
if (!child)
return;
LayoutPoint adjustedPaintOffset = paintOffset + location();
size_t rows = m_rows.m_sizes.size();
size_t cols = m_cols.m_sizes.size();
LayoutUnit borderThickness = frameSet()->border();
LayoutUnit yPos = 0;
for (size_t r = 0; r < rows; r++) {
LayoutUnit xPos = 0;
for (size_t c = 0; c < cols; c++) {
child->paint(paintInfo, adjustedPaintOffset);
xPos += m_cols.m_sizes[c];
if (borderThickness && m_cols.m_allowBorder[c + 1]) {
paintColumnBorder(paintInfo, pixelSnappedIntRect(LayoutRect(adjustedPaintOffset.x() + xPos, adjustedPaintOffset.y() + yPos, borderThickness, height())));
xPos += borderThickness;
}
child = child->nextSibling();
if (!child)
return;
}
yPos += m_rows.m_sizes[r];
if (borderThickness && m_rows.m_allowBorder[r + 1]) {
paintRowBorder(paintInfo, pixelSnappedIntRect(LayoutRect(adjustedPaintOffset.x(), adjustedPaintOffset.y() + yPos, width(), borderThickness)));
yPos += borderThickness;
}
}
}
示例7: ASSERT
bool LineBoxList::hitTest(LineLayoutBoxModel layoutObject, HitTestResult& result, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, HitTestAction hitTestAction) const
{
if (hitTestAction != HitTestForeground)
return false;
ASSERT(layoutObject.isLayoutBlock() || (layoutObject.isLayoutInline() && layoutObject.hasLayer())); // The only way an inline could hit test like this is if it has a layer.
// If we have no lines then we have no work to do.
if (!firstLineBox())
return false;
LayoutPoint point = locationInContainer.point();
CullRect cullRect(firstLineBox()->isHorizontal() ?
IntRect(point.x(), point.y() - locationInContainer.topPadding(), 1, locationInContainer.topPadding() + locationInContainer.bottomPadding() + 1) :
IntRect(point.x() - locationInContainer.leftPadding(), point.y(), locationInContainer.rightPadding() + locationInContainer.leftPadding() + 1, 1));
if (!anyLineIntersectsRect(layoutObject, cullRect, accumulatedOffset))
return false;
// See if our root lines contain the point. If so, then we hit test
// them further. Note that boxes can easily overlap, so we can't make any assumptions
// based off positions of our first line box or our last line box.
for (InlineFlowBox* curr = lastLineBox(); curr; curr = curr->prevLineBox()) {
RootInlineBox& root = curr->root();
if (rangeIntersectsRect(layoutObject, curr->logicalTopVisualOverflow(root.lineTop()), curr->logicalBottomVisualOverflow(root.lineBottom()), cullRect, accumulatedOffset)) {
bool inside = curr->nodeAtPoint(result, locationInContainer, accumulatedOffset, root.lineTop(), root.lineBottom());
if (inside) {
layoutObject.updateHitTestResult(result, locationInContainer.point() - toLayoutSize(accumulatedOffset));
return true;
}
}
}
return false;
}
示例8: setRegionBoxesRegionStyle
void RenderRegion::paintReplaced(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
{
// Delegate painting of content in region to RenderFlowThread.
if (!m_flowThread || !isValid())
return;
if (Frame* frame = this->frame()) {
if (Page* page = frame->page())
page->addRelevantRepaintedObject(this, paintInfo.rect);
}
setRegionBoxesRegionStyle();
m_flowThread->paintIntoRegion(paintInfo, this, LayoutPoint(paintOffset.x() + borderLeft() + paddingLeft(), paintOffset.y() + borderTop() + paddingTop()));
restoreRegionBoxesOriginalStyle();
}
示例9: firstRootBox
VisiblePosition RenderSVGText::positionForPoint(const LayoutPoint& pointInContents, const RenderRegion* region)
{
RootInlineBox* rootBox = firstRootBox();
if (!rootBox)
return createVisiblePosition(0, DOWNSTREAM);
ASSERT_WITH_SECURITY_IMPLICATION(rootBox->isSVGRootInlineBox());
ASSERT(!rootBox->nextRootBox());
ASSERT(childrenInline());
InlineBox* closestBox = toSVGRootInlineBox(rootBox)->closestLeafChildForPosition(pointInContents);
if (!closestBox)
return createVisiblePosition(0, DOWNSTREAM);
return closestBox->renderer().positionForPoint(LayoutPoint(pointInContents.x(), closestBox->y()), region);
}
示例10: firstRootBox
VisiblePosition RenderSVGText::positionForPoint(const LayoutPoint& pointInContents)
{
RootInlineBox* rootBox = firstRootBox();
if (!rootBox)
return createVisiblePosition(0, DOWNSTREAM);
ASSERT(rootBox->isSVGRootInlineBox());
ASSERT(!rootBox->nextRootBox());
ASSERT(childrenInline());
InlineBox* closestBox = static_cast<SVGRootInlineBox*>(rootBox)->closestLeafChildForPosition(pointInContents);
if (!closestBox)
return createVisiblePosition(0, DOWNSTREAM);
return closestBox->renderer()->positionForPoint(LayoutPoint(pointInContents.x(), closestBox->y()));
}
示例11: toHTMLInputElement
void LayoutSliderContainer::layout()
{
HTMLInputElement* input = toHTMLInputElement(node()->shadowHost());
bool isVertical = hasVerticalAppearance(input);
mutableStyleRef().setFlexDirection(isVertical ? FlowColumn : FlowRow);
TextDirection oldTextDirection = style()->direction();
if (isVertical) {
// FIXME: Work around rounding issues in RTL vertical sliders. We want them to
// render identically to LTR vertical sliders. We can remove this work around when
// subpixel rendering is enabled on all ports.
mutableStyleRef().setDirection(LTR);
}
Element* thumbElement = input->userAgentShadowRoot()->getElementById(ShadowElementNames::sliderThumb());
Element* trackElement = input->userAgentShadowRoot()->getElementById(ShadowElementNames::sliderTrack());
LayoutBox* thumb = thumbElement ? thumbElement->layoutBox() : 0;
LayoutBox* track = trackElement ? trackElement->layoutBox() : 0;
SubtreeLayoutScope layoutScope(*this);
// Force a layout to reset the position of the thumb so the code below doesn't move the thumb to the wrong place.
// FIXME: Make a custom layout class for the track and move the thumb positioning code there.
if (track)
layoutScope.setChildNeedsLayout(track);
LayoutFlexibleBox::layout();
mutableStyleRef().setDirection(oldTextDirection);
// These should always exist, unless someone mutates the shadow DOM (e.g., in the inspector).
if (!thumb || !track)
return;
double percentageOffset = sliderPosition(input).toDouble();
LayoutUnit availableExtent = isVertical ? track->contentHeight() : track->contentWidth();
availableExtent -= isVertical ? thumb->size().height() : thumb->size().width();
LayoutUnit offset = percentageOffset * availableExtent;
LayoutPoint thumbLocation = thumb->location();
if (isVertical)
thumbLocation.setY(thumbLocation.y() + track->contentHeight() - thumb->size().height() - offset);
else if (style()->isLeftToRightDirection())
thumbLocation.setX(thumbLocation.x() + offset);
else
thumbLocation.setX(thumbLocation.x() - offset);
thumb->setLocation(thumbLocation);
// We need one-off invalidation code here because painting of the timeline element does not go through style.
// Instead it has a custom implementation in C++ code.
// Therefore the style system cannot understand when it needs to be paint invalidated.
setShouldDoFullPaintInvalidation();
}
示例12: LayoutPoint
LayoutPoint InlineBox::logicalPositionToPhysicalPoint(const LayoutPoint& point, const LayoutSize& size) const
{
if (!UNLIKELY(lineLayoutItem().hasFlippedBlocksWritingMode()))
return LayoutPoint(point.x(), point.y());
LayoutBlockFlow& block = root().block();
if (block.style()->isHorizontalWritingMode())
return LayoutPoint(point.x(), block.size().height() - size.height() - point.y());
return LayoutPoint(block.size().width() - size.width() - point.x(), point.y());
}
示例13: distanceDataForNode
void distanceDataForNode(FocusType type, const FocusCandidate& current, FocusCandidate& candidate)
{
if (areElementsOnSameLine(current, candidate)) {
if ((type == FocusTypeUp && current.rect.y() > candidate.rect.y()) || (type == FocusTypeDown && candidate.rect.y() > current.rect.y())) {
candidate.distance = 0;
candidate.alignment = Full;
return;
}
}
LayoutRect nodeRect = candidate.rect;
LayoutRect currentRect = current.rect;
deflateIfOverlapped(currentRect, nodeRect);
if (!isRectInDirection(type, currentRect, nodeRect))
return;
LayoutPoint exitPoint;
LayoutPoint entryPoint;
entryAndExitPointsForDirection(type, currentRect, nodeRect, exitPoint, entryPoint);
LayoutUnit xAxis = exitPoint.x() - entryPoint.x();
LayoutUnit yAxis = exitPoint.y() - entryPoint.y();
LayoutUnit navigationAxisDistance;
LayoutUnit orthogonalAxisDistance;
switch (type) {
case FocusTypeLeft:
case FocusTypeRight:
navigationAxisDistance = xAxis.abs();
orthogonalAxisDistance = yAxis.abs();
break;
case FocusTypeUp:
case FocusTypeDown:
navigationAxisDistance = yAxis.abs();
orthogonalAxisDistance = xAxis.abs();
break;
default:
ASSERT_NOT_REACHED();
return;
}
double euclidianDistancePow2 = (xAxis * xAxis + yAxis * yAxis).toDouble();
LayoutRect intersectionRect = intersection(currentRect, nodeRect);
double overlap = (intersectionRect.width() * intersectionRect.height()).toDouble();
// Distance calculation is based on http://www.w3.org/TR/WICD/#focus-handling
candidate.distance = sqrt(euclidianDistancePow2) + navigationAxisDistance+ orthogonalAxisDistance * 2 - sqrt(overlap);
LayoutSize viewSize = candidate.visibleNode->document().page()->deprecatedLocalMainFrame()->view()->visibleContentRect().size();
candidate.alignment = alignmentForRects(type, currentRect, nodeRect, viewSize);
}
示例14: paintReplaced
void ImagePainter::paintReplaced(const PaintInfo& paintInfo, const LayoutPoint& paintOffset)
{
LayoutUnit cWidth = m_layoutImage.contentWidth();
LayoutUnit cHeight = m_layoutImage.contentHeight();
GraphicsContext* context = paintInfo.context;
if (!m_layoutImage.imageResource()->hasImage()) {
if (paintInfo.phase == PaintPhaseSelection)
return;
if (cWidth > 2 && cHeight > 2) {
// Draw an outline rect where the image should be.
IntRect paintRect = pixelSnappedIntRect(LayoutRect(paintOffset.x() + m_layoutImage.borderLeft() + m_layoutImage.paddingLeft(), paintOffset.y() + m_layoutImage.borderTop() + m_layoutImage.paddingTop(), cWidth, cHeight));
LayoutObjectDrawingRecorder drawingRecorder(*context, m_layoutImage, paintInfo.phase, paintRect);
if (drawingRecorder.canUseCachedDrawing())
return;
context->setStrokeStyle(SolidStroke);
context->setStrokeColor(Color::lightGray);
context->setFillColor(Color::transparent);
context->drawRect(paintRect);
}
} else if (cWidth > 0 && cHeight > 0) {
LayoutRect contentRect = m_layoutImage.contentBoxRect();
contentRect.moveBy(paintOffset);
LayoutRect paintRect = m_layoutImage.replacedContentRect();
paintRect.moveBy(paintOffset);
LayoutObjectDrawingRecorder drawingRecorder(*context, m_layoutImage, paintInfo.phase, contentRect);
if (drawingRecorder.canUseCachedDrawing())
return;
bool clip = !contentRect.contains(paintRect);
if (clip) {
context->save();
context->clip(contentRect);
}
paintIntoRect(context, paintRect);
if (clip)
context->restore();
}
}
示例15: positionForPoint
PositionWithAffinity RenderReplaced::positionForPoint(const LayoutPoint& point)
{
// FIXME: This code is buggy if the replaced element is relative positioned.
InlineBox* box = inlineBoxWrapper();
RootInlineBox* rootBox = box ? &box->root() : 0;
LayoutUnit top = rootBox ? rootBox->selectionTop() : logicalTop();
LayoutUnit bottom = rootBox ? rootBox->selectionBottom() : logicalBottom();
LayoutUnit blockDirectionPosition = point.y() + y();
if (blockDirectionPosition < top)
return createPositionWithAffinity(caretMinOffset(), DOWNSTREAM); // coordinates are above
if (blockDirectionPosition >= bottom)
return createPositionWithAffinity(caretMaxOffset(), DOWNSTREAM); // coordinates are below
return RenderBox::positionForPoint(point);
}