| 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 if (layoutObject.isSVG() && !layoutObject.isSVGRoot()) { | 21 if (layoutObject.isSVG() && !layoutObject.isSVGRoot()) { |
| 22 // The reference will have been resolved in | 22 // The reference will have been resolved in |
| 23 // SVGResources::buildResources, so we can just use the LayoutObject's | 23 // SVGResources::buildResources, so we can just use the LayoutObject's |
| 24 // SVGResources. | 24 // SVGResources. |
| 25 SVGResources* resources = | 25 SVGResources* resources = |
| 26 SVGResourcesCache::cachedResourcesForLayoutObject(&layoutObject); | 26 SVGResourcesCache::cachedResourcesForLayoutObject(&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 | 29 // TODO(fs): Doesn't work with external SVG references (crbug.com/109212.) |
| 30 // (https://bugs.webkit.org/show_bug.cgi?id=90405) | 30 Node* targetNode = layoutObject.node(); |
| 31 Element* element = layoutObject.document().getElementById( | 31 if (!targetNode) |
| 32 referenceClipPathOperation.fragment()); | 32 return nullptr; |
| 33 SVGElement* element = |
| 34 referenceClipPathOperation.findElement(targetNode->treeScope()); |
| 33 if (!isSVGClipPathElement(element) || !element->layoutObject()) | 35 if (!isSVGClipPathElement(element) || !element->layoutObject()) |
| 34 return nullptr; | 36 return nullptr; |
| 35 return toLayoutSVGResourceClipper( | 37 return toLayoutSVGResourceClipper( |
| 36 toLayoutSVGResourceContainer(element->layoutObject())); | 38 toLayoutSVGResourceContainer(element->layoutObject())); |
| 37 } | 39 } |
| 38 | 40 |
| 39 } // namespace | 41 } // namespace |
| 40 | 42 |
| 41 ClipPathClipper::ClipPathClipper(GraphicsContext& context, | 43 ClipPathClipper::ClipPathClipper(GraphicsContext& context, |
| 42 ClipPathOperation& clipPathOperation, | 44 ClipPathOperation& clipPathOperation, |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 } | 80 } |
| 79 } | 81 } |
| 80 | 82 |
| 81 ClipPathClipper::~ClipPathClipper() { | 83 ClipPathClipper::~ClipPathClipper() { |
| 82 if (m_resourceClipper) | 84 if (m_resourceClipper) |
| 83 SVGClipPainter(*m_resourceClipper) | 85 SVGClipPainter(*m_resourceClipper) |
| 84 .finishEffect(m_layoutObject, m_context, m_clipperState); | 86 .finishEffect(m_layoutObject, m_context, m_clipperState); |
| 85 } | 87 } |
| 86 | 88 |
| 87 } // namespace blink | 89 } // namespace blink |
| OLD | NEW |