FloatShapeInterval OffsetPolygonEdge::clippedEdgeXRange(float y1, float y2) const { if (!overlapsYRange(y1, y2) || (y1 == maxY() && minY() <= y1) || (y2 == minY() && maxY() >= y2)) return FloatShapeInterval(); if (isWithinYRange(y1, y2)) return FloatShapeInterval(minX(), maxX()); // Clip the edge line segment to the vertical range y1,y2 and then return // the clipped line segment's horizontal range. FloatPoint minYVertex; FloatPoint maxYVertex; if (vertex1().y() < vertex2().y()) { minYVertex = vertex1(); maxYVertex = vertex2(); } else { minYVertex = vertex2(); maxYVertex = vertex1(); } float xForY1 = (minYVertex.y() < y1) ? xIntercept(y1) : minYVertex.x(); float xForY2 = (maxYVertex.y() > y2) ? xIntercept(y2) : maxYVertex.x(); return FloatShapeInterval(std::min(xForY1, xForY2), std::max(xForY1, xForY2)); }
LineSegment PolygonShape::getExcludedInterval(LayoutUnit logicalTop, LayoutUnit logicalHeight) const { float y1 = logicalTop.toFloat(); float y2 = logicalTop.toFloat() + logicalHeight.toFloat(); if (m_polygon.isEmpty() || !overlapsYRange(m_polygon.boundingBox(), y1 - shapeMargin(), y2 + shapeMargin())) return LineSegment(); Vector<const FloatPolygonEdge*> overlappingEdges; if (!m_polygon.overlappingEdges(y1 - shapeMargin(), y2 + shapeMargin(), overlappingEdges)) return LineSegment(); FloatShapeInterval excludedInterval; for (unsigned i = 0; i < overlappingEdges.size(); i++) { const FloatPolygonEdge& edge = *(overlappingEdges[i]); if (edge.maxY() == edge.minY()) continue; if (!shapeMargin()) { excludedInterval.unite(OffsetPolygonEdge(edge, FloatSize()).clippedEdgeXRange(y1, y2)); } else { excludedInterval.unite(OffsetPolygonEdge(edge, outwardEdgeNormal(edge) * shapeMargin()).clippedEdgeXRange(y1, y2)); excludedInterval.unite(OffsetPolygonEdge(edge, inwardEdgeNormal(edge) * shapeMargin()).clippedEdgeXRange(y1, y2)); excludedInterval.unite(clippedCircleXRange(edge.vertex1(), shapeMargin(), y1, y2)); } } if (excludedInterval.isEmpty()) return LineSegment(); return LineSegment(excludedInterval.x1(), excludedInterval.x2()); }