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

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

Issue 1074813002: Remove isSupportedAttribute in svg (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: fixups Created 5 years, 8 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
OLDNEW
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) 2005 Alexander Kellett <lypanov@kde.org> 4 * Copyright (C) 2005 Alexander Kellett <lypanov@kde.org>
5 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org> 5 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org>
6 * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved. 6 * Copyright (C) Research In Motion Limited 2009-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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 visitor->trace(m_width); 62 visitor->trace(m_width);
63 visitor->trace(m_height); 63 visitor->trace(m_height);
64 visitor->trace(m_maskUnits); 64 visitor->trace(m_maskUnits);
65 visitor->trace(m_maskContentUnits); 65 visitor->trace(m_maskContentUnits);
66 SVGElement::trace(visitor); 66 SVGElement::trace(visitor);
67 SVGTests::trace(visitor); 67 SVGTests::trace(visitor);
68 } 68 }
69 69
70 DEFINE_NODE_FACTORY(SVGMaskElement) 70 DEFINE_NODE_FACTORY(SVGMaskElement)
71 71
72 bool SVGMaskElement::isSupportedAttribute(const QualifiedName& attrName)
73 {
74 DEFINE_STATIC_LOCAL(HashSet<QualifiedName>, supportedAttributes, ());
75 if (supportedAttributes.isEmpty()) {
76 SVGTests::addSupportedAttributes(supportedAttributes);
77 supportedAttributes.add(SVGNames::maskUnitsAttr);
78 supportedAttributes.add(SVGNames::maskContentUnitsAttr);
79 supportedAttributes.add(SVGNames::xAttr);
80 supportedAttributes.add(SVGNames::yAttr);
81 supportedAttributes.add(SVGNames::widthAttr);
82 supportedAttributes.add(SVGNames::heightAttr);
83 }
84 return supportedAttributes.contains<SVGAttributeHashTranslator>(attrName);
85 }
86
87 bool SVGMaskElement::isPresentationAttribute(const QualifiedName& attrName) cons t 72 bool SVGMaskElement::isPresentationAttribute(const QualifiedName& attrName) cons t
88 { 73 {
89 if (attrName == SVGNames::xAttr || attrName == SVGNames::yAttr 74 if (attrName == SVGNames::xAttr || attrName == SVGNames::yAttr
90 || attrName == SVGNames::widthAttr || attrName == SVGNames::heightAttr) 75 || attrName == SVGNames::widthAttr || attrName == SVGNames::heightAttr)
91 return true; 76 return true;
92 return SVGElement::isPresentationAttribute(attrName); 77 return SVGElement::isPresentationAttribute(attrName);
93 } 78 }
94 79
95 bool SVGMaskElement::isPresentationAttributeWithSVGDOM(const QualifiedName& attr Name) const 80 bool SVGMaskElement::isPresentationAttributeWithSVGDOM(const QualifiedName& attr Name) const
96 { 81 {
(...skipping 13 matching lines...) Expand all
110 else if (property == m_width) 95 else if (property == m_width)
111 addSVGLengthPropertyToPresentationAttributeStyle(style, CSSPropertyWidth , *m_width->currentValue()); 96 addSVGLengthPropertyToPresentationAttributeStyle(style, CSSPropertyWidth , *m_width->currentValue());
112 else if (property == m_height) 97 else if (property == m_height)
113 addSVGLengthPropertyToPresentationAttributeStyle(style, CSSPropertyHeigh t, *m_height->currentValue()); 98 addSVGLengthPropertyToPresentationAttributeStyle(style, CSSPropertyHeigh t, *m_height->currentValue());
114 else 99 else
115 SVGElement::collectStyleForPresentationAttribute(name, value, style); 100 SVGElement::collectStyleForPresentationAttribute(name, value, style);
116 } 101 }
117 102
118 void SVGMaskElement::svgAttributeChanged(const QualifiedName& attrName) 103 void SVGMaskElement::svgAttributeChanged(const QualifiedName& attrName)
119 { 104 {
120 if (!isSupportedAttribute(attrName)) { 105 bool isLengthAttr = attrName == SVGNames::xAttr
121 SVGElement::svgAttributeChanged(attrName);
122 return;
123 }
124
125 SVGElement::InvalidationGuard invalidationGuard(this);
126
127 if (attrName == SVGNames::xAttr
128 || attrName == SVGNames::yAttr 106 || attrName == SVGNames::yAttr
129 || attrName == SVGNames::widthAttr 107 || attrName == SVGNames::widthAttr
130 || attrName == SVGNames::heightAttr) { 108 || attrName == SVGNames::heightAttr;
109
110 if (isLengthAttr) {
131 invalidateSVGPresentationAttributeStyle(); 111 invalidateSVGPresentationAttributeStyle();
132 setNeedsStyleRecalc(LocalStyleChange, 112 setNeedsStyleRecalc(LocalStyleChange,
133 StyleChangeReasonForTracing::fromAttribute(attrName)); 113 StyleChangeReasonForTracing::fromAttribute(attrName));
134 updateRelativeLengthsInformation(); 114 updateRelativeLengthsInformation();
135 } 115 }
136 116
137 LayoutSVGResourceContainer* renderer = toLayoutSVGResourceContainer(this->la youtObject()); 117 if (isLengthAttr
138 if (renderer) 118 || attrName == SVGNames::maskUnitsAttr
139 renderer->invalidateCacheAndMarkForLayout(); 119 || attrName == SVGNames::maskContentUnitsAttr
120 || SVGTests::isKnownAttribute(attrName)) {
121 SVGElement::InvalidationGuard invalidationGuard(this);
122 LayoutSVGResourceContainer* renderer = toLayoutSVGResourceContainer(this ->layoutObject());
123 if (renderer)
124 renderer->invalidateCacheAndMarkForLayout();
125
126 return;
127 }
128
129 SVGElement::svgAttributeChanged(attrName);
140 } 130 }
141 131
142 void SVGMaskElement::childrenChanged(const ChildrenChange& change) 132 void SVGMaskElement::childrenChanged(const ChildrenChange& change)
143 { 133 {
144 SVGElement::childrenChanged(change); 134 SVGElement::childrenChanged(change);
145 135
146 if (change.byParser) 136 if (change.byParser)
147 return; 137 return;
148 138
149 if (LayoutObject* object = layoutObject()) 139 if (LayoutObject* object = layoutObject())
150 object->setNeedsLayoutAndFullPaintInvalidation(LayoutInvalidationReason: :ChildChanged); 140 object->setNeedsLayoutAndFullPaintInvalidation(LayoutInvalidationReason: :ChildChanged);
151 } 141 }
152 142
153 LayoutObject* SVGMaskElement::createLayoutObject(const ComputedStyle&) 143 LayoutObject* SVGMaskElement::createLayoutObject(const ComputedStyle&)
154 { 144 {
155 return new LayoutSVGResourceMasker(this); 145 return new LayoutSVGResourceMasker(this);
156 } 146 }
157 147
158 bool SVGMaskElement::selfHasRelativeLengths() const 148 bool SVGMaskElement::selfHasRelativeLengths() const
159 { 149 {
160 return m_x->currentValue()->isRelative() 150 return m_x->currentValue()->isRelative()
161 || m_y->currentValue()->isRelative() 151 || m_y->currentValue()->isRelative()
162 || m_width->currentValue()->isRelative() 152 || m_width->currentValue()->isRelative()
163 || m_height->currentValue()->isRelative(); 153 || m_height->currentValue()->isRelative();
164 } 154 }
165 155
166 } // namespace blink 156 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698