bool SVGLayoutSupport::pointInClippingArea(const LayoutObject& object, const FloatPoint& point) { ClipPathOperation* clipPathOperation = object.styleRef().clipPath(); if (!clipPathOperation) return true; if (clipPathOperation->type() == ClipPathOperation::SHAPE) { ShapeClipPathOperation& clipPath = toShapeClipPathOperation(*clipPathOperation); return clipPath.path(object.objectBoundingBox()).contains(point); } DCHECK_EQ(clipPathOperation->type(), ClipPathOperation::REFERENCE); SVGResources* resources = SVGResourcesCache::cachedResourcesForLayoutObject(&object); if (!resources || !resources->clipper()) return true; return resources->clipper()->hitTestClipContent(object.objectBoundingBox(), point); }
bool SVGPaintContext::applyClipIfNecessary(SVGResources* resources) { // resources->clipper() corresponds to the non-prefixed 'clip-path' whereas // m_object->style()->clipPath() corresponds to '-webkit-clip-path'. // FIXME: We should unify the clip-path and -webkit-clip-path codepaths. if (LayoutSVGResourceClipper* clipper = resources ? resources->clipper() : nullptr) { if (!SVGClipPainter(*clipper).prepareEffect(*m_object, m_object->objectBoundingBox(), m_object->paintInvalidationRectInLocalCoordinates(), m_paintInfo.context, m_clipperState)) return false; m_clipper = clipper; } else { ClipPathOperation* clipPathOperation = m_object->style()->clipPath(); if (clipPathOperation && clipPathOperation->type() == ClipPathOperation::SHAPE) { ShapeClipPathOperation* clipPath = toShapeClipPathOperation(clipPathOperation); if (!clipPath->isValid()) return false; m_clipPathRecorder = adoptPtr(new ClipPathRecorder(*m_paintInfo.context, *m_object, clipPath->path(m_object->objectBoundingBox()))); } } return true; }