void ExclusionPolygon::getExcludedIntervals(LayoutUnit logicalTop, LayoutUnit logicalHeight, SegmentList& result) const { const FloatPolygon& polygon = shapeMarginBounds(); if (polygon.isEmpty()) return; float y1 = logicalTop; float y2 = logicalTop + logicalHeight; Vector<ExclusionInterval> y1XIntervals, y2XIntervals; computeXIntersections(polygon, y1, true, y1XIntervals); computeXIntersections(polygon, y2, false, y2XIntervals); Vector<ExclusionInterval> mergedIntervals; mergeExclusionIntervals(y1XIntervals, y2XIntervals, mergedIntervals); Vector<ExclusionInterval> edgeIntervals; computeOverlappingEdgeXProjections(polygon, y1, y2, edgeIntervals); Vector<ExclusionInterval> excludedIntervals; mergeExclusionIntervals(mergedIntervals, edgeIntervals, excludedIntervals); for (unsigned i = 0; i < excludedIntervals.size(); ++i) { ExclusionInterval interval = excludedIntervals[i]; result.append(LineSegment(interval.x1, interval.x2)); } }
void RectangleShape::getExcludedIntervals(LayoutUnit logicalTop, LayoutUnit logicalHeight, SegmentList& result) const { const FloatRoundedRect& bounds = shapeMarginBounds(); if (bounds.isEmpty()) return; float y1 = logicalTop; float y2 = logicalTop + logicalHeight; if (y2 < bounds.y() || y1 >= bounds.maxY()) return; float x1 = bounds.x(); float x2 = bounds.maxX(); if (bounds.ry() > 0) { if (y2 < bounds.y() + bounds.ry()) { float yi = y2 - bounds.y() - bounds.ry(); float xi = ellipseXIntercept(yi, bounds.rx(), bounds.ry()); x1 = bounds.x() + bounds.rx() - xi; x2 = bounds.maxX() - bounds.rx() + xi; } else if (y1 > bounds.maxY() - bounds.ry()) { float yi = y1 - (bounds.maxY() - bounds.ry()); float xi = ellipseXIntercept(yi, bounds.rx(), bounds.ry()); x1 = bounds.x() + bounds.rx() - xi; x2 = bounds.maxX() - bounds.rx() + xi; } } result.append(LineSegment(x1, x2)); }
LineSegment RectangleShape::getExcludedInterval(LayoutUnit logicalTop, LayoutUnit logicalHeight) const { const FloatRect& bounds = shapeMarginBounds(); if (bounds.isEmpty()) return LineSegment(); float y1 = logicalTop.toFloat(); float y2 = (logicalTop + logicalHeight).toFloat(); if (y2 < bounds.y() || y1 >= bounds.maxY()) return LineSegment(); float x1 = bounds.x(); float x2 = bounds.maxX(); float marginRadiusX = rx() + shapeMargin(); float marginRadiusY = ry() + shapeMargin(); if (marginRadiusY > 0) { if (y2 < bounds.y() + marginRadiusY) { float yi = y2 - bounds.y() - marginRadiusY; float xi = ellipseXIntercept(yi, marginRadiusX, marginRadiusY); x1 = bounds.x() + marginRadiusX - xi; x2 = bounds.maxX() - marginRadiusX + xi; } else if (y1 > bounds.maxY() - marginRadiusY) { float yi = y1 - (bounds.maxY() - marginRadiusY); float xi = ellipseXIntercept(yi, marginRadiusX, marginRadiusY); x1 = bounds.x() + marginRadiusX - xi; x2 = bounds.maxX() - marginRadiusX + xi; } } return LineSegment(x1, x2); }
void BoxShape::buildDisplayPaths(DisplayPaths& paths) const { addRoundedRect(paths.shape, m_bounds.rect(), m_bounds.radii()); if (shapeMargin()) { const FloatRoundedRect& marginBounds = shapeMarginBounds(); addRoundedRect(paths.marginShape, marginBounds.rect(), marginBounds.radii()); } }
void BoxShape::getExcludedIntervals(LayoutUnit logicalTop, LayoutUnit logicalHeight, SegmentList& result) const { const FloatRoundedRect& marginBounds = shapeMarginBounds(); if (marginBounds.isEmpty() || !lineOverlapsShapeMarginBounds(logicalTop, logicalHeight)) return; float y1 = logicalTop; float y2 = logicalTop + logicalHeight; const FloatRect& rect = marginBounds.rect(); if (!marginBounds.isRounded()) { result.append(LineSegment(rect.x(), rect.maxX())); return; } float topCornerMaxY = std::max<float>(marginBounds.topLeftCorner().maxY(), marginBounds.topRightCorner().maxY()); float bottomCornerMinY = std::min<float>(marginBounds.bottomLeftCorner().y(), marginBounds.bottomRightCorner().y()); if (y1 <= topCornerMaxY && y2 >= bottomCornerMinY) { result.append(LineSegment(rect.x(), rect.maxX())); return; } float x1 = rect.maxX(); float x2 = rect.x(); float minXIntercept; float maxXIntercept; if (marginBounds.xInterceptsAtY(y1, minXIntercept, maxXIntercept)) { x1 = std::min<float>(x1, minXIntercept); x2 = std::max<float>(x2, maxXIntercept); } if (marginBounds.xInterceptsAtY(y2, minXIntercept, maxXIntercept)) { x1 = std::min<float>(x1, minXIntercept); x2 = std::max<float>(x2, maxXIntercept); } ASSERT(x2 >= x1); result.append(LineSegment(x1, x2)); }
void RectangleShape::buildDisplayPaths(DisplayPaths& paths) const { paths.shape.addRoundedRect(m_bounds, m_radii); if (shapeMargin()) paths.marginShape.addRoundedRect(shapeMarginBounds(), FloatSize(m_radii.width() + shapeMargin(), m_radii.height() + shapeMargin())); }