240bool RoundedRect::contains(const LayoutRect& otherRect) const
241{
242 if (!rect().contains(otherRect))
243 return false;
244
245 const LayoutSize& topLeft = m_radii.topLeft();
246 if (!topLeft.isEmpty()) {
247 FloatPoint center = { m_rect.x() + topLeft.width(), m_rect.y() + topLeft.height() };
248 if (otherRect.x() <= center.x() && otherRect.y() <= center.y()) {
249 if (!ellipseContainsPoint(center, topLeft, otherRect.location()))
250 return false;
251 }
252 }
253
254 const LayoutSize& topRight = m_radii.topRight();
255 if (!topRight.isEmpty()) {
256 FloatPoint center = { m_rect.maxX() - topRight.width(), m_rect.y() + topRight.height() };
257 if (otherRect.maxX() >= center.x() && otherRect.y() <= center.y()) {
258 if (!ellipseContainsPoint(center, topRight, otherRect.location()))
259 return false;
260 }
261 }
262
263 const LayoutSize& bottomLeft = m_radii.bottomLeft();
264 if (!bottomLeft.isEmpty()) {
265 FloatPoint center = { m_rect.x() + bottomLeft.width(), m_rect.maxY() - bottomLeft.height() };
266 if (otherRect.maxX() >= center.x() && otherRect.maxY() >= center.y()) {
267 if (!ellipseContainsPoint(center, bottomLeft, otherRect.location()))
268 return false;
269 }
270 }
271
272 const LayoutSize& bottomRight = m_radii.bottomRight();
273 if (!bottomRight.isEmpty()) {
274 FloatPoint center = { m_rect.maxX() - bottomRight.width(), m_rect.maxY() - bottomRight.height() };
275 if (otherRect.x() <= center.x() && otherRect.maxY() >= center.y()) {
276 if (!ellipseContainsPoint(center, bottomRight, otherRect.location()))
277 return false;
278 }
279 }
280
281 return true;
282}
283