OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2004, 2005, 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org> | 2 * Copyright (C) 2004, 2005, 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org> |
3 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Rob Buis <buis@kde.org> | 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Rob Buis <buis@kde.org> |
4 * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved. | 4 * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved. |
5 * Copyright (C) 2011 Dirk Schulze <krit@webkit.org> | 5 * Copyright (C) 2011 Dirk Schulze <krit@webkit.org> |
6 * | 6 * |
7 * This library is free software; you can redistribute it and/or | 7 * This library is free software; you can redistribute it and/or |
8 * modify it under the terms of the GNU Library General Public | 8 * modify it under the terms of the GNU Library General Public |
9 * License as published by the Free Software Foundation; either | 9 * License as published by the Free Software Foundation; either |
10 * version 2 of the License, or (at your option) any later version. | 10 * version 2 of the License, or (at your option) any later version. |
(...skipping 18 matching lines...) Expand all Loading... | |
29 #include "core/svg/SVGGeometryElement.h" | 29 #include "core/svg/SVGGeometryElement.h" |
30 #include "core/svg/SVGUseElement.h" | 30 #include "core/svg/SVGUseElement.h" |
31 #include "platform/graphics/paint/SkPictureBuilder.h" | 31 #include "platform/graphics/paint/SkPictureBuilder.h" |
32 #include "third_party/skia/include/core/SkPicture.h" | 32 #include "third_party/skia/include/core/SkPicture.h" |
33 #include "third_party/skia/include/pathops/SkPathOps.h" | 33 #include "third_party/skia/include/pathops/SkPathOps.h" |
34 | 34 |
35 namespace blink { | 35 namespace blink { |
36 | 36 |
37 namespace { | 37 namespace { |
38 | 38 |
39 bool requiresMask(const SVGElement& childElement) { | 39 bool requiresMask(const LayoutObject& layoutObject) { |
40 // TODO(fs): This needs to special-case <use> in a way similar to | |
41 // contributesToClip. (crbug.com/604677) | |
42 LayoutObject* layoutObject = childElement.layoutObject(); | |
43 DCHECK(layoutObject); | |
44 // Only basic shapes or paths are supported for direct clipping. We need to | 40 // Only basic shapes or paths are supported for direct clipping. We need to |
45 // fallback to masking for texts. | 41 // fallback to masking for texts. |
46 if (layoutObject->isSVGText()) | 42 if (layoutObject.isSVGText()) |
47 return true; | 43 return true; |
48 // Current shape in clip-path gets clipped too. Fallback to masking. | 44 // Current shape in clip-path gets clipped too. Fallback to masking. |
49 return layoutObject->styleRef().clipPath(); | 45 return layoutObject.styleRef().clipPath(); |
46 } | |
47 | |
48 bool requiresMask(const SVGElement& element) { | |
f(malita)
2016/12/07 13:58:09
There seems to be some overlap between contributes
fs
2016/12/07 14:11:43
Yes, that sounds like it might work. Will look int
| |
49 const LayoutObject* layoutObject = element.layoutObject(); | |
50 DCHECK(layoutObject); | |
51 if (isSVGUseElement(element)) { | |
52 if (layoutObject->styleRef().clipPath()) | |
53 return true; | |
54 const SVGGraphicsElement* clippingElement = | |
55 toSVGUseElement(element).visibleTargetGraphicsElementForClipping(); | |
56 DCHECK(clippingElement); | |
57 layoutObject = clippingElement->layoutObject(); | |
58 } | |
59 return requiresMask(*layoutObject); | |
50 } | 60 } |
51 | 61 |
52 bool contributesToClip(const SVGGraphicsElement& element) { | 62 bool contributesToClip(const SVGGraphicsElement& element) { |
53 const LayoutObject* layoutObject = element.layoutObject(); | 63 const LayoutObject* layoutObject = element.layoutObject(); |
54 if (!layoutObject) | 64 if (!layoutObject) |
55 return false; | 65 return false; |
56 const ComputedStyle& style = layoutObject->styleRef(); | 66 const ComputedStyle& style = layoutObject->styleRef(); |
57 if (style.display() == EDisplay::None || | 67 if (style.display() == EDisplay::None || |
58 style.visibility() != EVisibility::Visible) | 68 style.visibility() != EVisibility::Visible) |
59 return false; | 69 return false; |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
292 toSVGClipPathElement(element())->calculateTransform( | 302 toSVGClipPathElement(element())->calculateTransform( |
293 SVGElement::IncludeMotionTransform); | 303 SVGElement::IncludeMotionTransform); |
294 if (clipPathUnits() == SVGUnitTypes::kSvgUnitTypeObjectboundingbox) { | 304 if (clipPathUnits() == SVGUnitTypes::kSvgUnitTypeObjectboundingbox) { |
295 transform.translate(referenceBox.x(), referenceBox.y()); | 305 transform.translate(referenceBox.x(), referenceBox.y()); |
296 transform.scaleNonUniform(referenceBox.width(), referenceBox.height()); | 306 transform.scaleNonUniform(referenceBox.width(), referenceBox.height()); |
297 } | 307 } |
298 return transform.mapRect(m_localClipBounds); | 308 return transform.mapRect(m_localClipBounds); |
299 } | 309 } |
300 | 310 |
301 } // namespace blink | 311 } // namespace blink |
OLD | NEW |