Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(22)

Side by Side Diff: Source/core/svg/SVGStopElement.cpp

Issue 21042009: [SVG2] Merge SVGStyledElement into SVGElement (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase on master Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/svg/SVGStopElement.h ('k') | Source/core/svg/SVGStopElement.idl » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 16 matching lines...) Expand all
27 #include "core/rendering/svg/RenderSVGResource.h" 27 #include "core/rendering/svg/RenderSVGResource.h"
28 #include "core/svg/SVGElementInstance.h" 28 #include "core/svg/SVGElementInstance.h"
29 29
30 namespace WebCore { 30 namespace WebCore {
31 31
32 // Animated property definitions 32 // Animated property definitions
33 DEFINE_ANIMATED_NUMBER(SVGStopElement, SVGNames::offsetAttr, Offset, offset) 33 DEFINE_ANIMATED_NUMBER(SVGStopElement, SVGNames::offsetAttr, Offset, offset)
34 34
35 BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGStopElement) 35 BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGStopElement)
36 REGISTER_LOCAL_ANIMATED_PROPERTY(offset) 36 REGISTER_LOCAL_ANIMATED_PROPERTY(offset)
37 REGISTER_PARENT_ANIMATED_PROPERTIES(SVGStyledElement) 37 REGISTER_PARENT_ANIMATED_PROPERTIES(SVGElement)
38 END_REGISTER_ANIMATED_PROPERTIES 38 END_REGISTER_ANIMATED_PROPERTIES
39 39
40 inline SVGStopElement::SVGStopElement(const QualifiedName& tagName, Document* do cument) 40 inline SVGStopElement::SVGStopElement(const QualifiedName& tagName, Document* do cument)
41 : SVGStyledElement(tagName, document) 41 : SVGElement(tagName, document)
42 , m_offset(0) 42 , m_offset(0)
43 { 43 {
44 ASSERT(hasTagName(SVGNames::stopTag)); 44 ASSERT(hasTagName(SVGNames::stopTag));
45 ScriptWrappable::init(this); 45 ScriptWrappable::init(this);
46 registerAnimatedPropertiesForSVGStopElement(); 46 registerAnimatedPropertiesForSVGStopElement();
47 } 47 }
48 48
49 PassRefPtr<SVGStopElement> SVGStopElement::create(const QualifiedName& tagName, Document* document) 49 PassRefPtr<SVGStopElement> SVGStopElement::create(const QualifiedName& tagName, Document* document)
50 { 50 {
51 return adoptRef(new SVGStopElement(tagName, document)); 51 return adoptRef(new SVGStopElement(tagName, document));
52 } 52 }
53 53
54 bool SVGStopElement::isSupportedAttribute(const QualifiedName& attrName) 54 bool SVGStopElement::isSupportedAttribute(const QualifiedName& attrName)
55 { 55 {
56 DEFINE_STATIC_LOCAL(HashSet<QualifiedName>, supportedAttributes, ()); 56 DEFINE_STATIC_LOCAL(HashSet<QualifiedName>, supportedAttributes, ());
57 if (supportedAttributes.isEmpty()) 57 if (supportedAttributes.isEmpty())
58 supportedAttributes.add(SVGNames::offsetAttr); 58 supportedAttributes.add(SVGNames::offsetAttr);
59 return supportedAttributes.contains<SVGAttributeHashTranslator>(attrName); 59 return supportedAttributes.contains<SVGAttributeHashTranslator>(attrName);
60 } 60 }
61 61
62 void SVGStopElement::parseAttribute(const QualifiedName& name, const AtomicStrin g& value) 62 void SVGStopElement::parseAttribute(const QualifiedName& name, const AtomicStrin g& value)
63 { 63 {
64 if (!isSupportedAttribute(name)) { 64 if (!isSupportedAttribute(name)) {
65 SVGStyledElement::parseAttribute(name, value); 65 SVGElement::parseAttribute(name, value);
66 return; 66 return;
67 } 67 }
68 68
69 if (name == SVGNames::offsetAttr) { 69 if (name == SVGNames::offsetAttr) {
70 if (value.endsWith('%')) 70 if (value.endsWith('%'))
71 setOffsetBaseValue(value.string().left(value.length() - 1).toFloat() / 100.0f); 71 setOffsetBaseValue(value.string().left(value.length() - 1).toFloat() / 100.0f);
72 else 72 else
73 setOffsetBaseValue(value.toFloat()); 73 setOffsetBaseValue(value.toFloat());
74 return; 74 return;
75 } 75 }
76 76
77 ASSERT_NOT_REACHED(); 77 ASSERT_NOT_REACHED();
78 } 78 }
79 79
80 void SVGStopElement::svgAttributeChanged(const QualifiedName& attrName) 80 void SVGStopElement::svgAttributeChanged(const QualifiedName& attrName)
81 { 81 {
82 if (!isSupportedAttribute(attrName)) { 82 if (!isSupportedAttribute(attrName)) {
83 SVGStyledElement::svgAttributeChanged(attrName); 83 SVGElement::svgAttributeChanged(attrName);
84 return; 84 return;
85 } 85 }
86 86
87 SVGElementInstance::InvalidationGuard invalidationGuard(this); 87 SVGElementInstance::InvalidationGuard invalidationGuard(this);
88 88
89 if (!renderer()) 89 if (!renderer())
90 return; 90 return;
91 91
92 if (attrName == SVGNames::offsetAttr) { 92 if (attrName == SVGNames::offsetAttr) {
93 RenderSVGResource::markForLayoutAndParentResourceInvalidation(renderer() ); 93 RenderSVGResource::markForLayoutAndParentResourceInvalidation(renderer() );
(...skipping 20 matching lines...) Expand all
114 // which the renderer or style is null. This entire class is scheduled for r emoval (Bug WK 86941) 114 // which the renderer or style is null. This entire class is scheduled for r emoval (Bug WK 86941)
115 // and we will tolerate this null check until then. 115 // and we will tolerate this null check until then.
116 if (!style || !style->svgStyle()) 116 if (!style || !style->svgStyle())
117 return Color(Color::transparent); // Transparent black. 117 return Color(Color::transparent); // Transparent black.
118 118
119 const SVGRenderStyle* svgStyle = style->svgStyle(); 119 const SVGRenderStyle* svgStyle = style->svgStyle();
120 return colorWithOverrideAlpha(svgStyle->stopColor().rgb(), svgStyle->stopOpa city()); 120 return colorWithOverrideAlpha(svgStyle->stopColor().rgb(), svgStyle->stopOpa city());
121 } 121 }
122 122
123 } 123 }
OLDNEW
« no previous file with comments | « Source/core/svg/SVGStopElement.h ('k') | Source/core/svg/SVGStopElement.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698