本文整理汇总了C++中LayoutRect::contains方法的典型用法代码示例。如果您正苦于以下问题:C++ LayoutRect::contains方法的具体用法?C++ LayoutRect::contains怎么用?C++ LayoutRect::contains使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LayoutRect
的用法示例。
在下文中一共展示了LayoutRect::contains方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: deflateIfOverlapped
static void deflateIfOverlapped(LayoutRect& a, LayoutRect& b)
{
if (!a.intersects(b) || a.contains(b) || b.contains(a))
return;
LayoutUnit deflateFactor = -fudgeFactor();
// Avoid negative width or height values.
if ((a.width() + 2 * deflateFactor > 0) && (a.height() + 2 * deflateFactor > 0))
a.inflate(deflateFactor);
if ((b.width() + 2 * deflateFactor > 0) && (b.height() + 2 * deflateFactor > 0))
b.inflate(deflateFactor);
}
示例2: elementAccessibilityHitTest
AccessibilityObject* AccessibilityListBox::elementAccessibilityHitTest(const LayoutPoint& point) const
{
// the internal HTMLSelectElement methods for returning a listbox option at a point
// ignore optgroup elements.
if (!m_renderer)
return 0;
Node* node = m_renderer->node();
if (!node)
return 0;
LayoutRect parentRect = boundingBoxRect();
AccessibilityObject* listBoxOption = 0;
unsigned length = m_children.size();
for (unsigned i = 0; i < length; i++) {
LayoutRect rect = toRenderListBox(m_renderer)->itemBoundingBoxRect(parentRect.location(), i);
// The cast to HTMLElement below is safe because the only other possible listItem type
// would be a WMLElement, but WML builds don't use accessibility features at all.
if (rect.contains(point)) {
listBoxOption = m_children[i].get();
break;
}
}
if (listBoxOption && !listBoxOption->accessibilityIsIgnored())
return listBoxOption;
return axObjectCache()->getOrCreate(m_renderer);
}
示例3: nodeFromPoint
Node* TreeScope::nodeFromPoint(const LayoutPoint& clientPoint, LayoutPoint* localPoint)
{
auto* frame = documentScope().frame();
auto* view = documentScope().view();
if (!frame || !view)
return nullptr;
float scaleFactor = frame->pageZoomFactor() * frame->frameScaleFactor();
LayoutPoint contentsPoint = clientPoint;
contentsPoint.scale(scaleFactor);
contentsPoint.moveBy(view->contentsScrollPosition());
LayoutRect visibleRect;
#if PLATFORM(IOS)
visibleRect = view->unobscuredContentRect();
#else
visibleRect = view->visibleContentRect();
#endif
if (!visibleRect.contains(contentsPoint))
return nullptr;
HitTestResult result(contentsPoint);
documentScope().renderView()->hitTest(HitTestRequest(), result);
if (localPoint)
*localPoint = result.localPoint();
return result.innerNode();
}
示例4: hitTestFlowThreadPortionInRegion
bool RenderFlowThread::hitTestFlowThreadPortionInRegion(RenderRegion* region, LayoutRect flowThreadPortionRect, LayoutRect flowThreadPortionOverflowRect, const HitTestRequest& request, HitTestResult& result, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset) const
{
LayoutRect regionClippingRect = computeRegionClippingRect(accumulatedOffset, flowThreadPortionRect, flowThreadPortionOverflowRect);
if (!regionClippingRect.contains(locationInContainer.point()))
return false;
LayoutSize renderFlowThreadOffset;
if (style()->isFlippedBlocksWritingMode()) {
LayoutRect flippedFlowThreadPortionRect(flowThreadPortionRect);
flipForWritingMode(flippedFlowThreadPortionRect);
renderFlowThreadOffset = accumulatedOffset - flippedFlowThreadPortionRect.location();
} else
renderFlowThreadOffset = accumulatedOffset - flowThreadPortionRect.location();
// Always ignore clipping, since the RenderFlowThread has nothing to do with the bounds of the FrameView.
HitTestRequest newRequest(request.type() | HitTestRequest::IgnoreClipping);
// Make a new temporary HitTestLocation in the new region.
HitTestLocation newHitTestLocation(locationInContainer, -renderFlowThreadOffset, region);
bool isPointInsideFlowThread = layer()->hitTest(newRequest, newHitTestLocation, result);
// FIXME: Should we set result.m_localPoint back to the RenderRegion's coordinate space or leave it in the RenderFlowThread's coordinate
// space? Right now it's staying in the RenderFlowThread's coordinate space, which may end up being ok. We will know more when we get around to
// patching positionForPoint.
return isPointInsideFlowThread;
}
示例5: 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;
InterpolationQuality previousInterpolationQuality = context->imageInterpolationQuality();
context->setImageInterpolationQuality(interpolationQuality);
toHTMLCanvasElement(node())->paint(context, paintRect);
context->setImageInterpolationQuality(previousInterpolationQuality);
if (clip)
context->restore();
}
示例6: paintReplaced
void HTMLCanvasPainter::paintReplaced(const PaintInfo& paintInfo, const LayoutPoint& paintOffset)
{
GraphicsContext* context = paintInfo.context;
LayoutRect contentRect = m_renderHTMLCanvas.contentBoxRect();
contentRect.moveBy(paintOffset);
LayoutRect paintRect = m_renderHTMLCanvas.replacedContentRect();
paintRect.moveBy(paintOffset);
bool clip = !contentRect.contains(paintRect);
if (clip) {
context->save();
context->clip(contentRect);
}
// FIXME: InterpolationNone should be used if ImageRenderingOptimizeContrast is set.
// See bug for more details: crbug.com/353716.
InterpolationQuality interpolationQuality = m_renderHTMLCanvas.style()->imageRendering() == ImageRenderingOptimizeContrast ? InterpolationLow : CanvasDefaultInterpolationQuality;
if (m_renderHTMLCanvas.style()->imageRendering() == ImageRenderingPixelated)
interpolationQuality = InterpolationNone;
InterpolationQuality previousInterpolationQuality = context->imageInterpolationQuality();
context->setImageInterpolationQuality(interpolationQuality);
toHTMLCanvasElement(m_renderHTMLCanvas.node())->paint(context, paintRect);
context->setImageInterpolationQuality(previousInterpolationQuality);
if (clip)
context->restore();
}
示例7: paintReplaced
void RenderVideo::paintReplaced(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
{
MediaPlayer* mediaPlayer = mediaElement()->player();
bool displayingPoster = videoElement()->shouldDisplayPosterImage();
if (!displayingPoster && !mediaPlayer)
return;
LayoutRect rect = videoBox();
if (rect.isEmpty())
return;
rect.moveBy(paintOffset);
LayoutRect contentRect = contentBoxRect();
contentRect.moveBy(paintOffset);
GraphicsContext* context = paintInfo.context;
bool clip = !contentRect.contains(rect);
if (clip) {
context->save();
context->clip(contentRect);
}
if (displayingPoster)
paintIntoRect(context, rect);
else if ((document().view() && document().view()->paintBehavior() & PaintBehaviorFlattenCompositingLayers) || !acceleratedRenderingInUse())
mediaPlayer->paint(context, pixelSnappedIntRect(rect));
if (clip)
context->restore();
}
示例8: 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));
}
if (Frame* frame = this->frame()) {
if (Page* page = frame->page()) {
if (paintInfo.phase == PaintPhaseForeground)
page->addRelevantRepaintedObject(this, intersection(paintRect, contentRect));
}
}
bool useLowQualityScale = style()->imageRendering() == ImageRenderingOptimizeContrast;
toHTMLCanvasElement(node())->paint(context, paintRect, useLowQualityScale);
if (clip)
context->restore();
}
示例9: addNodeToRectBasedTestResult
bool HitTestResult::addNodeToRectBasedTestResult(Node* node, const HitTestRequest& request, const HitTestLocation& locationInContainer, const LayoutRect& rect)
{
// If it is not a rect-based hit test, this method has to be no-op.
// Return false, so the hit test stops.
if (!isRectBasedTest())
return false;
// If node is null, return true so the hit test can continue.
if (!node)
return true;
if (!request.allowsShadowContent())
node = node->shadowAncestorNode();
mutableRectBasedTestResult().add(node);
bool regionFilled = rect.contains(locationInContainer.boundingBox());
// FIXME: This code (incorrectly) attempts to correct for culled inline nodes. See https://bugs.webkit.org/show_bug.cgi?id=85849.
if (node->renderer()->isInline() && !regionFilled) {
for (RenderObject* curr = node->renderer()->parent(); curr; curr = curr->parent()) {
if (!curr->isRenderInline())
break;
// We need to make sure the nodes for culled inlines get included.
RenderInline* currInline = toRenderInline(curr);
if (currInline->alwaysCreateLineBoxes())
break;
if (currInline->visibleToHitTesting() && currInline->node())
mutableRectBasedTestResult().add(currInline->node()->shadowAncestorNode());
}
}
return !regionFilled;
}
示例10: viewRect
bool LayoutImage::updateImageLoadingPriorities()
{
if (!m_imageResource || !m_imageResource->cachedImage() || m_imageResource->cachedImage()->isLoaded())
return false;
LayoutRect viewBounds = viewRect();
LayoutRect objectBounds = LayoutRect(absoluteContentBox());
// The object bounds might be empty right now, so intersects will fail since it doesn't deal
// with empty rects. Use LayoutRect::contains in that case.
bool isVisible;
if (!objectBounds.isEmpty())
isVisible = viewBounds.intersects(objectBounds);
else
isVisible = viewBounds.contains(objectBounds);
ResourceLoadPriorityOptimizer::VisibilityStatus status = isVisible ?
ResourceLoadPriorityOptimizer::Visible : ResourceLoadPriorityOptimizer::NotVisible;
LayoutRect screenArea;
if (!objectBounds.isEmpty()) {
screenArea = viewBounds;
screenArea.intersect(objectBounds);
}
ResourceLoadPriorityOptimizer::resourceLoadPriorityOptimizer()->notifyImageResourceVisibility(m_imageResource->cachedImage(), status, screenArea);
return true;
}
示例11: properties
BoxClipper::BoxClipper(const LayoutBox& box, const PaintInfo& paintInfo, const LayoutPoint& accumulatedOffset, ContentsClipBehavior contentsClipBehavior)
: m_box(box)
, m_paintInfo(paintInfo)
, m_clipType(DisplayItem::UninitializedType)
{
ASSERT(m_paintInfo.phase != PaintPhaseSelfBlockBackgroundOnly && m_paintInfo.phase != PaintPhaseSelfOutlineOnly);
if (m_paintInfo.phase == PaintPhaseMask)
return;
if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
const auto* objectProperties = m_box.objectPaintProperties();
if (objectProperties && objectProperties->overflowClip()) {
PaintChunkProperties properties(paintInfo.context.getPaintController().currentPaintChunkProperties());
properties.clip = objectProperties->overflowClip();
m_scopedClipProperty.emplace(paintInfo.context.getPaintController(), properties);
}
return;
}
bool isControlClip = m_box.hasControlClip();
bool isOverflowOrContainmentClip = (m_box.hasOverflowClip() && !m_box.layer()->isSelfPaintingLayer())
|| m_box.style()->containsPaint();
if (!isControlClip && !isOverflowOrContainmentClip)
return;
LayoutRect clipRect = isControlClip ? m_box.controlClipRect(accumulatedOffset) : m_box.overflowClipRect(accumulatedOffset);
FloatRoundedRect clipRoundedRect(0, 0, 0, 0);
bool hasBorderRadius = m_box.style()->hasBorderRadius();
if (hasBorderRadius)
clipRoundedRect = m_box.style()->getRoundedInnerBorderFor(LayoutRect(accumulatedOffset, m_box.size()));
// Selection does not affect visual overflow, so this optimization is invalid if selection
// is present.
if (contentsClipBehavior == SkipContentsClipIfPossible && box.getSelectionState() == SelectionNone) {
LayoutRect contentsVisualOverflow = m_box.contentsVisualOverflowRect();
if (contentsVisualOverflow.isEmpty())
return;
LayoutRect conservativeClipRect = clipRect;
if (hasBorderRadius)
conservativeClipRect.intersect(LayoutRect(clipRoundedRect.radiusCenterRect()));
conservativeClipRect.moveBy(-accumulatedOffset);
if (m_box.hasLayer())
conservativeClipRect.move(m_box.scrolledContentOffset());
if (conservativeClipRect.contains(contentsVisualOverflow))
return;
}
if (!m_paintInfo.context.getPaintController().displayItemConstructionIsDisabled()) {
m_clipType = m_paintInfo.displayItemTypeForClipping();
Vector<FloatRoundedRect> roundedRects;
if (hasBorderRadius)
roundedRects.append(clipRoundedRect);
m_paintInfo.context.getPaintController().createAndAppend<ClipDisplayItem>(m_box, m_clipType, pixelSnappedIntRect(clipRect), roundedRects);
}
}
示例12: visiblePositionForPoint
PassRefPtr<Range> Frame::rangeForPoint(const LayoutPoint& framePoint)
{
VisiblePosition position = visiblePositionForPoint(framePoint);
if (position.isNull())
return 0;
VisiblePosition previous = position.previous();
if (previous.isNotNull()) {
RefPtr<Range> previousCharacterRange = makeRange(previous, position);
LayoutRect rect = editor()->firstRectForRange(previousCharacterRange.get());
if (rect.contains(framePoint))
return previousCharacterRange.release();
}
VisiblePosition next = position.next();
if (RefPtr<Range> nextCharacterRange = makeRange(position, next)) {
LayoutRect rect = editor()->firstRectForRange(nextCharacterRange.get());
if (rect.contains(framePoint))
return nextCharacterRange.release();
}
return 0;
}
示例13: addNodeToListBasedTestResult
ListBasedHitTestBehavior HitTestResult::addNodeToListBasedTestResult(Node* node, const HitTestLocation& location, const LayoutRect& rect)
{
// If not a list-based test, stop testing because the hit has been found.
if (!hitTestRequest().listBased())
return StopHitTesting;
if (!node)
return ContinueHitTesting;
mutableListBasedTestResult().add(node);
if (hitTestRequest().penetratingList())
return ContinueHitTesting;
return rect.contains(LayoutRect(location.boundingBox())) ? StopHitTesting : ContinueHitTesting;
}
示例14: addNodeToRectBasedTestResult
bool HitTestResult::addNodeToRectBasedTestResult(Node* node, const HitTestRequest& request, const HitTestLocation& locationInContainer, const LayoutRect& rect)
{
// If it is not a rect-based hit test, this method has to be no-op.
// Return false, so the hit test stops.
if (!isRectBasedTest())
return false;
// If node is null, return true so the hit test can continue.
if (!node)
return true;
mutableRectBasedTestResult().add(node);
bool regionFilled = rect.contains(locationInContainer.boundingBox());
return !regionFilled;
}
示例15: paintIntoRect
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);
}