| OLD | NEW | 
| (Empty) |  | 
 |   1 // Copyright 2016 The Chromium Authors. All rights reserved. | 
 |   2 // Use of this source code is governed by a BSD-style license that can be | 
 |   3 // found in the LICENSE file. | 
 |   4  | 
 |   5 #include "core/paint/ClipPathClipper.h" | 
 |   6  | 
 |   7 #include "core/layout/svg/LayoutSVGResourceClipper.h" | 
 |   8 #include "core/style/ClipPathOperation.h" | 
 |   9 #include "platform/graphics/paint/ClipPathRecorder.h" | 
 |  10  | 
 |  11 namespace blink { | 
 |  12  | 
 |  13 ClipPathClipper::ClipPathClipper( | 
 |  14     GraphicsContext& context, | 
 |  15     const LayoutObject& layoutObject, | 
 |  16     const FloatRect& referenceBox, | 
 |  17     const FloatRect& visualOverflowRect, | 
 |  18     const FloatPoint& origin) | 
 |  19     : m_resourceClipper(nullptr) | 
 |  20     , m_clipperState(SVGClipPainter::ClipperNotApplied) | 
 |  21     , m_layoutObject(layoutObject) | 
 |  22     , m_context(context) | 
 |  23 { | 
 |  24     DCHECK(layoutObject.styleRef().clipPath()); | 
 |  25     ClipPathOperation* clipPathOperation = layoutObject.styleRef().clipPath(); | 
 |  26     if (clipPathOperation->type() == ClipPathOperation::SHAPE) { | 
 |  27         ShapeClipPathOperation* shape = toShapeClipPathOperation(clipPathOperati
    on); | 
 |  28         if (shape->isValid()) | 
 |  29             m_clipPathRecorder.emplace(context, layoutObject, shape->path(refere
    nceBox)); | 
 |  30     } else { | 
 |  31         DCHECK_EQ(clipPathOperation->type(), ClipPathOperation::REFERENCE); | 
 |  32         ReferenceClipPathOperation* referenceClipPathOperation = toReferenceClip
    PathOperation(clipPathOperation); | 
 |  33         Document& document = layoutObject.document(); | 
 |  34         // TODO(fs): It doesn't work with forward or external SVG references (ht
    tps://bugs.webkit.org/show_bug.cgi?id=90405) | 
 |  35         Element* element = document.getElementById(referenceClipPathOperation->f
    ragment()); | 
 |  36         if (isSVGClipPathElement(element) && element->layoutObject()) { | 
 |  37             m_resourceClipper = toLayoutSVGResourceClipper(toLayoutSVGResourceCo
    ntainer(element->layoutObject())); | 
 |  38             FloatPoint originTranslation = m_resourceClipper->clipPathUnits() ==
     SVGUnitTypes::kSvgUnitTypeUserspaceonuse ? | 
 |  39                 origin : FloatPoint(); | 
 |  40             if (!SVGClipPainter(*m_resourceClipper).prepareEffect(layoutObject, 
    referenceBox, | 
 |  41                 visualOverflowRect, originTranslation, context, m_clipperState))
     { | 
 |  42                 // No need to "finish" the clipper if this failed. | 
 |  43                 m_resourceClipper = nullptr; | 
 |  44             } | 
 |  45         } | 
 |  46     } | 
 |  47 } | 
 |  48  | 
 |  49 ClipPathClipper::~ClipPathClipper() | 
 |  50 { | 
 |  51     if (m_resourceClipper) | 
 |  52         SVGClipPainter(*m_resourceClipper).finishEffect(m_layoutObject, m_contex
    t, m_clipperState); | 
 |  53 } | 
 |  54  | 
 |  55 } // namespace blink | 
| OLD | NEW |