| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org> | 2 * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org> |
| 3 * Copyright (C) 2008 Eric Seidel <eric@webkit.org> | 3 * Copyright (C) 2008 Eric Seidel <eric@webkit.org> |
| 4 * Copyright (C) 2008 Dirk Schulze <krit@webkit.org> | 4 * Copyright (C) 2008 Dirk Schulze <krit@webkit.org> |
| 5 * Copyright (C) Research In Motion Limited 2010. All rights reserved. | 5 * Copyright (C) Research In Motion Limited 2010. All rights reserved. |
| 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. |
| 11 * | 11 * |
| 12 * This library is distributed in the hope that it will be useful, | 12 * This library is distributed in the hope that it will be useful, |
| 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15 * Library General Public License for more details. | 15 * Library General Public License for more details. |
| 16 * | 16 * |
| 17 * You should have received a copy of the GNU Library General Public License | 17 * You should have received a copy of the GNU Library General Public License |
| 18 * along with this library; see the file COPYING.LIB. If not, write to | 18 * along with this library; see the file COPYING.LIB. If not, write to |
| 19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 20 * Boston, MA 02110-1301, USA. | 20 * Boston, MA 02110-1301, USA. |
| 21 */ | 21 */ |
| 22 | 22 |
| 23 #include "core/layout/svg/LayoutSVGResourceGradient.h" | 23 #include "core/layout/svg/LayoutSVGResourceGradient.h" |
| 24 | 24 |
| 25 #include "wtf/PtrUtil.h" | |
| 26 #include <memory> | |
| 27 | |
| 28 namespace blink { | 25 namespace blink { |
| 29 | 26 |
| 30 LayoutSVGResourceGradient::LayoutSVGResourceGradient(SVGGradientElement* node) | 27 LayoutSVGResourceGradient::LayoutSVGResourceGradient(SVGGradientElement* node) |
| 31 : LayoutSVGResourcePaintServer(node) | 28 : LayoutSVGResourcePaintServer(node) |
| 32 , m_shouldCollectGradientAttributes(true) | 29 , m_shouldCollectGradientAttributes(true) |
| 33 { | 30 { |
| 34 } | 31 } |
| 35 | 32 |
| 36 void LayoutSVGResourceGradient::removeAllClientsFromCache(bool markForInvalidati
on) | 33 void LayoutSVGResourceGradient::removeAllClientsFromCache(bool markForInvalidati
on) |
| 37 { | 34 { |
| (...skipping 28 matching lines...) Expand all Loading... |
| 66 | 63 |
| 67 m_shouldCollectGradientAttributes = false; | 64 m_shouldCollectGradientAttributes = false; |
| 68 } | 65 } |
| 69 | 66 |
| 70 // Spec: When the geometry of the applicable element has no width or height
and objectBoundingBox is specified, | 67 // Spec: When the geometry of the applicable element has no width or height
and objectBoundingBox is specified, |
| 71 // then the given effect (e.g. a gradient or a filter) will be ignored. | 68 // then the given effect (e.g. a gradient or a filter) will be ignored. |
| 72 FloatRect objectBoundingBox = object.objectBoundingBox(); | 69 FloatRect objectBoundingBox = object.objectBoundingBox(); |
| 73 if (gradientUnits() == SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX && obje
ctBoundingBox.isEmpty()) | 70 if (gradientUnits() == SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX && obje
ctBoundingBox.isEmpty()) |
| 74 return SVGPaintServer::invalid(); | 71 return SVGPaintServer::invalid(); |
| 75 | 72 |
| 76 std::unique_ptr<GradientData>& gradientData = m_gradientMap.add(&object, nul
lptr).storedValue->value; | 73 OwnPtr<GradientData>& gradientData = m_gradientMap.add(&object, nullptr).sto
redValue->value; |
| 77 if (!gradientData) | 74 if (!gradientData) |
| 78 gradientData = wrapUnique(new GradientData); | 75 gradientData = adoptPtr(new GradientData); |
| 79 | 76 |
| 80 // Create gradient object | 77 // Create gradient object |
| 81 if (!gradientData->gradient) { | 78 if (!gradientData->gradient) { |
| 82 gradientData->gradient = buildGradient(); | 79 gradientData->gradient = buildGradient(); |
| 83 | 80 |
| 84 // We want the text bounding box applied to the gradient space transform
now, so the gradient shader can use it. | 81 // We want the text bounding box applied to the gradient space transform
now, so the gradient shader can use it. |
| 85 if (gradientUnits() == SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX &&
!objectBoundingBox.isEmpty()) { | 82 if (gradientUnits() == SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX &&
!objectBoundingBox.isEmpty()) { |
| 86 gradientData->userspaceTransform.translate(objectBoundingBox.x(), ob
jectBoundingBox.y()); | 83 gradientData->userspaceTransform.translate(objectBoundingBox.x(), ob
jectBoundingBox.y()); |
| 87 gradientData->userspaceTransform.scaleNonUniform(objectBoundingBox.w
idth(), objectBoundingBox.height()); | 84 gradientData->userspaceTransform.scaleNonUniform(objectBoundingBox.w
idth(), objectBoundingBox.height()); |
| 88 } | 85 } |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 return SpreadMethodReflect; | 121 return SpreadMethodReflect; |
| 125 case SVGSpreadMethodRepeat: | 122 case SVGSpreadMethodRepeat: |
| 126 return SpreadMethodRepeat; | 123 return SpreadMethodRepeat; |
| 127 } | 124 } |
| 128 | 125 |
| 129 ASSERT_NOT_REACHED(); | 126 ASSERT_NOT_REACHED(); |
| 130 return SpreadMethodPad; | 127 return SpreadMethodPad; |
| 131 } | 128 } |
| 132 | 129 |
| 133 } // namespace blink | 130 } // namespace blink |
| OLD | NEW |