本文整理汇总了C++中LayoutPoint::y方法的典型用法代码示例。如果您正苦于以下问题:C++ LayoutPoint::y方法的具体用法?C++ LayoutPoint::y怎么用?C++ LayoutPoint::y使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LayoutPoint
的用法示例。
在下文中一共展示了LayoutPoint::y方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: shouldPaint
bool RenderReplaced::shouldPaint(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
{
if (paintInfo.phase != PaintPhaseForeground && paintInfo.phase != PaintPhaseOutline && paintInfo.phase != PaintPhaseSelfOutline
&& paintInfo.phase != PaintPhaseSelection && paintInfo.phase != PaintPhaseMask)
return false;
if (!paintInfo.shouldPaintWithinRoot(this))
return false;
// if we're invisible or haven't received a layout yet, then just bail.
if (style()->visibility() != VISIBLE)
return false;
LayoutPoint adjustedPaintOffset = paintOffset + location();
// Early exit if the element touches the edges.
LayoutUnit top = adjustedPaintOffset.y() + visualOverflowRect().y();
LayoutUnit bottom = adjustedPaintOffset.y() + visualOverflowRect().maxY();
if (isSelected() && m_inlineBoxWrapper) {
LayoutUnit selTop = paintOffset.y() + m_inlineBoxWrapper->root()->selectionTop();
LayoutUnit selBottom = paintOffset.y() + selTop + m_inlineBoxWrapper->root()->selectionHeight();
top = min(selTop, top);
bottom = max(selBottom, bottom);
}
LayoutRect localRepaintRect = paintInfo.rect;
localRepaintRect.inflate(maximalOutlineSize(paintInfo.phase));
if (adjustedPaintOffset.x() + visualOverflowRect().x() >= localRepaintRect.maxX() || adjustedPaintOffset.x() + visualOverflowRect().maxX() <= localRepaintRect.x())
return false;
if (top >= localRepaintRect.maxY() || bottom <= localRepaintRect.y())
return false;
return true;
}
示例2: paint
void RenderMathMLBlock::paint(PaintInfo& info, const LayoutPoint& paintOffset)
{
RenderBlock::paint(info, paintOffset);
if (info.context->paintingDisabled() || info.phase != PaintPhaseForeground)
return;
LayoutPoint adjustedPaintOffset = paintOffset + location();
GraphicsContextStateSaver stateSaver(*info.context);
info.context->setStrokeThickness(1.0f);
info.context->setStrokeStyle(SolidStroke);
info.context->setStrokeColor(Color(0, 0, 255), ColorSpaceSRGB);
info.context->drawLine(adjustedPaintOffset, LayoutPoint(adjustedPaintOffset.x() + offsetWidth(), adjustedPaintOffset.y()));
info.context->drawLine(LayoutPoint(adjustedPaintOffset.x() + offsetWidth(), adjustedPaintOffset.y()), LayoutPoint(adjustedPaintOffset.x() + offsetWidth(), adjustedPaintOffset.y() + offsetHeight()));
info.context->drawLine(LayoutPoint(adjustedPaintOffset.x(), adjustedPaintOffset.y() + offsetHeight()), LayoutPoint(adjustedPaintOffset.x() + offsetWidth(), adjustedPaintOffset.y() + offsetHeight()));
info.context->drawLine(adjustedPaintOffset, LayoutPoint(adjustedPaintOffset.x(), adjustedPaintOffset.y() + offsetHeight()));
int topStart = paddingTop();
info.context->setStrokeColor(Color(0, 255, 0), ColorSpaceSRGB);
info.context->drawLine(LayoutPoint(adjustedPaintOffset.x(), adjustedPaintOffset.y() + topStart), LayoutPoint(adjustedPaintOffset.x() + offsetWidth(), adjustedPaintOffset.y() + topStart));
int baseline = baselinePosition(AlphabeticBaseline, true, HorizontalLine);
info.context->setStrokeColor(Color(255, 0, 0), ColorSpaceSRGB);
info.context->drawLine(LayoutPoint(adjustedPaintOffset.x(), adjustedPaintOffset.y() + baseline), LayoutPoint(adjustedPaintOffset.x() + offsetWidth(), adjustedPaintOffset.y() + baseline));
}
示例3: positionForPoint
VisiblePosition RenderReplaced::positionForPoint(const LayoutPoint& point, const RenderRegion* region)
{
// FIXME: This code is buggy if the replaced element is relative positioned.
InlineBox* box = inlineBoxWrapper();
const RootInlineBox* rootBox = box ? &box->root() : 0;
LayoutUnit top = rootBox ? rootBox->selectionTop() : logicalTop();
LayoutUnit bottom = rootBox ? rootBox->selectionBottom() : logicalBottom();
LayoutUnit blockDirectionPosition = isHorizontalWritingMode() ? point.y() + y() : point.x() + x();
LayoutUnit lineDirectionPosition = isHorizontalWritingMode() ? point.x() + x() : point.y() + y();
if (blockDirectionPosition < top)
return createVisiblePosition(caretMinOffset(), DOWNSTREAM); // coordinates are above
if (blockDirectionPosition >= bottom)
return createVisiblePosition(caretMaxOffset(), DOWNSTREAM); // coordinates are below
if (element()) {
if (lineDirectionPosition <= logicalLeft() + (logicalWidth() / 2))
return createVisiblePosition(0, DOWNSTREAM);
return createVisiblePosition(1, DOWNSTREAM);
}
return RenderBox::positionForPoint(point, region);
}
示例4: paintBorders
void FrameSetPainter::paintBorders(const PaintInfo& paintInfo, const LayoutPoint& adjustedPaintOffset)
{
LayoutRect adjustedFrameRect(adjustedPaintOffset, m_layoutFrameSet.size());
LayoutObjectDrawingRecorder recorder(*paintInfo.context, m_layoutFrameSet, paintInfo.phase, adjustedFrameRect);
if (recorder.canUseCachedDrawing())
return;
LayoutObject* child = m_layoutFrameSet.firstChild();
size_t rows = m_layoutFrameSet.rows().m_sizes.size();
size_t cols = m_layoutFrameSet.columns().m_sizes.size();
LayoutUnit borderThickness = m_layoutFrameSet.frameSet()->border();
LayoutUnit yPos = 0;
for (size_t r = 0; r < rows; r++) {
LayoutUnit xPos = 0;
for (size_t c = 0; c < cols; c++) {
xPos += m_layoutFrameSet.columns().m_sizes[c];
if (borderThickness && m_layoutFrameSet.columns().m_allowBorder[c + 1]) {
paintColumnBorder(paintInfo, pixelSnappedIntRect(
LayoutRect(adjustedPaintOffset.x() + xPos, adjustedPaintOffset.y() + yPos, borderThickness, m_layoutFrameSet.size().height())));
xPos += borderThickness;
}
child = child->nextSibling();
if (!child)
return;
}
yPos += m_layoutFrameSet.rows().m_sizes[r];
if (borderThickness && m_layoutFrameSet.rows().m_allowBorder[r + 1]) {
paintRowBorder(paintInfo, pixelSnappedIntRect(
LayoutRect(adjustedPaintOffset.x(), adjustedPaintOffset.y() + yPos, m_layoutFrameSet.size().width(), borderThickness)));
yPos += borderThickness;
}
}
}
示例5: positionForPoint
PositionWithAffinity LayoutReplaced::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 = isHorizontalWritingMode()
? point.y() + location().y()
: point.x() + location().x();
LayoutUnit lineDirectionPosition = isHorizontalWritingMode()
? point.x() + location().x()
: point.y() + location().y();
if (blockDirectionPosition < top)
return createPositionWithAffinity(
caretMinOffset()); // coordinates are above
if (blockDirectionPosition >= bottom)
return createPositionWithAffinity(
caretMaxOffset()); // coordinates are below
if (node()) {
if (lineDirectionPosition <= logicalLeft() + (logicalWidth() / 2))
return createPositionWithAffinity(0);
return createPositionWithAffinity(1);
}
return LayoutBox::positionForPoint(point);
}
示例6: hitTest
bool LineBoxList::hitTest(LayoutBoxModelObject* renderer, HitTestResult& result, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, HitTestAction hitTestAction) const
{
if (hitTestAction != HitTestForeground)
return false;
ASSERT(renderer->isLayoutBlock() || (renderer->isLayoutInline() && renderer->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();
LayoutRect rect(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(renderer, rect, 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(renderer, curr->logicalTopVisualOverflow(root.lineTop()), curr->logicalBottomVisualOverflow(root.lineBottom()), rect, accumulatedOffset)) {
bool inside = curr->nodeAtPoint(result, locationInContainer, accumulatedOffset, root.lineTop(), root.lineBottom());
if (inside) {
renderer->updateHitTestResult(result, locationInContainer.point() - toLayoutSize(accumulatedOffset));
return true;
}
}
}
return false;
}
示例7: paintObject
void FileUploadControlPainter::paintObject(const PaintInfo& paintInfo, const LayoutPoint& paintOffset)
{
if (m_layoutFileUploadControl.style()->visibility() != VISIBLE)
return;
// Push a clip.
Optional<ClipRecorder> clipRecorder;
if (paintInfo.phase == PaintPhaseForeground || paintInfo.phase == PaintPhaseDescendantBlockBackgroundsOnly) {
IntRect clipRect = enclosingIntRect(LayoutRect(
LayoutPoint(paintOffset.x() + m_layoutFileUploadControl.borderLeft(), paintOffset.y() + m_layoutFileUploadControl.borderTop()),
m_layoutFileUploadControl.size() + LayoutSize(0, -m_layoutFileUploadControl.borderWidth() + buttonShadowHeight)));
if (clipRect.isEmpty())
return;
clipRecorder.emplace(paintInfo.context, m_layoutFileUploadControl, DisplayItem::ClipFileUploadControlRect, clipRect);
}
if (paintInfo.phase == PaintPhaseForeground && !LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(paintInfo.context, m_layoutFileUploadControl, paintInfo.phase)) {
const String& displayedFilename = m_layoutFileUploadControl.fileTextValue();
const Font& font = m_layoutFileUploadControl.style()->font();
TextRun textRun = constructTextRun(font, displayedFilename, m_layoutFileUploadControl.styleRef(), RespectDirection | RespectDirectionOverride);
textRun.setExpansionBehavior(TextRun::AllowTrailingExpansion);
// Determine where the filename should be placed
LayoutUnit contentLeft = paintOffset.x() + m_layoutFileUploadControl.borderLeft() + m_layoutFileUploadControl.paddingLeft();
Node* button = m_layoutFileUploadControl.uploadButton();
if (!button)
return;
int buttonWidth = (button && button->layoutBox()) ? button->layoutBox()->pixelSnappedWidth() : 0;
LayoutUnit buttonAndSpacingWidth(buttonWidth + LayoutFileUploadControl::afterButtonSpacing);
float textWidth = font.width(textRun);
LayoutUnit textX;
if (m_layoutFileUploadControl.style()->isLeftToRightDirection())
textX = contentLeft + buttonAndSpacingWidth;
else
textX = LayoutUnit(contentLeft + m_layoutFileUploadControl.contentWidth() - buttonAndSpacingWidth - textWidth);
LayoutUnit textY;
// We want to match the button's baseline
// FIXME: Make this work with transforms.
if (LayoutButton* buttonLayoutObject = toLayoutButton(button->layoutObject()))
textY = paintOffset.y() + m_layoutFileUploadControl.borderTop() + m_layoutFileUploadControl.paddingTop() + buttonLayoutObject->baselinePosition(AlphabeticBaseline, true, HorizontalLine, PositionOnContainingLine);
else
textY = LayoutUnit(m_layoutFileUploadControl.baselinePosition(AlphabeticBaseline, true, HorizontalLine, PositionOnContainingLine));
TextRunPaintInfo textRunPaintInfo(textRun);
// FIXME: Shouldn't these offsets be rounded? crbug.com/350474
textRunPaintInfo.bounds = FloatRect(textX.toFloat(), textY.toFloat() - m_layoutFileUploadControl.style()->getFontMetrics().ascent(),
textWidth, m_layoutFileUploadControl.style()->getFontMetrics().height());
// Draw the filename.
LayoutObjectDrawingRecorder recorder(paintInfo.context, m_layoutFileUploadControl, paintInfo.phase, textRunPaintInfo.bounds);
paintInfo.context.setFillColor(m_layoutFileUploadControl.resolveColor(CSSPropertyColor));
paintInfo.context.drawBidiText(font, textRunPaintInfo, FloatPoint(roundToInt(textX), roundToInt(textY)));
}
// Paint the children.
m_layoutFileUploadControl.LayoutBlockFlow::paintObject(paintInfo, paintOffset);
}
示例8: setPositionFromPoint
void SliderThumbElement::setPositionFromPoint(const LayoutPoint& point)
{
RefPtrWillBeRawPtr<HTMLInputElement> input(hostInput());
Element* trackElement = input->closedShadowRoot()->getElementById(ShadowElementNames::sliderTrack());
if (!input->layoutObject() || !layoutBox() || !trackElement->layoutBox())
return;
LayoutPoint offset = roundedLayoutPoint(input->layoutObject()->absoluteToLocal(FloatPoint(point), UseTransforms));
bool isVertical = hasVerticalAppearance(input.get());
bool isLeftToRightDirection = layoutBox()->style()->isLeftToRightDirection();
LayoutUnit trackSize;
LayoutUnit position;
LayoutUnit currentPosition;
// We need to calculate currentPosition from absolute points becaue the
// renderer for this node is usually on a layer and layoutBox()->x() and
// y() are unusable.
// FIXME: This should probably respect transforms.
LayoutPoint absoluteThumbOrigin = layoutBox()->absoluteBoundingBoxRectIgnoringTransforms().location();
LayoutPoint absoluteSliderContentOrigin = roundedLayoutPoint(input->layoutObject()->localToAbsolute());
IntRect trackBoundingBox = trackElement->layoutObject()->absoluteBoundingBoxRectIgnoringTransforms();
IntRect inputBoundingBox = input->layoutObject()->absoluteBoundingBoxRectIgnoringTransforms();
if (isVertical) {
trackSize = trackElement->layoutBox()->contentHeight() - layoutBox()->size().height();
position = offset.y() - layoutBox()->size().height() / 2 - trackBoundingBox.y() + inputBoundingBox.y() - layoutBox()->marginBottom();
currentPosition = absoluteThumbOrigin.y() - absoluteSliderContentOrigin.y();
} else {
trackSize = trackElement->layoutBox()->contentWidth() - layoutBox()->size().width();
position = offset.x() - layoutBox()->size().width() / 2 - trackBoundingBox.x() + inputBoundingBox.x();
position -= isLeftToRightDirection ? layoutBox()->marginLeft() : layoutBox()->marginRight();
currentPosition = absoluteThumbOrigin.x() - absoluteSliderContentOrigin.x();
}
position = std::max<LayoutUnit>(0, std::min(position, trackSize));
const Decimal ratio = Decimal::fromDouble(static_cast<double>(position) / trackSize);
const Decimal fraction = isVertical || !isLeftToRightDirection ? Decimal(1) - ratio : ratio;
StepRange stepRange(input->createStepRange(RejectAny));
Decimal value = stepRange.clampValue(stepRange.valueFromProportion(fraction));
Decimal closest = input->findClosestTickMarkValue(value);
if (closest.isFinite()) {
double closestFraction = stepRange.proportionFromValue(closest).toDouble();
double closestRatio = isVertical || !isLeftToRightDirection ? 1.0 - closestFraction : closestFraction;
LayoutUnit closestPosition = trackSize * closestRatio;
const LayoutUnit snappingThreshold = 5;
if ((closestPosition - position).abs() <= snappingThreshold)
value = closest;
}
String valueString = serializeForNumberType(value);
if (valueString == input->value())
return;
// FIXME: This is no longer being set from renderer. Consider updating the method name.
input->setValueFromRenderer(valueString);
if (layoutObject())
layoutObject()->setNeedsLayoutAndFullPaintInvalidation(LayoutInvalidationReason::SliderValueChanged);
}
示例9: logicalPositionToPhysicalPoint
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());
}
示例10: 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);
}
示例11: paintFloats
void BlockFlowPainter::paintFloats(const PaintInfo& paintInfo,
const LayoutPoint& paintOffset) {
if (!m_layoutBlockFlow.floatingObjects())
return;
DCHECK(paintInfo.phase == PaintPhaseFloat ||
paintInfo.phase == PaintPhaseSelection ||
paintInfo.phase == PaintPhaseTextClip);
PaintInfo floatPaintInfo(paintInfo);
if (paintInfo.phase == PaintPhaseFloat)
floatPaintInfo.phase = PaintPhaseForeground;
for (const auto& floatingObject :
m_layoutBlockFlow.floatingObjects()->set()) {
if (!floatingObject->shouldPaint())
continue;
const LayoutBox* floatingLayoutObject = floatingObject->layoutObject();
// FIXME: LayoutPoint version of xPositionForFloatIncludingMargin would make
// this much cleaner.
LayoutPoint childPoint = m_layoutBlockFlow.flipFloatForWritingModeForChild(
*floatingObject,
LayoutPoint(paintOffset.x() +
m_layoutBlockFlow.xPositionForFloatIncludingMargin(
*floatingObject) -
floatingLayoutObject->location().x(),
paintOffset.y() +
m_layoutBlockFlow.yPositionForFloatIncludingMargin(
*floatingObject) -
floatingLayoutObject->location().y()));
ObjectPainter(*floatingLayoutObject)
.paintAllPhasesAtomically(floatPaintInfo, childPoint);
}
}
示例12: mapAbsoluteToLocalPoint
void RenderMultiColumnFlowThread::mapAbsoluteToLocalPoint(MapCoordinatesFlags mode, TransformState& transformState) const
{
// First get the transform state's point into the block flow thread's physical coordinate space.
parent()->mapAbsoluteToLocalPoint(mode, transformState);
LayoutPoint transformPoint = roundedLayoutPoint(transformState.mappedPoint());
// Now walk through each region.
const RenderMultiColumnSet* candidateColumnSet = nullptr;
LayoutPoint candidatePoint;
LayoutSize candidateContainerOffset;
for (const auto& columnSet : childrenOfType<RenderMultiColumnSet>(*parent())) {
candidateContainerOffset = columnSet.offsetFromContainer(parent(), LayoutPoint());
candidatePoint = transformPoint - candidateContainerOffset;
candidateColumnSet = &columnSet;
// We really have no clue what to do with overflow. We'll just use the closest region to the point in that case.
LayoutUnit pointOffset = isHorizontalWritingMode() ? candidatePoint.y() : candidatePoint.x();
LayoutUnit regionOffset = isHorizontalWritingMode() ? columnSet.topLeftLocation().y() : columnSet.topLeftLocation().x();
if (pointOffset < regionOffset + columnSet.logicalHeight())
break;
}
// Once we have a good guess as to which region we hit tested through (and yes, this was just a heuristic, but it's
// the best we could do), then we can map from the region into the flow thread.
LayoutSize translationOffset = physicalTranslationFromRegionToFlow(candidateColumnSet, candidatePoint) + candidateContainerOffset;
bool preserve3D = mode & UseTransforms && (parent()->style().preserves3D() || style().preserves3D());
if (mode & UseTransforms && shouldUseTransformFromContainer(parent())) {
TransformationMatrix t;
getTransformFromContainer(parent(), translationOffset, t);
transformState.applyTransform(t, preserve3D ? TransformState::AccumulateTransform : TransformState::FlattenTransform);
} else
transformState.move(translationOffset.width(), translationOffset.height(), preserve3D ? TransformState::AccumulateTransform : TransformState::FlattenTransform);
}
示例13: 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))
.toInt();
if (index < 0)
return 0;
return std::min(unsigned(index), actualColumnCount() - 1);
}
示例14: paintContents
void RenderWidget::paintContents(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
{
LayoutPoint adjustedPaintOffset = paintOffset + location();
Widget* widget = this->widget();
RELEASE_ASSERT(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 = 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.width(), widgetPaintOffset.height());
paintRect.move(-widgetPaintOffset);
}
widget->paint(paintInfo.context, paintRect);
if (!widgetPaintOffset.isZero())
paintInfo.context->translate(-widgetPaintOffset.width(), -widgetPaintOffset.height());
}
示例15: nodeAtPoint
bool EllipsisBox::nodeAtPoint(const HitTestRequest& request, HitTestResult& result, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, LayoutUnit lineTop, LayoutUnit lineBottom)
{
LayoutPoint adjustedLocation = accumulatedOffset + roundedLayoutPoint(topLeft());
// Hit test the markup box.
if (InlineBox* markupBox = this->markupBox()) {
RenderStyle* style = renderer().style(isFirstLineStyle());
LayoutUnit mtx = adjustedLocation.x() + m_logicalWidth - markupBox->x();
LayoutUnit mty = adjustedLocation.y() + style->fontMetrics().ascent() - (markupBox->y() + markupBox->renderer().style(isFirstLineStyle())->fontMetrics().ascent());
if (markupBox->nodeAtPoint(request, result, locationInContainer, LayoutPoint(mtx, mty), lineTop, lineBottom)) {
renderer().updateHitTestResult(result, locationInContainer.point() - LayoutSize(mtx, mty));
return true;
}
}
FloatPoint boxOrigin = locationIncludingFlipping();
boxOrigin.moveBy(accumulatedOffset);
FloatRect boundsRect(boxOrigin, size());
if (visibleToHitTestRequest(request) && boundsRect.intersects(HitTestLocation::rectForPoint(locationInContainer.point(), 0, 0, 0, 0))) {
renderer().updateHitTestResult(result, locationInContainer.point() - toLayoutSize(adjustedLocation));
if (!result.addNodeToRectBasedTestResult(renderer().node(), request, locationInContainer, boundsRect))
return true;
}
return false;
}