Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Nikolas Zimmermann <zimmermann@kde .org> | 2 * Copyright (C) 2004, 2005, 2006, 2007, 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) Research In Motion Limited 2010. All rights reserved. | 4 * Copyright (C) Research In Motion Limited 2010. All rights reserved. |
| 5 * | 5 * |
| 6 * This library is free software; you can redistribute it and/or | 6 * This library is free software; you can redistribute it and/or |
| 7 * modify it under the terms of the GNU Library General Public | 7 * modify it under the terms of the GNU Library General Public |
| 8 * License as published by the Free Software Foundation; either | 8 * License as published by the Free Software Foundation; either |
| 9 * version 2 of the License, or (at your option) any later version. | 9 * version 2 of the License, or (at your option) any later version. |
| 10 * | 10 * |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 159 | 159 |
| 160 if (RenderObject* object = renderer()) | 160 if (RenderObject* object = renderer()) |
| 161 object->setNeedsLayout(); | 161 object->setNeedsLayout(); |
| 162 } | 162 } |
| 163 | 163 |
| 164 RenderObject* SVGPatternElement::createRenderer(RenderStyle*) | 164 RenderObject* SVGPatternElement::createRenderer(RenderStyle*) |
| 165 { | 165 { |
| 166 return new RenderSVGResourcePattern(this); | 166 return new RenderSVGResourcePattern(this); |
| 167 } | 167 } |
| 168 | 168 |
| 169 static void setPatternAttributes(const SVGPatternElement* element, PatternAttrib utes& attributes) | |
| 170 { | |
| 171 if (!attributes.hasX() && element->hasAttribute(SVGNames::xAttr)) | |
| 172 attributes.setX(element->x()->currentValue()); | |
| 173 | |
| 174 if (!attributes.hasY() && element->hasAttribute(SVGNames::yAttr)) | |
| 175 attributes.setY(element->y()->currentValue()); | |
| 176 | |
| 177 if (!attributes.hasWidth() && element->hasAttribute(SVGNames::widthAttr)) | |
| 178 attributes.setWidth(element->width()->currentValue()); | |
| 179 | |
| 180 if (!attributes.hasHeight() && element->hasAttribute(SVGNames::heightAttr)) | |
| 181 attributes.setHeight(element->height()->currentValue()); | |
| 182 | |
| 183 if (!attributes.hasViewBox() && element->hasAttribute(SVGNames::viewBoxAttr) && element->viewBox()->currentValue()->isValid()) | |
| 184 attributes.setViewBox(element->viewBox()->currentValue()->value()); | |
| 185 | |
| 186 if (!attributes.hasPreserveAspectRatio() && element->hasAttribute(SVGNames:: preserveAspectRatioAttr)) | |
| 187 attributes.setPreserveAspectRatio(element->preserveAspectRatioCurrentVal ue()); | |
| 188 | |
| 189 if (!attributes.hasPatternUnits() && element->hasAttribute(SVGNames::pattern UnitsAttr)) | |
| 190 attributes.setPatternUnits(element->patternUnitsCurrentValue()); | |
| 191 | |
| 192 if (!attributes.hasPatternContentUnits() && element->hasAttribute(SVGNames:: patternContentUnitsAttr)) | |
| 193 attributes.setPatternContentUnits(element->patternContentUnitsCurrentVal ue()); | |
| 194 | |
| 195 if (!attributes.hasPatternTransform() && element->hasAttribute(SVGNames::pat ternTransformAttr)) { | |
| 196 AffineTransform transform; | |
| 197 element->patternTransformCurrentValue().concatenate(transform); | |
| 198 attributes.setPatternTransform(transform); | |
| 199 } | |
| 200 | |
| 201 if (!attributes.hasPatternContentElement() && element->childElementCount()) | |
| 202 attributes.setPatternContentElement(element); | |
| 203 } | |
| 204 | |
| 169 void SVGPatternElement::collectPatternAttributes(PatternAttributes& attributes) const | 205 void SVGPatternElement::collectPatternAttributes(PatternAttributes& attributes) const |
| 170 { | 206 { |
| 171 HashSet<const SVGPatternElement*> processedPatterns; | 207 HashSet<const SVGPatternElement*> processedPatterns; |
| 208 const SVGPatternElement* current = this; | |
| 172 | 209 |
| 173 const SVGPatternElement* current = this; | 210 while (true) { |
| 174 while (current) { | 211 setPatternAttributes(current, attributes); |
| 175 if (!attributes.hasX() && current->hasAttribute(SVGNames::xAttr)) | |
| 176 attributes.setX(current->x()->currentValue()); | |
| 177 | |
| 178 if (!attributes.hasY() && current->hasAttribute(SVGNames::yAttr)) | |
| 179 attributes.setY(current->y()->currentValue()); | |
| 180 | |
| 181 if (!attributes.hasWidth() && current->hasAttribute(SVGNames::widthAttr) ) | |
| 182 attributes.setWidth(current->width()->currentValue()); | |
| 183 | |
| 184 if (!attributes.hasHeight() && current->hasAttribute(SVGNames::heightAtt r)) | |
| 185 attributes.setHeight(current->height()->currentValue()); | |
| 186 | |
| 187 if (!attributes.hasViewBox() && current->hasAttribute(SVGNames::viewBoxA ttr) && current->viewBox()->currentValue()->isValid()) | |
| 188 attributes.setViewBox(current->viewBox()->currentValue()->value()); | |
| 189 | |
| 190 if (!attributes.hasPreserveAspectRatio() && current->hasAttribute(SVGNam es::preserveAspectRatioAttr)) | |
| 191 attributes.setPreserveAspectRatio(current->preserveAspectRatioCurren tValue()); | |
| 192 | |
| 193 if (!attributes.hasPatternUnits() && current->hasAttribute(SVGNames::pat ternUnitsAttr)) | |
| 194 attributes.setPatternUnits(current->patternUnitsCurrentValue()); | |
| 195 | |
| 196 if (!attributes.hasPatternContentUnits() && current->hasAttribute(SVGNam es::patternContentUnitsAttr)) | |
| 197 attributes.setPatternContentUnits(current->patternContentUnitsCurren tValue()); | |
| 198 | |
| 199 if (!attributes.hasPatternTransform() && current->hasAttribute(SVGNames: :patternTransformAttr)) { | |
| 200 AffineTransform transform; | |
| 201 current->patternTransformCurrentValue().concatenate(transform); | |
| 202 attributes.setPatternTransform(transform); | |
| 203 } | |
| 204 | |
| 205 if (!attributes.hasPatternContentElement() && current->childElementCount ()) | |
| 206 attributes.setPatternContentElement(current); | |
| 207 | |
| 208 processedPatterns.add(current); | 212 processedPatterns.add(current); |
| 209 | 213 |
| 210 // Respect xlink:href, take attributes from referenced element | 214 // Respect xlink:href, take attributes from referenced element |
| 211 Node* refNode = SVGURIReference::targetElementFromIRIString(current->hre fCurrentValue(), document()); | 215 Node* refNode = SVGURIReference::targetElementFromIRIString(current->hre fCurrentValue(), document()); |
| 212 if (refNode && refNode->hasTagName(SVGNames::patternTag)) { | 216 if (refNode && refNode->hasTagName(SVGNames::patternTag)) { |
| 213 current = toSVGPatternElement(const_cast<const Node*>(refNode)); | 217 current = toSVGPatternElement(const_cast<const Node*>(refNode)); |
| 214 | 218 |
| 215 // Cycle detection | 219 // Cycle detection |
| 216 if (processedPatterns.contains(current)) { | 220 if (processedPatterns.contains(current)) |
| 217 current = 0; | 221 return; |
|
pdr.
2014/01/21 00:33:26
I actually think this is harder to follow as there
| |
| 218 break; | 222 } else { |
| 219 } | 223 return; |
| 220 } else | 224 } |
| 221 current = 0; | |
| 222 } | 225 } |
| 226 | |
| 227 ASSERT_NOT_REACHED(); | |
| 223 } | 228 } |
| 224 | 229 |
| 225 AffineTransform SVGPatternElement::localCoordinateSpaceTransform(SVGElement::CTM Scope) const | 230 AffineTransform SVGPatternElement::localCoordinateSpaceTransform(SVGElement::CTM Scope) const |
| 226 { | 231 { |
| 227 AffineTransform matrix; | 232 AffineTransform matrix; |
| 228 patternTransformCurrentValue().concatenate(matrix); | 233 patternTransformCurrentValue().concatenate(matrix); |
| 229 return matrix; | 234 return matrix; |
| 230 } | 235 } |
| 231 | 236 |
| 232 bool SVGPatternElement::selfHasRelativeLengths() const | 237 bool SVGPatternElement::selfHasRelativeLengths() const |
| 233 { | 238 { |
| 234 return m_x->currentValue()->isRelative() | 239 return m_x->currentValue()->isRelative() |
| 235 || m_y->currentValue()->isRelative() | 240 || m_y->currentValue()->isRelative() |
| 236 || m_width->currentValue()->isRelative() | 241 || m_width->currentValue()->isRelative() |
| 237 || m_height->currentValue()->isRelative(); | 242 || m_height->currentValue()->isRelative(); |
| 238 } | 243 } |
| 239 | 244 |
| 240 } | 245 } |
| OLD | NEW |