bool RoundedRect::intersectsQuad(const FloatQuad& quad) const { FloatRect rect(m_rect); if (!quad.intersectsRect(rect)) return false; const IntSize& topLeft = m_radii.topLeft(); if (!topLeft.isEmpty()) { FloatRect rect(m_rect.x(), m_rect.y(), topLeft.width(), topLeft.height()); if (quad.intersectsRect(rect)) { FloatPoint center(m_rect.x() + topLeft.width(), m_rect.y() + topLeft.height()); FloatSize size(topLeft.width(), topLeft.height()); if (!quad.intersectsEllipse(center, size)) return false; } } const IntSize& topRight = m_radii.topRight(); if (!topRight.isEmpty()) { FloatRect rect(m_rect.maxX() - topRight.width(), m_rect.y(), topRight.width(), topRight.height()); if (quad.intersectsRect(rect)) { FloatPoint center(m_rect.maxX() - topRight.width(), m_rect.y() + topRight.height()); FloatSize size(topRight.width(), topRight.height()); if (!quad.intersectsEllipse(center, size)) return false; } } const IntSize& bottomLeft = m_radii.bottomLeft(); if (!bottomLeft.isEmpty()) { FloatRect rect(m_rect.x(), m_rect.maxY() - bottomLeft.height(), bottomLeft.width(), bottomLeft.height()); if (quad.intersectsRect(rect)) { FloatPoint center(m_rect.x() + bottomLeft.width(), m_rect.maxY() - bottomLeft.height()); FloatSize size(bottomLeft.width(), bottomLeft.height()); if (!quad.intersectsEllipse(center, size)) return false; } } const IntSize& bottomRight = m_radii.bottomRight(); if (!bottomRight.isEmpty()) { FloatRect rect(m_rect.maxX() - bottomRight.width(), m_rect.maxY() - bottomRight.height(), bottomRight.width(), bottomRight.height()); if (quad.intersectsRect(rect)) { FloatPoint center(m_rect.maxX() - bottomRight.width(), m_rect.maxY() - bottomRight.height()); FloatSize size(bottomRight.width(), bottomRight.height()); if (!quad.intersectsEllipse(center, size)) return false; } } return true; }