本文整理汇总了C++中FloatQuad::containsPoint方法的典型用法代码示例。如果您正苦于以下问题:C++ FloatQuad::containsPoint方法的具体用法?C++ FloatQuad::containsPoint怎么用?C++ FloatQuad::containsPoint使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FloatQuad
的用法示例。
在下文中一共展示了FloatQuad::containsPoint方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: nodeAtPoint
bool SVGInlineTextBox::nodeAtPoint(HitTestResult& result, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, LayoutUnit, LayoutUnit)
{
// FIXME: integrate with InlineTextBox::nodeAtPoint better.
ASSERT(!isLineBreak());
PointerEventsHitRules hitRules(PointerEventsHitRules::SVG_TEXT_HITTESTING, result.hitTestRequest(), lineLayoutItem().style()->pointerEvents());
bool isVisible = lineLayoutItem().style()->visibility() == VISIBLE;
if (isVisible || !hitRules.requireVisible) {
if (hitRules.canHitBoundingBox
|| (hitRules.canHitStroke && (lineLayoutItem().style()->svgStyle().hasStroke() || !hitRules.requireStroke))
|| (hitRules.canHitFill && (lineLayoutItem().style()->svgStyle().hasFill() || !hitRules.requireFill))) {
LayoutPoint boxOrigin(x(), y());
boxOrigin.moveBy(accumulatedOffset);
LayoutRect rect(boxOrigin, size());
if (locationInContainer.intersects(rect)) {
LineLayoutSVGInlineText lineLayoutItem = LineLayoutSVGInlineText(this->lineLayoutItem());
ASSERT(lineLayoutItem.scalingFactor());
float baseline = lineLayoutItem.scaledFont().fontMetrics().floatAscent() / lineLayoutItem.scalingFactor();
FloatPoint floatLocation = FloatPoint(locationInContainer.point());
for (const SVGTextFragment& fragment : m_textFragments) {
FloatQuad fragmentQuad = fragment.boundingQuad(baseline);
if (fragmentQuad.containsPoint(floatLocation)) {
lineLayoutItem.updateHitTestResult(result, locationInContainer.point() - toLayoutSize(accumulatedOffset));
if (!result.addNodeToListBasedTestResult(lineLayoutItem.node(), locationInContainer, rect))
return true;
}
}
}
}
}
return false;
}
示例2: snapTo
bool snapTo(const SubtargetGeometry& geom, const IntPoint& touchPoint, const IntRect& touchArea, IntPoint& adjustedPoint)
{
FrameView* view = geom.node()->document()->view();
FloatQuad quad = geom.quad();
if (quad.isRectilinear()) {
IntRect contentBounds = geom.boundingBox();
// Convert from frame coordinates to window coordinates.
IntRect bounds = view->contentsToWindow(contentBounds);
if (bounds.contains(touchPoint)) {
adjustedPoint = touchPoint;
return true;
}
if (bounds.intersects(touchArea)) {
bounds.intersect(touchArea);
adjustedPoint = bounds.center();
return true;
}
return false;
}
// The following code tries to adjust the point to place inside a both the touchArea and the non-rectilinear quad.
// FIXME: This will return the point inside the touch area that is the closest to the quad center, but does not
// guarantee that the point will be inside the quad. Corner-cases exist where the quad will intersect but this
// will fail to adjust the point to somewhere in the intersection.
// Convert quad from content to window coordinates.
FloatPoint p1 = contentsToWindow(view, quad.p1());
FloatPoint p2 = contentsToWindow(view, quad.p2());
FloatPoint p3 = contentsToWindow(view, quad.p3());
FloatPoint p4 = contentsToWindow(view, quad.p4());
quad = FloatQuad(p1, p2, p3, p4);
if (quad.containsPoint(touchPoint)) {
adjustedPoint = touchPoint;
return true;
}
// Pull point towards the center of the element.
FloatPoint center = quad.center();
adjustPointToRect(center, touchArea);
adjustedPoint = roundedIntPoint(center);
return quad.containsPoint(adjustedPoint);
}
示例3: nodeAtPoint
bool SVGInlineTextBox::nodeAtPoint(HitTestResult& result,
const HitTestLocation& locationInContainer,
const LayoutPoint& accumulatedOffset,
LayoutUnit,
LayoutUnit) {
// FIXME: integrate with InlineTextBox::nodeAtPoint better.
ASSERT(!isLineBreak());
PointerEventsHitRules hitRules(PointerEventsHitRules::SVG_TEXT_HITTESTING,
result.hitTestRequest(),
getLineLayoutItem().style()->pointerEvents());
bool isVisible =
getLineLayoutItem().style()->visibility() == EVisibility::Visible;
if (isVisible || !hitRules.requireVisible) {
if (hitRules.canHitBoundingBox ||
(hitRules.canHitStroke &&
(getLineLayoutItem().style()->svgStyle().hasStroke() ||
!hitRules.requireStroke)) ||
(hitRules.canHitFill &&
(getLineLayoutItem().style()->svgStyle().hasFill() ||
!hitRules.requireFill))) {
LayoutRect rect(topLeft(), LayoutSize(logicalWidth(), logicalHeight()));
rect.moveBy(accumulatedOffset);
if (locationInContainer.intersects(rect)) {
LineLayoutSVGInlineText lineLayoutItem =
LineLayoutSVGInlineText(this->getLineLayoutItem());
const SimpleFontData* fontData =
lineLayoutItem.scaledFont().primaryFont();
DCHECK(fontData);
if (!fontData)
return false;
DCHECK(lineLayoutItem.scalingFactor());
float baseline = fontData->getFontMetrics().floatAscent() /
lineLayoutItem.scalingFactor();
FloatPoint floatLocation = FloatPoint(locationInContainer.point());
for (const SVGTextFragment& fragment : m_textFragments) {
FloatQuad fragmentQuad = fragment.boundingQuad(baseline);
if (fragmentQuad.containsPoint(floatLocation)) {
lineLayoutItem.updateHitTestResult(
result,
locationInContainer.point() - toLayoutSize(accumulatedOffset));
if (result.addNodeToListBasedTestResult(lineLayoutItem.node(),
locationInContainer,
rect) == StopHitTesting)
return true;
}
}
}
}
}
return false;
}