| 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 Rob Buis <buis@kde.org> | 3 * Copyright (C) 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org> |
| 4 * | 4 * |
| 5 * This library is free software; you can redistribute it and/or | 5 * This library is free software; you can redistribute it and/or |
| 6 * modify it under the terms of the GNU Library General Public | 6 * modify it under the terms of the GNU Library General Public |
| 7 * License as published by the Free Software Foundation; either | 7 * License as published by the Free Software Foundation; either |
| 8 * version 2 of the License, or (at your option) any later version. | 8 * version 2 of the License, or (at your option) any later version. |
| 9 * | 9 * |
| 10 * This library is distributed in the hope that it will be useful, | 10 * This library is distributed in the hope that it will be useful, |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 | 29 |
| 30 inline SVGStopElement::SVGStopElement(Document& document) | 30 inline SVGStopElement::SVGStopElement(Document& document) |
| 31 : SVGElement(SVGNames::stopTag, document) | 31 : SVGElement(SVGNames::stopTag, document) |
| 32 , m_offset(SVGAnimatedNumber::create(this, SVGNames::offsetAttr, SVGNumberAc
ceptPercentage::create())) | 32 , m_offset(SVGAnimatedNumber::create(this, SVGNames::offsetAttr, SVGNumberAc
ceptPercentage::create())) |
| 33 { | 33 { |
| 34 addToPropertyMap(m_offset); | 34 addToPropertyMap(m_offset); |
| 35 } | 35 } |
| 36 | 36 |
| 37 DEFINE_NODE_FACTORY(SVGStopElement) | 37 DEFINE_NODE_FACTORY(SVGStopElement) |
| 38 | 38 |
| 39 bool SVGStopElement::isSupportedAttribute(const QualifiedName& attrName) | |
| 40 { | |
| 41 DEFINE_STATIC_LOCAL(HashSet<QualifiedName>, supportedAttributes, ()); | |
| 42 if (supportedAttributes.isEmpty()) | |
| 43 supportedAttributes.add(SVGNames::offsetAttr); | |
| 44 return supportedAttributes.contains<SVGAttributeHashTranslator>(attrName); | |
| 45 } | |
| 46 | |
| 47 void SVGStopElement::parseAttribute(const QualifiedName& name, const AtomicStrin
g& value) | 39 void SVGStopElement::parseAttribute(const QualifiedName& name, const AtomicStrin
g& value) |
| 48 { | 40 { |
| 49 if (!isSupportedAttribute(name)) { | 41 parseAttributeNew(name, value); |
| 50 SVGElement::parseAttribute(name, value); | |
| 51 return; | |
| 52 } | |
| 53 | |
| 54 SVGParsingError parseError = NoError; | |
| 55 | |
| 56 if (name == SVGNames::offsetAttr) | |
| 57 m_offset->setBaseValueAsString(value, parseError); | |
| 58 else | |
| 59 ASSERT_NOT_REACHED(); | |
| 60 | |
| 61 reportAttributeParsingError(parseError, name, value); | |
| 62 } | 42 } |
| 63 | 43 |
| 64 void SVGStopElement::svgAttributeChanged(const QualifiedName& attrName) | 44 void SVGStopElement::svgAttributeChanged(const QualifiedName& attrName) |
| 65 { | 45 { |
| 66 if (!isSupportedAttribute(attrName)) { | 46 if (attrName == SVGNames::offsetAttr) { |
| 67 SVGElement::svgAttributeChanged(attrName); | 47 SVGElement::InvalidationGuard invalidationGuard(this); |
| 48 |
| 49 if (renderer()) |
| 50 RenderSVGResource::markForLayoutAndParentResourceInvalidation(render
er()); |
| 51 |
| 68 return; | 52 return; |
| 69 } | 53 } |
| 70 | 54 |
| 71 SVGElement::InvalidationGuard invalidationGuard(this); | 55 SVGElement::svgAttributeChanged(attrName); |
| 72 | |
| 73 if (!renderer()) | |
| 74 return; | |
| 75 | |
| 76 if (attrName == SVGNames::offsetAttr) { | |
| 77 RenderSVGResource::markForLayoutAndParentResourceInvalidation(renderer()
); | |
| 78 return; | |
| 79 } | |
| 80 | |
| 81 ASSERT_NOT_REACHED(); | |
| 82 } | 56 } |
| 83 | 57 |
| 84 RenderObject* SVGStopElement::createRenderer(RenderStyle*) | 58 RenderObject* SVGStopElement::createRenderer(RenderStyle*) |
| 85 { | 59 { |
| 86 return new RenderSVGGradientStop(this); | 60 return new RenderSVGGradientStop(this); |
| 87 } | 61 } |
| 88 | 62 |
| 89 bool SVGStopElement::rendererIsNeeded(const RenderStyle&) | 63 bool SVGStopElement::rendererIsNeeded(const RenderStyle&) |
| 90 { | 64 { |
| 91 return true; | 65 return true; |
| 92 } | 66 } |
| 93 | 67 |
| 94 Color SVGStopElement::stopColorIncludingOpacity() const | 68 Color SVGStopElement::stopColorIncludingOpacity() const |
| 95 { | 69 { |
| 96 RenderStyle* style = renderer() ? renderer()->style() : 0; | 70 RenderStyle* style = renderer() ? renderer()->style() : 0; |
| 97 // FIXME: This check for null style exists to address Bug WK 90814, a rare c
rash condition in | 71 // FIXME: This check for null style exists to address Bug WK 90814, a rare c
rash condition in |
| 98 // which the renderer or style is null. This entire class is scheduled for r
emoval (Bug WK 86941) | 72 // which the renderer or style is null. This entire class is scheduled for r
emoval (Bug WK 86941) |
| 99 // and we will tolerate this null check until then. | 73 // and we will tolerate this null check until then. |
| 100 if (!style) | 74 if (!style) |
| 101 return Color(Color::transparent); // Transparent black. | 75 return Color(Color::transparent); // Transparent black. |
| 102 | 76 |
| 103 const SVGRenderStyle& svgStyle = style->svgStyle(); | 77 const SVGRenderStyle& svgStyle = style->svgStyle(); |
| 104 return svgStyle.stopColor().combineWithAlpha(svgStyle.stopOpacity()); | 78 return svgStyle.stopColor().combineWithAlpha(svgStyle.stopOpacity()); |
| 105 } | 79 } |
| 106 | 80 |
| 107 } // namespace blink | 81 } // namespace blink |
| OLD | NEW |