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

Side by Side Diff: Source/core/rendering/svg/RenderSVGResourceGradient.cpp

Issue 622653003: Gradients should restrict possible content (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Patch for landing? Created 6 years, 2 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org> 2 * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org>
3 * Copyright (C) 2008 Eric Seidel <eric@webkit.org> 3 * Copyright (C) 2008 Eric Seidel <eric@webkit.org>
4 * Copyright (C) 2008 Dirk Schulze <krit@webkit.org> 4 * Copyright (C) 2008 Dirk Schulze <krit@webkit.org>
5 * Copyright (C) Research In Motion Limited 2010. All rights reserved. 5 * Copyright (C) Research In Motion Limited 2010. All rights reserved.
6 * 6 *
7 * This library is free software; you can redistribute it and/or 7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public 8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either 9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version. 10 * version 2 of the License, or (at your option) any later version.
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 127
128 return true; 128 return true;
129 } 129 }
130 130
131 void RenderSVGResourceGradient::postApplyResource(RenderObject*, GraphicsContext *& context) 131 void RenderSVGResourceGradient::postApplyResource(RenderObject*, GraphicsContext *& context)
132 { 132 {
133 ASSERT(context); 133 ASSERT(context);
134 context->restore(); 134 context->restore();
135 } 135 }
136 136
137 bool RenderSVGResourceGradient::isChildAllowed(RenderObject* child, RenderStyle* ) const
138 {
139 if (child->isSVGGradientStop())
140 return true;
141
142 if (!child->isSVGResourceContainer())
143 return false;
144
145 RenderSVGResourceContainer* resource = toRenderSVGResourceContainer(child);
146 return resource->resourceType() == PatternResourceType
147 || resource->resourceType() == LinearGradientResourceType
148 || resource->resourceType() == RadialGradientResourceType;
149 }
150
137 void RenderSVGResourceGradient::addStops(GradientData* gradientData, const Vecto r<Gradient::ColorStop>& stops) const 151 void RenderSVGResourceGradient::addStops(GradientData* gradientData, const Vecto r<Gradient::ColorStop>& stops) const
138 { 152 {
139 ASSERT(gradientData->gradient); 153 ASSERT(gradientData->gradient);
140 154
141 const Vector<Gradient::ColorStop>::const_iterator end = stops.end(); 155 const Vector<Gradient::ColorStop>::const_iterator end = stops.end();
142 for (Vector<Gradient::ColorStop>::const_iterator it = stops.begin(); it != e nd; ++it) 156 for (Vector<Gradient::ColorStop>::const_iterator it = stops.begin(); it != e nd; ++it)
143 gradientData->gradient->addColorStop(*it); 157 gradientData->gradient->addColorStop(*it);
144 } 158 }
145 159
146 GradientSpreadMethod RenderSVGResourceGradient::platformSpreadMethodFromSVGType( SVGSpreadMethodType method) const 160 GradientSpreadMethod RenderSVGResourceGradient::platformSpreadMethodFromSVGType( SVGSpreadMethodType method) const
147 { 161 {
148 switch (method) { 162 switch (method) {
149 case SVGSpreadMethodUnknown: 163 case SVGSpreadMethodUnknown:
150 case SVGSpreadMethodPad: 164 case SVGSpreadMethodPad:
151 return SpreadMethodPad; 165 return SpreadMethodPad;
152 case SVGSpreadMethodReflect: 166 case SVGSpreadMethodReflect:
153 return SpreadMethodReflect; 167 return SpreadMethodReflect;
154 case SVGSpreadMethodRepeat: 168 case SVGSpreadMethodRepeat:
155 return SpreadMethodRepeat; 169 return SpreadMethodRepeat;
156 } 170 }
157 171
158 ASSERT_NOT_REACHED(); 172 ASSERT_NOT_REACHED();
159 return SpreadMethodPad; 173 return SpreadMethodPad;
160 } 174 }
161 175
162 } 176 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698