| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "core/paint/ClipPathClipper.h" | 5 #include "core/paint/ClipPathClipper.h" |
| 6 | 6 |
| 7 #include "core/layout/svg/LayoutSVGResourceClipper.h" | 7 #include "core/layout/svg/LayoutSVGResourceClipper.h" |
| 8 #include "core/layout/svg/SVGResources.h" | 8 #include "core/layout/svg/SVGResources.h" |
| 9 #include "core/layout/svg/SVGResourcesCache.h" | 9 #include "core/layout/svg/SVGResourcesCache.h" |
| 10 #include "core/paint/SVGClipPainter.h" | 10 #include "core/paint/SVGClipPainter.h" |
| 11 #include "core/style/ClipPathOperation.h" | 11 #include "core/style/ClipPathOperation.h" |
| 12 #include "platform/graphics/paint/ClipPathRecorder.h" | 12 #include "platform/graphics/paint/ClipPathRecorder.h" |
| 13 | 13 |
| 14 namespace blink { | 14 namespace blink { |
| 15 | 15 |
| 16 namespace { | 16 namespace { |
| 17 | 17 |
| 18 LayoutSVGResourceClipper* resolveElementReference( | 18 LayoutSVGResourceClipper* resolveElementReference( |
| 19 const LayoutObject& layoutObject, | 19 const LayoutObject& layoutObject, |
| 20 const ReferenceClipPathOperation& referenceClipPathOperation) | 20 const ReferenceClipPathOperation& referenceClipPathOperation) |
| 21 { | 21 { |
| 22 if (layoutObject.isSVG()) { | 22 if (layoutObject.isSVG() && !layoutObject.isSVGRoot()) { |
| 23 // The reference will have been resolved in | 23 // The reference will have been resolved in |
| 24 // SVGResources::buildResources, so we can just use the LayoutObject's | 24 // SVGResources::buildResources, so we can just use the LayoutObject's |
| 25 // SVGResources. | 25 // SVGResources. |
| 26 SVGResources* resources = SVGResourcesCache::cachedResourcesForLayoutObj
ect(&layoutObject); | 26 SVGResources* resources = SVGResourcesCache::cachedResourcesForLayoutObj
ect(&layoutObject); |
| 27 return resources ? resources->clipper() : nullptr; | 27 return resources ? resources->clipper() : nullptr; |
| 28 } | 28 } |
| 29 // TODO(fs): It doesn't work with forward or external SVG references (https:
//bugs.webkit.org/show_bug.cgi?id=90405) | 29 // TODO(fs): It doesn't work with forward or external SVG references (https:
//bugs.webkit.org/show_bug.cgi?id=90405) |
| 30 Element* element = layoutObject.document().getElementById(referenceClipPathO
peration.fragment()); | 30 Element* element = layoutObject.document().getElementById(referenceClipPathO
peration.fragment()); |
| 31 if (!isSVGClipPathElement(element) || !element->layoutObject()) | 31 if (!isSVGClipPathElement(element) || !element->layoutObject()) |
| 32 return nullptr; | 32 return nullptr; |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 } | 75 } |
| 76 } | 76 } |
| 77 | 77 |
| 78 ClipPathClipper::~ClipPathClipper() | 78 ClipPathClipper::~ClipPathClipper() |
| 79 { | 79 { |
| 80 if (m_resourceClipper) | 80 if (m_resourceClipper) |
| 81 SVGClipPainter(*m_resourceClipper).finishEffect(m_layoutObject, m_contex
t, m_clipperState); | 81 SVGClipPainter(*m_resourceClipper).finishEffect(m_layoutObject, m_contex
t, m_clipperState); |
| 82 } | 82 } |
| 83 | 83 |
| 84 } // namespace blink | 84 } // namespace blink |
| OLD | NEW |