Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2004, 2005, 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org> | 2 * Copyright (C) 2004, 2005, 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org> |
| 3 * Copyright (C) 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org> | 3 * Copyright (C) 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org> |
| 4 * Copyright (C) 2008 Eric Seidel <eric@webkit.org> | 4 * Copyright (C) 2008 Eric Seidel <eric@webkit.org> |
| 5 * Copyright (C) 2008 Dirk Schulze <krit@webkit.org> | 5 * Copyright (C) 2008 Dirk Schulze <krit@webkit.org> |
| 6 * Copyright (C) Research In Motion Limited 2010. All rights reserved. | 6 * Copyright (C) Research In Motion Limited 2010. All rights reserved. |
| 7 * | 7 * |
| 8 * This library is free software; you can redistribute it and/or | 8 * This library is free software; you can redistribute it and/or |
| 9 * modify it under the terms of the GNU Library General Public | 9 * modify it under the terms of the GNU Library General Public |
| 10 * License as published by the Free Software Foundation; either | 10 * License as published by the Free Software Foundation; either |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 127 | 127 |
| 128 RenderObject* SVGRadialGradientElement::createRenderer(RenderStyle*) | 128 RenderObject* SVGRadialGradientElement::createRenderer(RenderStyle*) |
| 129 { | 129 { |
| 130 return new RenderSVGResourceRadialGradient(this); | 130 return new RenderSVGResourceRadialGradient(this); |
| 131 } | 131 } |
| 132 | 132 |
| 133 bool SVGRadialGradientElement::collectGradientAttributes(RadialGradientAttribute s& attributes) | 133 bool SVGRadialGradientElement::collectGradientAttributes(RadialGradientAttribute s& attributes) |
| 134 { | 134 { |
| 135 HashSet<SVGGradientElement*> processedGradients; | 135 HashSet<SVGGradientElement*> processedGradients; |
| 136 | 136 |
| 137 bool isRadial = true; | |
| 138 SVGGradientElement* current = this; | 137 SVGGradientElement* current = this; |
| 139 | 138 |
| 140 while (current) { | 139 while (current) { |
| 141 if (!current->renderer()) | 140 if (!current->renderer()) |
| 142 return false; | 141 return false; |
| 143 | 142 |
| 144 if (!attributes.hasSpreadMethod() && current->hasAttribute(SVGNames::spr eadMethodAttr)) | 143 if (!attributes.hasSpreadMethod() && current->hasAttribute(SVGNames::spr eadMethodAttr)) |
| 145 attributes.setSpreadMethod(current->spreadMethodCurrentValue()); | 144 attributes.setSpreadMethod(current->spreadMethodCurrentValue()); |
| 146 | 145 |
| 147 if (!attributes.hasGradientUnits() && current->hasAttribute(SVGNames::gr adientUnitsAttr)) | 146 if (!attributes.hasGradientUnits() && current->hasAttribute(SVGNames::gr adientUnitsAttr)) |
| 148 attributes.setGradientUnits(current->gradientUnitsCurrentValue()); | 147 attributes.setGradientUnits(current->gradientUnitsCurrentValue()); |
| 149 | 148 |
| 150 if (!attributes.hasGradientTransform() && current->hasAttribute(SVGNames ::gradientTransformAttr)) { | 149 if (!attributes.hasGradientTransform() && current->hasAttribute(SVGNames ::gradientTransformAttr)) { |
| 151 AffineTransform transform; | 150 AffineTransform transform; |
| 152 current->gradientTransformCurrentValue().concatenate(transform); | 151 current->gradientTransformCurrentValue().concatenate(transform); |
| 153 attributes.setGradientTransform(transform); | 152 attributes.setGradientTransform(transform); |
| 154 } | 153 } |
| 155 | 154 |
| 156 if (!attributes.hasStops()) { | 155 if (!attributes.hasStops()) { |
| 157 const Vector<Gradient::ColorStop>& stops(current->buildStops()); | 156 const Vector<Gradient::ColorStop>& stops(current->buildStops()); |
| 158 if (!stops.isEmpty()) | 157 if (!stops.isEmpty()) |
| 159 attributes.setStops(stops); | 158 attributes.setStops(stops); |
| 160 } | 159 } |
| 161 | 160 |
| 162 if (isRadial) { | |
| 163 SVGRadialGradientElement* radial = toSVGRadialGradientElement(curren t); | |
| 164 | |
| 165 if (!attributes.hasCx() && current->hasAttribute(SVGNames::cxAttr)) | |
| 166 attributes.setCx(radial->cx()->currentValue()); | |
| 167 | |
| 168 if (!attributes.hasCy() && current->hasAttribute(SVGNames::cyAttr)) | |
| 169 attributes.setCy(radial->cy()->currentValue()); | |
| 170 | |
| 171 if (!attributes.hasR() && current->hasAttribute(SVGNames::rAttr)) | |
| 172 attributes.setR(radial->r()->currentValue()); | |
| 173 | |
| 174 if (!attributes.hasFx() && current->hasAttribute(SVGNames::fxAttr)) | |
| 175 attributes.setFx(radial->fx()->currentValue()); | |
| 176 | |
| 177 if (!attributes.hasFy() && current->hasAttribute(SVGNames::fyAttr)) | |
| 178 attributes.setFy(radial->fy()->currentValue()); | |
| 179 | |
| 180 if (!attributes.hasFr() && current->hasAttribute(SVGNames::frAttr)) | |
| 181 attributes.setFr(radial->fr()->currentValue()); | |
| 182 } | |
| 183 | |
| 184 processedGradients.add(current); | 161 processedGradients.add(current); |
| 185 | 162 |
| 186 // Respect xlink:href, take attributes from referenced element | 163 // Respect xlink:href, take attributes from referenced element |
| 187 Node* refNode = SVGURIReference::targetElementFromIRIString(current->hre fCurrentValue(), document()); | 164 Node* refNode = SVGURIReference::targetElementFromIRIString(current->hre fCurrentValue(), document()); |
| 188 if (refNode && (refNode->hasTagName(SVGNames::radialGradientTag) || refN ode->hasTagName(SVGNames::linearGradientTag))) { | 165 if (refNode && (refNode->hasTagName(SVGNames::radialGradientTag) || refN ode->hasTagName(SVGNames::linearGradientTag))) { |
| 189 current = toSVGGradientElement(refNode); | 166 current = toSVGGradientElement(refNode); |
| 190 | 167 |
| 191 // Cycle detection | 168 // Cycle detection |
| 192 if (processedGradients.contains(current)) { | 169 if (processedGradients.contains(current)) { |
| 193 current = 0; | 170 current = 0; |
| 194 break; | 171 break; |
| 195 } | 172 } |
| 196 | 173 |
| 197 isRadial = current->hasTagName(SVGNames::radialGradientTag); | 174 if (current->hasTagName(SVGNames::radialGradientTag)) { |
|
gyuyoung-inactive
2014/01/13 16:12:13
This moving do wrong behavior. I will update this
| |
| 175 SVGRadialGradientElement* radial = toSVGRadialGradientElement(cu rrent); | |
| 176 | |
| 177 if (!attributes.hasCx() && current->hasAttribute(SVGNames::cxAtt r)) | |
| 178 attributes.setCx(radial->cx()->currentValue()); | |
| 179 | |
| 180 if (!attributes.hasCy() && current->hasAttribute(SVGNames::cyAtt r)) | |
| 181 attributes.setCy(radial->cy()->currentValue()); | |
| 182 | |
| 183 if (!attributes.hasR() && current->hasAttribute(SVGNames::rAttr) ) | |
| 184 attributes.setR(radial->r()->currentValue()); | |
| 185 | |
| 186 if (!attributes.hasFx() && current->hasAttribute(SVGNames::fxAtt r)) | |
| 187 attributes.setFx(radial->fx()->currentValue()); | |
| 188 | |
| 189 if (!attributes.hasFy() && current->hasAttribute(SVGNames::fyAtt r)) | |
| 190 attributes.setFy(radial->fy()->currentValue()); | |
| 191 | |
| 192 if (!attributes.hasFr() && current->hasAttribute(SVGNames::frAtt r)) | |
| 193 attributes.setFr(radial->fr()->currentValue()); | |
| 194 } | |
| 198 } else | 195 } else |
| 199 current = 0; | 196 current = 0; |
| 200 } | 197 } |
| 201 | 198 |
| 202 // Handle default values for fx/fy | 199 // Handle default values for fx/fy |
| 203 if (!attributes.hasFx()) | 200 if (!attributes.hasFx()) |
| 204 attributes.setFx(attributes.cx()); | 201 attributes.setFx(attributes.cx()); |
| 205 | 202 |
| 206 if (!attributes.hasFy()) | 203 if (!attributes.hasFy()) |
| 207 attributes.setFy(attributes.cy()); | 204 attributes.setFy(attributes.cy()); |
| 208 return true; | 205 return true; |
| 209 } | 206 } |
| 210 | 207 |
| 211 bool SVGRadialGradientElement::selfHasRelativeLengths() const | 208 bool SVGRadialGradientElement::selfHasRelativeLengths() const |
| 212 { | 209 { |
| 213 return m_cx->currentValue()->isRelative() | 210 return m_cx->currentValue()->isRelative() |
| 214 || m_cy->currentValue()->isRelative() | 211 || m_cy->currentValue()->isRelative() |
| 215 || m_r->currentValue()->isRelative() | 212 || m_r->currentValue()->isRelative() |
| 216 || m_fx->currentValue()->isRelative() | 213 || m_fx->currentValue()->isRelative() |
| 217 || m_fy->currentValue()->isRelative() | 214 || m_fy->currentValue()->isRelative() |
| 218 || m_fr->currentValue()->isRelative(); | 215 || m_fr->currentValue()->isRelative(); |
| 219 } | 216 } |
| 220 | 217 |
| 221 } | 218 } |
| OLD | NEW |